Skip to content

Deprecated SingletonSupport #758

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

Merged
merged 2 commits into from
Jan 12, 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
1 change: 1 addition & 0 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Contributors:
# 2.17.0 (not yet released)

WrongWrong (@k163377)
* #758: Deprecated SingletonSupport.
* #755: Changes in constructor invocation and argument management.
* #752: Fix KDoc for KotlinModule.
* #751: Marked useKotlinPropertyNameForGetter as deprecated.
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 @@ -18,6 +18,7 @@ Co-maintainers:

2.17.0 (not yet released)

#758: Deprecated SingletonSupport and related properties to be consistent with KotlinFeature.SingletonSupport.
#755: Changes in constructor invocation and argument management.
This change degrades performance in cases where the constructor is called without default arguments, but improves performance in other cases.
#751: The KotlinModule#useKotlinPropertyNameForGetter property was deprecated because it differed from the name of the KotlinFeature.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ fun Class<*>.isKotlinClass(): Boolean = this.isAnnotationPresent(Metadata::class
* using the default value provided in Kotlin.
* @property singletonSupport Default: DISABLED. Mode for singleton handling.
* See {@link com.fasterxml.jackson.module.kotlin.SingletonSupport label}
* @property enabledSingletonSupport Default: false. A temporary property that is maintained until the return value of `singletonSupport` is changed.
* It will be removed in 2.21.
* @property strictNullChecks Default: false. Whether to check deserialized collections. With this disabled,
* the default, collections which are typed to disallow null members
* (e.g. List<String>) may contain null values after deserialization. Enabling it
Expand Down Expand Up @@ -53,6 +55,11 @@ class KotlinModule @Deprecated(
val nullToEmptyCollection: Boolean = NullToEmptyCollection.enabledByDefault,
val nullToEmptyMap: Boolean = NullToEmptyMap.enabledByDefault,
val nullIsSameAsDefault: Boolean = NullIsSameAsDefault.enabledByDefault,
@property:Deprecated(
level = DeprecationLevel.WARNING,
message = "The return value will be Boolean in 2.19. Until then, use enabledSingletonSupport.",
replaceWith = ReplaceWith("enabledSingletonSupport")
)
val singletonSupport: SingletonSupport = DISABLED,
val strictNullChecks: Boolean = StrictNullChecks.enabledByDefault,
@Deprecated(
Expand All @@ -65,6 +72,7 @@ class KotlinModule @Deprecated(
val useJavaDurationConversion: Boolean = UseJavaDurationConversion.enabledByDefault,
) : SimpleModule(KotlinModule::class.java.name, PackageVersion.VERSION) {
val kotlinPropertyNameAsImplicitName: Boolean get() = useKotlinPropertyNameForGetter
val enabledSingletonSupport: Boolean get() = singletonSupport == CANONICALIZE

companion object {
// Increment when option is added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ package com.fasterxml.jackson.module.kotlin
/**
* Special handling for singletons.
*/
@Deprecated(
level = DeprecationLevel.WARNING,
message = "It will be removed in 2.19 to unify with KotlinFeature.",
replaceWith = ReplaceWith("KotlinFeature.SingletonSupport")
)
enum class SingletonSupport {
// No special handling of singletons (pre-2.10 behavior)
// Each time a Singleton object is deserialized a new instance is created.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class KotlinModuleTest {
assertFalse(module.nullToEmptyMap)
assertFalse(module.nullIsSameAsDefault)
assertEquals(SingletonSupport.DISABLED, module.singletonSupport)
assertFalse(module.enabledSingletonSupport)
assertFalse(module.strictNullChecks)
assertFalse(module.kotlinPropertyNameAsImplicitName)
assertFalse(module.useJavaDurationConversion)
Expand All @@ -41,6 +42,7 @@ class KotlinModuleTest {
assertTrue(module.nullToEmptyMap)
assertTrue(module.nullIsSameAsDefault)
assertEquals(SingletonSupport.CANONICALIZE, module.singletonSupport)
assertTrue(module.enabledSingletonSupport)
assertTrue(module.strictNullChecks)
assertTrue(module.kotlinPropertyNameAsImplicitName)
assertTrue(module.useJavaDurationConversion)
Expand Down