You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been using Kotlin 2.0.20, but I've tested with 1.6.21 and get the same error regardless. I've included a sample project illustrating the problem. Ironically, I created this project (hoplite-test.zip) in order to demonstrate the issue and I'm seeing the same behavior but the underlying cause is different.
The original project I'm working on is manifesting with a ClassCastException:
Exception in thread "main" com.sksamuel.hoplite.ConfigException: Error loading config because:
Could not instantiate class Simple from args [kotlin.time.Duration]: Expected args are [class kotlin.time.Duration]. Underlying error was java.lang.ClassCastException: Cannot cast java.lang.Long to kotlin.time.Duration
at com.sksamuel.hoplite.ConfigLoaderKt$returnOrThrow$1.invoke(ConfigLoader.kt:315)
at com.sksamuel.hoplite.ConfigLoaderKt$returnOrThrow$1.invoke(ConfigLoader.kt:312)
at com.sksamuel.hoplite.fp.ValidatedKt.getOrElse(Validated.kt:115)
at com.sksamuel.hoplite.ConfigLoaderKt.returnOrThrow(ConfigLoader.kt:312)
at com.sksamuel.hoplite.ConfigLoader.returnOrThrow(ConfigLoader.kt:273)
at SimpleKt.main(Simple.kt:33)
at SimpleKt.main(Simple.kt)
The demonstration project included here is also failing, but with a different underlying error:
com.sksamuel.hoplite.ConfigException: Error loading config because:
Could not instantiate class org.example.NotWorking$Simple from args [kotlin.time.Duration]: Expected args are [class kotlin.time.Duration]. Underlying error was java.lang.IllegalArgumentException: argument type mismatch
at com.sksamuel.hoplite.ConfigLoaderKt$returnOrThrow$1.invoke(ConfigLoader.kt:315)
at com.sksamuel.hoplite.ConfigLoaderKt$returnOrThrow$1.invoke(ConfigLoader.kt:312)
at com.sksamuel.hoplite.fp.ValidatedKt.getOrElse(Validated.kt:115)
at com.sksamuel.hoplite.ConfigLoaderKt.returnOrThrow(ConfigLoader.kt:312)
at com.sksamuel.hoplite.ConfigLoader.returnOrThrow(ConfigLoader.kt:273)
at org.example.DemoKt.main(Demo.kt:186)
at org.example.DemoKt.main(Demo.kt)
I've been trying to get it to fail the same way, but no success - maybe you'll see some difference in the configuration that isn't standing out to me.
In both cases the error is coming from the DataClassDecoder class (/com/sksamuel/hoplite/decoder/DataClassDecoder.kt:126, /com/sksamuel/hoplite/decoder/DataClassDecoder.kt:140, /com/sksamuel/hoplite/decoder/DataClassDecoder.kt:144)
I have only encountered this problem with kotlin.time.Duration?. kotlin.time.Duration works without any problem.
The text was updated successfully, but these errors were encountered:
I've been using Kotlin 2.0.20, but I've tested with 1.6.21 and get the same error regardless. I've included a sample project illustrating the problem. Ironically, I created this project (hoplite-test.zip) in order to demonstrate the issue and I'm seeing the same behavior but the underlying cause is different.
The original project I'm working on is manifesting with a ClassCastException:
The code that creates this stacktrace is
With this configuration file
The (slightly modified) build configuration is
The demonstration project included here is also failing, but with a different underlying error:
I've been trying to get it to fail the same way, but no success - maybe you'll see some difference in the configuration that isn't standing out to me.
In both cases the error is coming from the
DataClassDecoder
class (/com/sksamuel/hoplite/decoder/DataClassDecoder.kt:126, /com/sksamuel/hoplite/decoder/DataClassDecoder.kt:140, /com/sksamuel/hoplite/decoder/DataClassDecoder.kt:144)I have only encountered this problem with
kotlin.time.Duration?
.kotlin.time.Duration
works without any problem.The text was updated successfully, but these errors were encountered: