Skip to content

Commit

Permalink
Merge pull request #758 from k163377/dep-singleton
Browse files Browse the repository at this point in the history
Deprecated SingletonSupport
  • Loading branch information
k163377 authored Jan 12, 2024
2 parents d020730 + 0387f27 commit 2625ebc
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 0 deletions.
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

0 comments on commit 2625ebc

Please sign in to comment.