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