From 59b7c25003f0fe61163d074d50be558bde6b698b Mon Sep 17 00:00:00 2001 From: Sebastien Deleuze Date: Tue, 21 Jun 2016 16:46:24 +0200 Subject: [PATCH] Use ResolvableType instead of raw Class in JacksonJsonDecoder --- .../core/codec/support/JacksonJsonDecoder.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/spring-web-reactive/src/main/java/org/springframework/core/codec/support/JacksonJsonDecoder.java b/spring-web-reactive/src/main/java/org/springframework/core/codec/support/JacksonJsonDecoder.java index ccf8f5be3b6..93815729db6 100644 --- a/spring-web-reactive/src/main/java/org/springframework/core/codec/support/JacksonJsonDecoder.java +++ b/spring-web-reactive/src/main/java/org/springframework/core/codec/support/JacksonJsonDecoder.java @@ -19,8 +19,10 @@ package org.springframework.core.codec.support; import java.io.IOException; import java.nio.charset.StandardCharsets; +import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectReader; +import com.fasterxml.jackson.databind.type.TypeFactory; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; @@ -29,6 +31,7 @@ import org.springframework.core.codec.CodecException; import org.springframework.core.codec.Decoder; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.support.DataBufferUtils; +import org.springframework.util.Assert; import org.springframework.util.MimeType; @@ -64,7 +67,11 @@ public class JacksonJsonDecoder extends AbstractDecoder { public Flux decode(Publisher inputStream, ResolvableType elementType, MimeType mimeType, Object... hints) { - ObjectReader reader = this.mapper.readerFor(elementType.getRawClass()); + Assert.notNull(inputStream, "'inputStream' must not be null"); + Assert.notNull(elementType, "'elementType' must not be null"); + TypeFactory typeFactory = this.mapper.getTypeFactory(); + JavaType javaType = typeFactory.constructType(elementType.getType()); + ObjectReader reader = this.mapper.readerFor(javaType); Flux stream = Flux.from(inputStream); if (this.preProcessor != null) {