ITADN

Kotlin SDK relies on deprecated kotlinx.datetime.Instant, making instantiating mock classes difficult

#2079Opensalockhart 创建于 2025-10-02
S
salockhartcommented
## Bug Report <!-- Thank you for reporting an issue. Please fill in as much of the template below as you're able. --> ### Version ``` com.svix.kotlin:svix-kotlin:1.76.1 ``` ### Platform ``` Darwin {name omitted} 24.6.0 Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:29 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6000 arm64 ``` ### Description [The `ApplicationOut` class](https://github.com/svix/svix-webhooks/blob/c7cad42f2600db7bd45fc43a5d87634181c94631/kotlin/lib/src/main/kotlin/models/ApplicationOut.kt) is defined as follows: ```kt // This file is @generated package com.svix.kotlin.models import kotlinx.datetime.Instant import kotlinx.serialization.Serializable @Serializable data class ApplicationOut( val createdAt: Instant, ... ``` Here, `createdAt` (and `updatedAt`, not visible) rely on the `kotlinx.datetime.Instant` class to define a datetime. The `kotlinx.datetime.Instant` class is [deprecated](https://github.com/Kotlin/kotlinx-datetime#deprecation-of-instant) in favour of `kotlin.time.Instant`, which is functionally identical but unfortunately not able to be used to instantiate an `ApplicationOut` object. This makes unit testing difficult - I can pull in the older version of `org.jetbrains.kotlinx:kotlinx-datetime` in order to get these classes, but they are incompatible with the rest of my codebase. A possible solution may be to upgrade to `org.jetbrains.kotlinx:kotlinx-datetime:0.7.1`. In [this version](https://github.com/Kotlin/kotlinx-datetime/releases/tag/v0.7.1), the deprecated types have been aliased to the new ones.
1 条评论