Assign TokenBuffer field with createToken() result
This commit is contained in:
parent
6db20eb773
commit
d72c90cd7a
|
@ -37,7 +37,6 @@ import org.springframework.core.codec.DecodingException;
|
|||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DataBufferLimitException;
|
||||
import org.springframework.core.io.buffer.DataBufferUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* {@link Function} to transform a JSON stream of arbitrary size, byte array
|
||||
|
@ -67,7 +66,6 @@ final class Jackson2Tokenizer {
|
|||
|
||||
private int byteCount;
|
||||
|
||||
@Nullable // yet initialized by calling createToken() in the constructor
|
||||
private TokenBuffer tokenBuffer;
|
||||
|
||||
|
||||
|
@ -85,7 +83,7 @@ final class Jackson2Tokenizer {
|
|||
this.forceUseOfBigDecimal = forceUseOfBigDecimal;
|
||||
this.inputFeeder = (ByteArrayFeeder) this.parser.getNonBlockingInputFeeder();
|
||||
this.maxInMemorySize = maxInMemorySize;
|
||||
createToken();
|
||||
this.tokenBuffer = createToken();
|
||||
}
|
||||
|
||||
|
||||
|
@ -176,9 +174,8 @@ final class Jackson2Tokenizer {
|
|||
|
||||
if ((token.isStructEnd() || token.isScalarValue()) && this.objectDepth == 0 && this.arrayDepth == 0) {
|
||||
result.add(this.tokenBuffer);
|
||||
createToken();
|
||||
this.tokenBuffer = createToken();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void processTokenArray(JsonToken token, List<TokenBuffer> result) throws IOException {
|
||||
|
@ -189,13 +186,14 @@ final class Jackson2Tokenizer {
|
|||
if (this.objectDepth == 0 && (this.arrayDepth == 0 || this.arrayDepth == 1) &&
|
||||
(token == JsonToken.END_OBJECT || token.isScalarValue())) {
|
||||
result.add(this.tokenBuffer);
|
||||
createToken();
|
||||
this.tokenBuffer = createToken();
|
||||
}
|
||||
}
|
||||
|
||||
private void createToken() {
|
||||
this.tokenBuffer = new TokenBuffer(this.parser, this.deserializationContext);
|
||||
this.tokenBuffer.forceUseOfBigDecimal(this.forceUseOfBigDecimal);
|
||||
private TokenBuffer createToken() {
|
||||
TokenBuffer tokenBuffer = new TokenBuffer(this.parser, this.deserializationContext);
|
||||
tokenBuffer.forceUseOfBigDecimal(this.forceUseOfBigDecimal);
|
||||
return tokenBuffer;
|
||||
}
|
||||
|
||||
private boolean isTopLevelArrayToken(JsonToken token) {
|
||||
|
@ -233,8 +231,8 @@ final class Jackson2Tokenizer {
|
|||
* @param objectMapper the current mapper instance
|
||||
* @param tokenizeArrays if {@code true} and the "top level" JSON object is
|
||||
* an array, each element is returned individually immediately after it is received
|
||||
* @param forceUseOfBigDecimal if {@code true}, any floating point values encountered in source will use
|
||||
* {@link java.math.BigDecimal}
|
||||
* @param forceUseOfBigDecimal if {@code true}, any floating point values encountered
|
||||
* in source will use {@link java.math.BigDecimal}
|
||||
* @param maxInMemorySize maximum memory size
|
||||
* @return the resulting token buffers
|
||||
*/
|
||||
|
@ -248,8 +246,8 @@ final class Jackson2Tokenizer {
|
|||
context = ((DefaultDeserializationContext) context).createInstance(
|
||||
objectMapper.getDeserializationConfig(), parser, objectMapper.getInjectableValues());
|
||||
}
|
||||
Jackson2Tokenizer tokenizer = new Jackson2Tokenizer(parser, context, tokenizeArrays, forceUseOfBigDecimal,
|
||||
maxInMemorySize);
|
||||
Jackson2Tokenizer tokenizer =
|
||||
new Jackson2Tokenizer(parser, context, tokenizeArrays, forceUseOfBigDecimal, maxInMemorySize);
|
||||
return dataBuffers.concatMapIterable(tokenizer::tokenize).concatWith(tokenizer.endOfInput());
|
||||
}
|
||||
catch (IOException ex) {
|
||||
|
|
Loading…
Reference in New Issue