-
-
Notifications
You must be signed in to change notification settings - Fork 180
Description
Search before asking
- I searched in the issues and found nothing similar.
- I have confirmed that the same problem is not reproduced if I exclude the KotlinModule.
- I searched in the issues of databind and other modules used and found nothing similar.
- I have confirmed that the problem does not reproduce in Java and only occurs when using Kotlin and KotlinModule.
Describe the bug
The new kotlin annotation defaulting rule described here: https://youtrack.jetbrains.com/issue/KT-73255 is introduced in kotlin 2.2.0 as opt-in (-Xannotation-default-target=param-property
). Enabling it causes this test to fail with:
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Problem with definition of [AnnotedClass com.trib3.json.InjectedValueBean]: Duplicate injectable value with id 'Key[type=com.trib3.json.SimpleBean, annotation=[none]]' (of type `com.google.inject.Key`)
at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 1]
To Reproduce
https://github.com/josephlbarnett/leakycauldron/blob/main/json/src/test/kotlin/com/trib3/json/ObjectMapperTest.kt#L171-L179 tries to read an InjectedValueBean
from json with this bean definition:
private data class SimpleBean(
val foo: String,
val bar: Int,
val maybe: String?,
val date: LocalDate?,
val ignoreMe: String? = null,
)
private data class InjectedValueBean(
val foo: String,
val bar: Int,
@JacksonInject
val injectedBeanDefault: SimpleBean,
@JacksonInject(useInput = OptBoolean.TRUE)
val injectedBeanTrue: SimpleBean,
@JacksonInject(useInput = OptBoolean.FALSE)
val injectedBeanFalse: SimpleBean,
)
Expected behavior
changing the @JacksonInject
s to @param:JacksonInject
s in the InjectedValueBean
definition fixes the issue, but would be nice to not have to
Versions
Kotlin: 2.2.0
Jackson-module-kotlin: 2.19.0
Jackson-databind: 2.19.0
Additional context
initially filed as FasterXML/jackson-databind#5206 but asked to move here (there may be a way to generate a java class that reproduces this in contrast to checkbox 4)