Implement review feedback.
Remove empty string optimization. Simplify test to use only Mono/Flux/TestSubscriber instead of mixing with RxJava.
This commit is contained in:
parent
c4b9d94c33
commit
9e79b344ca
|
|
@ -45,7 +45,6 @@ import org.springframework.util.MimeType;
|
|||
public class StringDecoder extends AbstractDecoder<String> {
|
||||
|
||||
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<String> {
|
|||
}
|
||||
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();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -95,12 +95,11 @@ public class StringDecoderTests extends AbstractAllocatingTestCase {
|
|||
|
||||
@Test
|
||||
public void decodeEmpty() throws InterruptedException {
|
||||
Flux<DataBuffer> source = Flux.just(stringBuffer(""));
|
||||
Single<String> single = RxJava1SingleConverter.from(this.decoder.decode(source,
|
||||
ResolvableType.forClassWithGenerics(Single.class, String.class),
|
||||
MediaType.TEXT_PLAIN));
|
||||
String result = single.toBlocking().value();
|
||||
assertEquals("", result);
|
||||
Mono<DataBuffer> source = Mono.just(stringBuffer(""));
|
||||
Flux<String> output =
|
||||
this.decoder.decode(source, ResolvableType.forClass(String.class), null);
|
||||
TestSubscriber<String> testSubscriber = new TestSubscriber<>();
|
||||
testSubscriber.bindTo(output).assertValues("");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue