From 9ab0c701c594f42dad8fda417115e7c4106544cf Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Fri, 10 May 2024 14:30:55 -0700 Subject: [PATCH] Fix #1271: reprecate LockFreePool in 2.18 (to be removed from 3.0) (#1291) --- release-notes/VERSION-2.x | 1 + .../jackson/core/util/JsonRecyclerPools.java | 21 +++++++++++++++++-- .../jackson/core/util/RecyclerPool.java | 10 +++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 5ae16bfaaa..d717cbd192 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -30,6 +30,7 @@ a pure JSON library. to prevent use by downstream consumers (requested by @seadbrane) #1266: Change default recycler pool to `newConcurrentDequePool()` in 2.18 +#1271: Deprecate `LockFreePool` implementation in 2.18 (remove from 3.0) #1277: Add back Java 22 optimisation in FastDoubleParser 2.17.1 (04-May-2024) diff --git a/src/main/java/com/fasterxml/jackson/core/util/JsonRecyclerPools.java b/src/main/java/com/fasterxml/jackson/core/util/JsonRecyclerPools.java index fffb93f1d3..aa43095075 100644 --- a/src/main/java/com/fasterxml/jackson/core/util/JsonRecyclerPools.java +++ b/src/main/java/com/fasterxml/jackson/core/util/JsonRecyclerPools.java @@ -6,7 +6,6 @@ import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.util.RecyclerPool.BoundedPoolBase; import com.fasterxml.jackson.core.util.RecyclerPool.ConcurrentDequePoolBase; -import com.fasterxml.jackson.core.util.RecyclerPool.LockFreePoolBase; /** * Set of {@link RecyclerPool} implementations to be used by the default @@ -74,7 +73,11 @@ public static RecyclerPool newConcurrentDequePool() { * Accessor for getting the shared/global {@link LockFreePool} instance. * * @return Globally shared instance of {@link LockFreePool}. + * + * @deprecated Since 2.18: use one of other implementations instead; + * see {@link LockFreePool} Javadocs for details */ + @Deprecated // since 2.18 public static RecyclerPool sharedLockFreePool() { return LockFreePool.GLOBAL; } @@ -83,7 +86,11 @@ public static RecyclerPool sharedLockFreePool() { * Accessor for constructing a new, non-shared {@link LockFreePool} instance. * * @return Globally shared instance of {@link LockFreePool}. + * + * @deprecated Since 2.18: use one of other implementations instead; + * see {@link LockFreePool} Javadocs for details */ + @Deprecated // since 2.18 public static RecyclerPool newLockFreePool() { return LockFreePool.construct(); } @@ -204,8 +211,18 @@ protected Object readResolve() { *

* Pool is unbounded: see {@link RecyclerPool} for * details on what this means. + *

+ * NOTE: serious issues found with 2.17.0 lead to deprecation + * of this implementation -- basically it is possible to have + * unbalanced acquire/release success rate lead to excessive + * growth of pooled instances. + * See + * jackson-core#1260 for details. + * + * @deprecated Since 2.18: use other implementations instead */ - public static class LockFreePool extends LockFreePoolBase + @Deprecated + public static class LockFreePool extends RecyclerPool.LockFreePoolBase { private static final long serialVersionUID = 1L; diff --git a/src/main/java/com/fasterxml/jackson/core/util/RecyclerPool.java b/src/main/java/com/fasterxml/jackson/core/util/RecyclerPool.java index 13bfe57327..0973e139bd 100644 --- a/src/main/java/com/fasterxml/jackson/core/util/RecyclerPool.java +++ b/src/main/java/com/fasterxml/jackson/core/util/RecyclerPool.java @@ -309,7 +309,17 @@ public boolean clear() { * a lock free linked list for recycling instances. * Pool is unbounded: see {@link RecyclerPool} for * details on what this means. + *

+ * NOTE: serious issues found with 2.17.0 lead to deprecation + * of this implementation -- basically it is possible to have + * unbalanced acquire/release success rate lead to excessive + * growth of pooled instances. + * See + * jackson-core#1260 for details. + * + * @deprecated Since 2.18: use other implementations */ + @Deprecated // since 2.18 abstract class LockFreePoolBase

> extends StatefulImplBase

{