Skip to content

Commit

Permalink
Fix #1269: allow lazy creation of RecyclerPool default instance
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Apr 20, 2024
1 parent 7f1604c commit 324576d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ JSON library.
#1231: Enable Fast Floating-Point reading/writing by default in 3.0
#1233: Lower default `maxNestingDepth` of `StreamReadConstraints` /
`StreamWriteConstraints` to 500 in 3.0
#1269: Change `JsonFactory.builder()` configuration of `RecyclerPool` to avoid
allocation default implementation (in 3.0)
- Rename `JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT` as `AUTO_CLOSE_CONTENT`
- Add `TreeCodec.nullNode()`, `TreeNode.isNull()` methods
- Change the way `JsonLocation.NA` is included in exception messages
5 changes: 2 additions & 3 deletions src/main/java/tools/jackson/core/TSFBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.util.Objects;

import tools.jackson.core.util.BufferRecycler;
import tools.jackson.core.util.JsonRecyclerPools;
import tools.jackson.core.util.RecyclerPool;

/**
Expand Down Expand Up @@ -64,7 +63,7 @@ public abstract class TSFBuilder<F extends TokenStreamFactory,
protected TSFBuilder(StreamReadConstraints src, StreamWriteConstraints swc,
ErrorReportConfiguration erc,
int formatReadF, int formatWriteF) {
this(JsonRecyclerPools.defaultPool(),
this(null,
src, swc, erc,
TokenStreamFactory.DEFAULT_FACTORY_FEATURE_FLAGS,
TokenStreamFactory.DEFAULT_STREAM_READ_FEATURE_FLAGS,
Expand All @@ -89,7 +88,7 @@ protected TSFBuilder(RecyclerPool<BufferRecycler> brp,
int streamReadFeatures, int streamWriteFeatures,
int formatReadFeatures, int formatWriteFeatures)
{
_recyclerPool = Objects.requireNonNull(brp);
_recyclerPool = brp;
_streamReadConstraints = Objects.requireNonNull(src);
_streamWriteConstraints = Objects.requireNonNull(swc);
_errorReportConfiguration = Objects.requireNonNull(erc);
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/tools/jackson/core/TokenStreamFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,14 @@ protected TokenStreamFactory(TSFBuilder<?,?> baseBuilder)
_streamReadConstraints = Objects.requireNonNull(baseBuilder._streamReadConstraints);
_streamWriteConstraints = Objects.requireNonNull(baseBuilder._streamWriteConstraints);
_errorReportConfiguration = Objects.requireNonNull(baseBuilder._errorReportConfiguration);
_recyclerPool = Objects.requireNonNull(baseBuilder._recyclerPool);

// 19-Apr-2024, tatu: [core#1269] allow `null` to indicate "just use
// default to lazily instantiate
RecyclerPool<BufferRecycler> rp = baseBuilder._recyclerPool;
if (rp == null) {
rp = JsonRecyclerPools.defaultPool();
}
_recyclerPool = rp;

_factoryFeatures = baseBuilder.factoryFeaturesMask();
_streamReadFeatures = baseBuilder.streamReadFeaturesMask();
Expand Down
1 change: 0 additions & 1 deletion src/main/java/tools/jackson/core/json/JsonFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public class JsonFactory
/**********************************************************************
*/


/**
* Name used to identify JSON format
* (and returned by {@link #getFormatName()}
Expand Down

0 comments on commit 324576d

Please sign in to comment.