3737import org .springframework .core .io .buffer .DataBuffer ;
3838import org .springframework .core .io .buffer .DataBufferLimitException ;
3939import org .springframework .core .io .buffer .DataBufferUtils ;
40- import org .springframework .lang .Nullable ;
4140
4241/**
4342 * {@link Function} to transform a JSON stream of arbitrary size, byte array
@@ -67,7 +66,6 @@ final class Jackson2Tokenizer {
6766
6867private int byteCount ;
6968
70- @ Nullable // yet initialized by calling createToken() in the constructor
7169private TokenBuffer tokenBuffer ;
7270
7371
@@ -85,7 +83,7 @@ private Jackson2Tokenizer(JsonParser parser, DeserializationContext deserializat
8583this .forceUseOfBigDecimal = forceUseOfBigDecimal ;
8684this .inputFeeder = (ByteArrayFeeder ) this .parser .getNonBlockingInputFeeder ();
8785this .maxInMemorySize = maxInMemorySize ;
88- createToken ();
86+ this . tokenBuffer = createToken ();
8987}
9088
9189
@@ -176,9 +174,8 @@ private void processTokenNormal(JsonToken token, List<TokenBuffer> result) throw
176174
177175if ((token .isStructEnd () || token .isScalarValue ()) && this .objectDepth == 0 && this .arrayDepth == 0 ) {
178176result .add (this .tokenBuffer );
179- createToken ();
177+ this . tokenBuffer = createToken ();
180178}
181-
182179}
183180
184181private void processTokenArray (JsonToken token , List <TokenBuffer > result ) throws IOException {
@@ -189,13 +186,14 @@ private void processTokenArray(JsonToken token, List<TokenBuffer> result) throws
189186if (this .objectDepth == 0 && (this .arrayDepth == 0 || this .arrayDepth == 1 ) &&
190187(token == JsonToken .END_OBJECT || token .isScalarValue ())) {
191188result .add (this .tokenBuffer );
192- createToken ();
189+ this . tokenBuffer = createToken ();
193190}
194191}
195192
196- private void createToken () {
197- this .tokenBuffer = new TokenBuffer (this .parser , this .deserializationContext );
198- this .tokenBuffer .forceUseOfBigDecimal (this .forceUseOfBigDecimal );
193+ private TokenBuffer createToken () {
194+ TokenBuffer tokenBuffer = new TokenBuffer (this .parser , this .deserializationContext );
195+ tokenBuffer .forceUseOfBigDecimal (this .forceUseOfBigDecimal );
196+ return tokenBuffer ;
199197}
200198
201199private boolean isTopLevelArrayToken (JsonToken token ) {
@@ -233,8 +231,8 @@ private void raiseLimitException() {
233231 * @param objectMapper the current mapper instance
234232 * @param tokenizeArrays if {@code true} and the "top level" JSON object is
235233 * an array, each element is returned individually immediately after it is received
236- * @param forceUseOfBigDecimal if {@code true}, any floating point values encountered in source will use
237- * {@link java.math.BigDecimal}
234+ * @param forceUseOfBigDecimal if {@code true}, any floating point values encountered
235+ * in source will use {@link java.math.BigDecimal}
238236 * @param maxInMemorySize maximum memory size
239237 * @return the resulting token buffers
240238 */
@@ -248,8 +246,8 @@ public static Flux<TokenBuffer> tokenize(Flux<DataBuffer> dataBuffers, JsonFacto
248246context = ((DefaultDeserializationContext ) context ).createInstance (
249247objectMapper .getDeserializationConfig (), parser , objectMapper .getInjectableValues ());
250248}
251- Jackson2Tokenizer tokenizer = new Jackson2Tokenizer ( parser , context , tokenizeArrays , forceUseOfBigDecimal ,
252- maxInMemorySize );
249+ Jackson2Tokenizer tokenizer =
250+ new Jackson2Tokenizer ( parser , context , tokenizeArrays , forceUseOfBigDecimal , maxInMemorySize );
253251return dataBuffers .concatMapIterable (tokenizer ::tokenize ).concatWith (tokenizer .endOfInput ());
254252}
255253catch (IOException ex ) {
0 commit comments