StringDecoder shouldn't chop off strings randomly

Issue: SPR-16337
This commit is contained in:
Arjen Poutsma
2018-02-01 11:57:44 +01:00
parent cfe7ff1c81
commit 609f173ebc
18 changed files with 338 additions and 128 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@ import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.web.reactive.function.client.WebClient;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;
/**
* @author Sebastien Deleuze
@@ -121,7 +121,7 @@ public class FlushingIntegrationTests extends AbstractHttpHandlerIntegrationTest
if (path.endsWith("write-and-flush")) {
Flux<Publisher<DataBuffer>> responseBody = Flux
.interval(Duration.ofMillis(50))
.map(l -> toDataBuffer("data" + l, response.bufferFactory()))
.map(l -> toDataBuffer("data" + l + "\n", response.bufferFactory()))
.take(2)
.map(Flux::just);
responseBody = responseBody.concatWith(Flux.never());
@@ -131,14 +131,14 @@ public class FlushingIntegrationTests extends AbstractHttpHandlerIntegrationTest
Flux<DataBuffer> responseBody = Flux
.just("0123456789")
.repeat(20000)
.map(value -> toDataBuffer(value, response.bufferFactory()));
.map(value -> toDataBuffer(value + "\n", response.bufferFactory()));
return response.writeWith(responseBody);
}
else if (path.endsWith("write-and-never-complete")) {
Flux<DataBuffer> responseBody = Flux
.just("0123456789")
.repeat(20000)
.map(value -> toDataBuffer(value, response.bufferFactory()))
.map(value -> toDataBuffer(value + "\n", response.bufferFactory()))
.mergeWith(Flux.never());
return response.writeWith(responseBody);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,12 +47,7 @@ import org.springframework.web.reactive.BindingContext;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.ServerWebInputException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assert.*;
import static org.springframework.core.ResolvableType.forClassWithGenerics;
import static org.springframework.http.MediaType.TEXT_PLAIN;
import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.post;
@@ -282,9 +277,9 @@ public class HttpEntityArgumentResolverTests {
assertEquals(exchange.getRequest().getHeaders(), httpEntity.getHeaders());
StepVerifier.create(httpEntity.getBody())
.expectNext("line1\n")
.expectNext("line2\n")
.expectNext("line3\n")
.expectNext("line1")
.expectNext("line2")
.expectNext("line3")
.expectComplete()
.verify();
}