diff --git a/spring-web-reactive/src/main/java/org/springframework/core/codec/support/StringDecoder.java b/spring-web-reactive/src/main/java/org/springframework/core/codec/support/StringDecoder.java index a72e4249fb0..56ac1d9f46d 100644 --- a/spring-web-reactive/src/main/java/org/springframework/core/codec/support/StringDecoder.java +++ b/spring-web-reactive/src/main/java/org/springframework/core/codec/support/StringDecoder.java @@ -45,7 +45,6 @@ import org.springframework.util.MimeType; public class StringDecoder extends AbstractDecoder { public static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; - public static final String EMPTY = ""; private final boolean reduceToSingleBuffer; @@ -85,11 +84,6 @@ public class StringDecoder extends AbstractDecoder { } Charset charset = getCharset(mimeType); return inputFlux.map(content -> { - // fast-path exit. - if(content.readableByteCount() == 0) { - return EMPTY; - } - CharBuffer charBuffer = charset.decode(content.asByteBuffer()); return charBuffer.toString(); }); diff --git a/spring-web-reactive/src/test/java/org/springframework/core/codec/support/StringDecoderTests.java b/spring-web-reactive/src/test/java/org/springframework/core/codec/support/StringDecoderTests.java index 4195dc40525..0901d5bca05 100644 --- a/spring-web-reactive/src/test/java/org/springframework/core/codec/support/StringDecoderTests.java +++ b/spring-web-reactive/src/test/java/org/springframework/core/codec/support/StringDecoderTests.java @@ -95,12 +95,11 @@ public class StringDecoderTests extends AbstractAllocatingTestCase { @Test public void decodeEmpty() throws InterruptedException { - Flux source = Flux.just(stringBuffer("")); - Single single = RxJava1SingleConverter.from(this.decoder.decode(source, - ResolvableType.forClassWithGenerics(Single.class, String.class), - MediaType.TEXT_PLAIN)); - String result = single.toBlocking().value(); - assertEquals("", result); + Mono source = Mono.just(stringBuffer("")); + Flux output = + this.decoder.decode(source, ResolvableType.forClass(String.class), null); + TestSubscriber testSubscriber = new TestSubscriber<>(); + testSubscriber.bindTo(output).assertValues(""); } }