File tree 4 files changed +12
-17
lines changed
src/main/kotlin/com/fasterxml/jackson/module/kotlin
4 files changed +12
-17
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ Authors:
16
16
Contributors :
17
17
18
18
# 2 .17.0 (not yet released)
19
+ * #727 : Fixed overriding findCreatorAnnotation instead of hasCreatorAnnotation
19
20
20
21
# 2 .16.0
21
22
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ Co-maintainers:
18
18
19
19
2.17 .0 (not yet released )
20
20
21
- -
21
+ #727 : Fixed overriding findCreatorAnnotation instead of hasCreatorAnnotation .
22
22
23
23
2.16 .0 (15 - Nov - 2023 )
24
24
Original file line number Diff line number Diff line change 1
1
package com.fasterxml.jackson.module.kotlin
2
2
3
- import com.fasterxml.jackson.annotation.JsonCreator
4
3
import com.fasterxml.jackson.annotation.JsonProperty
5
4
import com.fasterxml.jackson.databind.DeserializationFeature
6
5
import com.fasterxml.jackson.databind.JsonSerializer
7
6
import com.fasterxml.jackson.databind.Module
8
- import com.fasterxml.jackson.databind.cfg.MapperConfig
9
7
import com.fasterxml.jackson.databind.introspect.*
10
8
import com.fasterxml.jackson.databind.jsontype.NamedType
11
9
import com.fasterxml.jackson.databind.util.Converter
@@ -59,15 +57,6 @@ internal class KotlinAnnotationIntrospector(
59
57
return hasRequired
60
58
}
61
59
62
- override fun findCreatorAnnotation (config : MapperConfig <* >, a : Annotated ): JsonCreator .Mode ? {
63
-
64
- // TODO: possible work around for JsonValue class that requires the class constructor to have the JsonCreator(Mode.DELEGATED) set?
65
- // since we infer the creator at times for these methods, the wrong mode could be implied.
66
-
67
- // findCreatorBinding used to be a clearer way to set this, but we need to set the mode here to disambugiate the intent of the constructor
68
- return super .findCreatorAnnotation(config, a)
69
- }
70
-
71
60
override fun findSerializationConverter (a : Annotated ): Converter <* , * >? = when (a) {
72
61
// Find a converter to handle the case where the getter returns an unboxed value from the value class.
73
62
is AnnotatedMethod -> a.findValueClassReturnType()?.let {
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package com.fasterxml.jackson.module.kotlin
2
2
3
3
import com.fasterxml.jackson.annotation.JsonCreator
4
4
import com.fasterxml.jackson.annotation.JsonProperty
5
+ import com.fasterxml.jackson.databind.cfg.MapperConfig
5
6
import com.fasterxml.jackson.databind.introspect.Annotated
6
7
import com.fasterxml.jackson.databind.introspect.AnnotatedConstructor
7
8
import com.fasterxml.jackson.databind.introspect.AnnotatedMember
@@ -111,11 +112,15 @@ internal class KotlinNamesAnnotationIntrospector(
111
112
}
112
113
}
113
114
114
- override fun hasCreatorAnnotation (member : Annotated ): Boolean =
115
- if (member is AnnotatedConstructor && member.isKotlinConstructorWithParameters())
116
- cache.checkConstructorIsCreatorAnnotated(member) { hasCreatorAnnotation(it) }
117
- else
118
- false
115
+ // TODO: possible work around for JsonValue class that requires the class constructor to have the JsonCreator(DELEGATED) set?
116
+ // since we infer the creator at times for these methods, the wrong mode could be implied.
117
+ override fun findCreatorAnnotation (config : MapperConfig <* >, ann : Annotated ): JsonCreator .Mode ? {
118
+ if (ann !is AnnotatedConstructor || ! ann.isKotlinConstructorWithParameters()) return null
119
+
120
+ return JsonCreator .Mode .DEFAULT .takeIf {
121
+ cache.checkConstructorIsCreatorAnnotated(ann) { hasCreatorAnnotation(it) }
122
+ }
123
+ }
119
124
120
125
@Suppress(" UNCHECKED_CAST" )
121
126
private fun findKotlinParameterName (param : AnnotatedParameter ): String? {
You can’t perform that action at this time.
0 commit comments