Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove meaningless checks and properties in KNAI. #542

Merged
merged 3 commits into from
Jun 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@
<exclude>com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#reflectionCacheSize(int)
</exclude>
<!-- internal -->
<exclude>
com.fasterxml.jackson.module.kotlin.KotlinNamesAnnotationIntrospector#KotlinNamesAnnotationIntrospector(com.fasterxml.jackson.module.kotlin.ReflectionCache,java.util.Set,boolean)
</exclude>

</excludes>
</parameter>
Expand Down
1 change: 1 addition & 0 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Contributors:

# 2.18.0 (not yet released)
* #782: Organize deprecated contents
* #542: Remove meaningless checks and properties in KNAI

# 2.17.2 (not yet released)

Expand Down
1 change: 1 addition & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Co-maintainers:
#782: Content marked as deprecated has been reorganized.
Several constructors and accessors to properties of KotlinModule.Builder that were marked as DeprecationLevel.ERROR have been removed.
Also, the content marked as DeprecationLevel.WARNING is now DeprecationLevel.ERROR.
#542: Remove meaningless checks and properties in KNAI.

2.17.2 (not yet released)
#799: Fixed problem with code compiled with 2.17.x losing backward compatibility.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ class KotlinModule private constructor(
builder.isEnabled(UseJavaDurationConversion),
)

private val ignoredClassesForImplyingJsonCreator = emptySet<KClass<*>>()

override fun setupModule(context: SetupContext) {
super.setupModule(context)

Expand All @@ -114,12 +112,7 @@ class KotlinModule private constructor(
nullIsSameAsDefault,
useJavaDurationConversion
))
context.appendAnnotationIntrospector(
KotlinNamesAnnotationIntrospector(
cache,
ignoredClassesForImplyingJsonCreator,
kotlinPropertyNameAsImplicitName)
)
context.appendAnnotationIntrospector(KotlinNamesAnnotationIntrospector(cache, kotlinPropertyNameAsImplicitName))

context.addDeserializers(KotlinDeserializers(cache, useJavaDurationConversion))
context.addKeyDeserializers(KotlinKeyDeserializers)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import kotlin.reflect.jvm.javaType

internal class KotlinNamesAnnotationIntrospector(
private val cache: ReflectionCache,
private val ignoredClassesForImplyingJsonCreator: Set<KClass<*>>,
private val useKotlinPropertyNameForGetter: Boolean
) : NopAnnotationIntrospector() {
private fun getterNameFromJava(member: AnnotatedMethod): String? {
Expand Down Expand Up @@ -89,7 +88,6 @@ internal class KotlinNamesAnnotationIntrospector(
// don't add a JsonCreator to any constructor if one is declared already

val kClass = member.declaringClass.kotlin
.apply { if (this in ignoredClassesForImplyingJsonCreator) return false }
val kConstructor = cache.kotlinFromJava(member.annotated) ?: return false

// TODO: should we do this check or not? It could cause failures if we miss another way a property could be set
Expand Down