Skip to content

Commit

Permalink
Remove explicit disabling of buffer recycling in Jackson codec
Browse files Browse the repository at this point in the history
Since now FasterXML/jackson-core#476
and FasterXML/jackson-core#479 are fixed.

This commit also raises the minimum version of Jackson to 2.9.7.

Closes spring-projectsgh-23522
  • Loading branch information
sdeleuze committed Aug 28, 2019
1 parent c004ef8 commit f65cc9a
Showing 1 changed file with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down Expand Up @@ -50,6 +49,8 @@
/**
* Abstract base class for Jackson 2.9 decoding, leveraging non-blocking parsing.
*
* <p>Compatible with Jackson 2.9.7 and higher.
*
* @author Sebastien Deleuze
* @author Rossen Stoyanchev
* @author Arjen Poutsma
Expand All @@ -58,20 +59,11 @@
*/
public abstract class AbstractJackson2Decoder extends Jackson2CodecSupport implements HttpMessageDecoder<Object> {

/**
* Until https://github.com/FasterXML/jackson-core/issues/476 is resolved,
* we need to ensure buffer recycling is off.
*/
private final JsonFactory jsonFactory;


/**
* Constructor with a Jackson {@link ObjectMapper} to use.
*/
protected AbstractJackson2Decoder(ObjectMapper mapper, MimeType... mimeTypes) {
super(mapper, mimeTypes);
this.jsonFactory = mapper.getFactory().copy()
.disable(JsonFactory.Feature.USE_THREAD_LOCAL_FOR_BUFFER_RECYCLING);
}


Expand All @@ -87,8 +79,9 @@ public boolean canDecode(ResolvableType elementType, @Nullable MimeType mimeType
public Flux<Object> decode(Publisher<DataBuffer> input, ResolvableType elementType,
@Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {

ObjectMapper mapper = getObjectMapper();
Flux<TokenBuffer> tokens = Jackson2Tokenizer.tokenize(
Flux.from(input), this.jsonFactory, getObjectMapper(), true);
Flux.from(input), mapper.getFactory(), mapper, true);

ObjectReader reader = getObjectReader(elementType, hints);

Expand Down

0 comments on commit f65cc9a

Please sign in to comment.