Skip to content

Commit 2625ebc

Browse files
authored
Merge pull request #758 from k163377/dep-singleton
Deprecated SingletonSupport
2 parents d020730 + 0387f27 commit 2625ebc

File tree

5 files changed

+17
-0
lines changed

5 files changed

+17
-0
lines changed

release-notes/CREDITS-2.x

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Contributors:
1818
# 2.17.0 (not yet released)
1919

2020
WrongWrong (@k163377)
21+
* #758: Deprecated SingletonSupport.
2122
* #755: Changes in constructor invocation and argument management.
2223
* #752: Fix KDoc for KotlinModule.
2324
* #751: Marked useKotlinPropertyNameForGetter as deprecated.

release-notes/VERSION-2.x

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Co-maintainers:
1818

1919
2.17.0 (not yet released)
2020

21+
#758: Deprecated SingletonSupport and related properties to be consistent with KotlinFeature.SingletonSupport.
2122
#755: Changes in constructor invocation and argument management.
2223
This change degrades performance in cases where the constructor is called without default arguments, but improves performance in other cases.
2324
#751: The KotlinModule#useKotlinPropertyNameForGetter property was deprecated because it differed from the name of the KotlinFeature.

src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinModule.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ fun Class<*>.isKotlinClass(): Boolean = this.isAnnotationPresent(Metadata::class
2525
* using the default value provided in Kotlin.
2626
* @property singletonSupport Default: DISABLED. Mode for singleton handling.
2727
* See {@link com.fasterxml.jackson.module.kotlin.SingletonSupport label}
28+
* @property enabledSingletonSupport Default: false. A temporary property that is maintained until the return value of `singletonSupport` is changed.
29+
* It will be removed in 2.21.
2830
* @property strictNullChecks Default: false. Whether to check deserialized collections. With this disabled,
2931
* the default, collections which are typed to disallow null members
3032
* (e.g. List<String>) may contain null values after deserialization. Enabling it
@@ -53,6 +55,11 @@ class KotlinModule @Deprecated(
5355
val nullToEmptyCollection: Boolean = NullToEmptyCollection.enabledByDefault,
5456
val nullToEmptyMap: Boolean = NullToEmptyMap.enabledByDefault,
5557
val nullIsSameAsDefault: Boolean = NullIsSameAsDefault.enabledByDefault,
58+
@property:Deprecated(
59+
level = DeprecationLevel.WARNING,
60+
message = "The return value will be Boolean in 2.19. Until then, use enabledSingletonSupport.",
61+
replaceWith = ReplaceWith("enabledSingletonSupport")
62+
)
5663
val singletonSupport: SingletonSupport = DISABLED,
5764
val strictNullChecks: Boolean = StrictNullChecks.enabledByDefault,
5865
@Deprecated(
@@ -65,6 +72,7 @@ class KotlinModule @Deprecated(
6572
val useJavaDurationConversion: Boolean = UseJavaDurationConversion.enabledByDefault,
6673
) : SimpleModule(KotlinModule::class.java.name, PackageVersion.VERSION) {
6774
val kotlinPropertyNameAsImplicitName: Boolean get() = useKotlinPropertyNameForGetter
75+
val enabledSingletonSupport: Boolean get() = singletonSupport == CANONICALIZE
6876

6977
companion object {
7078
// Increment when option is added

src/main/kotlin/com/fasterxml/jackson/module/kotlin/SingletonSupport.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ package com.fasterxml.jackson.module.kotlin
33
/**
44
* Special handling for singletons.
55
*/
6+
@Deprecated(
7+
level = DeprecationLevel.WARNING,
8+
message = "It will be removed in 2.19 to unify with KotlinFeature.",
9+
replaceWith = ReplaceWith("KotlinFeature.SingletonSupport")
10+
)
611
enum class SingletonSupport {
712
// No special handling of singletons (pre-2.10 behavior)
813
// Each time a Singleton object is deserialized a new instance is created.

src/test/kotlin/com/fasterxml/jackson/module/kotlin/KotlinModuleTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class KotlinModuleTest {
1818
assertFalse(module.nullToEmptyMap)
1919
assertFalse(module.nullIsSameAsDefault)
2020
assertEquals(SingletonSupport.DISABLED, module.singletonSupport)
21+
assertFalse(module.enabledSingletonSupport)
2122
assertFalse(module.strictNullChecks)
2223
assertFalse(module.kotlinPropertyNameAsImplicitName)
2324
assertFalse(module.useJavaDurationConversion)
@@ -41,6 +42,7 @@ class KotlinModuleTest {
4142
assertTrue(module.nullToEmptyMap)
4243
assertTrue(module.nullIsSameAsDefault)
4344
assertEquals(SingletonSupport.CANONICALIZE, module.singletonSupport)
45+
assertTrue(module.enabledSingletonSupport)
4446
assertTrue(module.strictNullChecks)
4547
assertTrue(module.kotlinPropertyNameAsImplicitName)
4648
assertTrue(module.useJavaDurationConversion)

0 commit comments

Comments
 (0)