From 11b9a96583aec0172ccd00e698cd695a85bead7f Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 28 Mar 2024 11:31:45 -0700 Subject: [PATCH 1/2] Increase InternCache default max size from 100 to 200 --- .../com/fasterxml/jackson/core/util/InternCache.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/fasterxml/jackson/core/util/InternCache.java b/src/main/java/com/fasterxml/jackson/core/util/InternCache.java index ef0bc6af60..454d07d2ae 100644 --- a/src/main/java/com/fasterxml/jackson/core/util/InternCache.java +++ b/src/main/java/com/fasterxml/jackson/core/util/InternCache.java @@ -20,8 +20,10 @@ public final class InternCache *

* One consideration is possible attack via colliding {@link String#hashCode}; * because of this, limit to reasonably low setting. + *

+ * Increased to 200 (from 100) in 2.18 */ - private final static int MAX_ENTRIES = 180; + private final static int DEFAULT_MAX_ENTRIES = 280; public final static InternCache instance = new InternCache(); @@ -32,7 +34,7 @@ public final class InternCache */ private final ReentrantLock lock = new ReentrantLock(); - public InternCache() { this(MAX_ENTRIES, 0.8f, 4); } + public InternCache() { this(DEFAULT_MAX_ENTRIES, 0.8f, 4); } public InternCache(int maxSize, float loadFactor, int concurrency) { super(maxSize, loadFactor, concurrency); @@ -47,7 +49,7 @@ public String intern(String input) { * possible limitation: just clear all contents. This because otherwise * we are simply likely to keep on clearing same, commonly used entries. */ - if (size() >= MAX_ENTRIES) { + if (size() >= DEFAULT_MAX_ENTRIES) { /* As of 2.18, the limit is not strictly enforced, but we do try to * clear entries if we have reached the limit. We do not expect to * go too much over the limit, and if we do, it's not a huge problem. @@ -56,7 +58,7 @@ public String intern(String input) { */ if (lock.tryLock()) { try { - if (size() >= MAX_ENTRIES) { + if (size() >= DEFAULT_MAX_ENTRIES) { clear(); } } finally { From baec580243172815dd9b8bdd25c43a753fee9b8b Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 28 Mar 2024 11:33:15 -0700 Subject: [PATCH 2/2] ... --- release-notes/VERSION-2.x | 1 + 1 file changed, 1 insertion(+) diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 02a7ec433f..f35ed1ad64 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -22,6 +22,7 @@ a pure JSON library. (contributed by @pjfanning) #1252: `ThreadLocalBufferManager` replace synchronized with `ReentrantLock` (contributed by @pjfanning) +#1257: Increase InternCache default max size from 100 to 200 2.17.1 (not yet released)