Fix error handling in Jackson2JsonDecoder
Issue: SPR-15112
This commit is contained in:
@@ -118,7 +118,7 @@ public class Jackson2JsonDecoder extends AbstractJackson2Codec implements Decode
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
catch (IOException ex) {
|
catch (IOException ex) {
|
||||||
return Flux.error(new CodecException("Error while reading the data", ex));
|
throw new CodecException("Error while reading the data", ex);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import reactor.core.publisher.Mono;
|
|||||||
import reactor.test.StepVerifier;
|
import reactor.test.StepVerifier;
|
||||||
|
|
||||||
import org.springframework.core.ResolvableType;
|
import org.springframework.core.ResolvableType;
|
||||||
|
import org.springframework.core.codec.CodecException;
|
||||||
import org.springframework.core.io.buffer.AbstractDataBufferAllocatingTestCase;
|
import org.springframework.core.io.buffer.AbstractDataBufferAllocatingTestCase;
|
||||||
import org.springframework.core.io.buffer.DataBuffer;
|
import org.springframework.core.io.buffer.DataBuffer;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
@@ -67,6 +68,16 @@ public class Jackson2JsonDecoderTests extends AbstractDataBufferAllocatingTestCa
|
|||||||
.verify();
|
.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void decodePojoWithError() throws Exception {
|
||||||
|
Flux<DataBuffer> source = Flux.just(stringBuffer("{\"foo\":}"));
|
||||||
|
ResolvableType elementType = ResolvableType.forClass(Pojo.class);
|
||||||
|
Flux<Object> flux = new Jackson2JsonDecoder().decode(source, elementType, null,
|
||||||
|
Collections.emptyMap());
|
||||||
|
|
||||||
|
StepVerifier.create(flux).verifyError(CodecException.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void decodeToList() throws Exception {
|
public void decodeToList() throws Exception {
|
||||||
Flux<DataBuffer> source = Flux.just(stringBuffer(
|
Flux<DataBuffer> source = Flux.just(stringBuffer(
|
||||||
|
|||||||
Reference in New Issue
Block a user