Skip to content

Commit 2a4a6dc

Browse files
authored
Fix #1256: revert #1117, default recycler pool again threadLocalPool() (for 2.17.1+) (#1267)
1 parent 7e57e5b commit 2a4a6dc

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

release-notes/VERSION-2.x

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ a pure JSON library.
1818

1919
#1241: Fix `NumberInput.looksLikeValidNumber()` implementation
2020
(contributed by @pjfanning)
21+
#1256: Revert #1117: change default recycler pool back to `threadLocalPool()`
22+
for 2.17.1
2123

2224
2.17.0 (12-Mar-2024)
2325

src/main/java/com/fasterxml/jackson/core/util/JsonRecyclerPools.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ public final class JsonRecyclerPools
1919
{
2020
/**
2121
* Method to call to get the default recycler pool instance:
22-
* as of Jackson 2.17 this is same as calling
23-
* {@link #newLockFreePool()}; earlier
22+
* as of Jackson 2.17.x and earlier (except for 2.17.0) this is same as calling
23+
* {@link #threadLocalPool()} -- 2.17.0 temporarily had this call
24+
* {@link #newLockFreePool()} (but reverted due to problems reported).
25+
* Will likely be changed in 2.18.0 to something else.
2426
*
2527
* @return the default {@link RecyclerPool} implementation to use
2628
* if no specific implementation desired.
2729
*/
2830
public static RecyclerPool<BufferRecycler> defaultPool() {
29-
return newLockFreePool();
31+
return threadLocalPool();
3032
}
3133

3234
/**

src/test/java/perf/RecyclerPoolTest.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525
public class RecyclerPoolTest
2626
{
27-
final static int THREAD_COUNT = 100;
27+
final static int THREAD_COUNT = 200;
2828

2929
final static int RUNTIME_SECS = 60;
3030

@@ -100,7 +100,8 @@ void testUntil(JsonFactory jsonF,
100100
long endTimeMsecs, int threadId, AtomicLong calls)
101101
{
102102
final Random rnd = new Random(threadId);
103-
final byte[] JSON_INPUT = "\"abc\"".getBytes(StandardCharsets.UTF_8);
103+
final byte[] JSON_INPUT = "42 "
104+
.getBytes(StandardCharsets.UTF_8);
104105

105106
while (System.currentTimeMillis() < endTimeMsecs) {
106107
try {
@@ -144,7 +145,6 @@ private void _testWrite(JsonFactory jsonF) throws Exception
144145
StringWriter w = new StringWriter(16);
145146
JsonGenerator g = jsonF.createGenerator(w);
146147
g.writeStartArray();
147-
g.writeString("foobar");
148148
g.writeEndArray();
149149
g.close();
150150
}
@@ -154,15 +154,15 @@ public static void main(String[] args) throws Exception
154154
RecyclerPoolTest test = new RecyclerPoolTest(THREAD_COUNT);
155155
List<String> results = Arrays.asList(
156156
test.testPool(JsonFactory.builder()
157-
.recyclerPool(JsonRecyclerPools.newConcurrentDequePool())
157+
.recyclerPool(JsonRecyclerPools.newLockFreePool())
158158
.build(),
159-
RUNTIME_SECS),
159+
RUNTIME_SECS * 1000),
160160
test.testPool(JsonFactory.builder()
161-
.recyclerPool(JsonRecyclerPools.newBoundedPool(THREAD_COUNT - 5))
161+
.recyclerPool(JsonRecyclerPools.newConcurrentDequePool())
162162
.build(),
163163
RUNTIME_SECS),
164164
test.testPool(JsonFactory.builder()
165-
.recyclerPool(JsonRecyclerPools.newLockFreePool())
165+
.recyclerPool(JsonRecyclerPools.newBoundedPool(THREAD_COUNT - 5))
166166
.build(),
167167
RUNTIME_SECS)
168168
);

0 commit comments

Comments
 (0)