Skip to content

Commit 114df91

Browse files
committed
Test case for race condition in WriteBarrier
This is just a quick-and-dirty test case scrapped together from ControllerInputIntegrationTests.
1 parent c37f685 commit 114df91

File tree

2 files changed

+48
-3
lines changed

2 files changed

+48
-3
lines changed

spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/bootstrap/AbstractHttpHandlerIntegrationTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ public static Flux<Long> testInterval(Duration period, int count) {
125125

126126
static Stream<Named<HttpServer>> httpServers() {
127127
return Stream.of(
128-
named("Jetty", new JettyHttpServer()),
129-
named("Reactor Netty", new ReactorHttpServer()),
130-
named("Tomcat", new TomcatHttpServer()),
128+
// named("Jetty", new JettyHttpServer()),
129+
// named("Reactor Netty", new ReactorHttpServer()),
130+
// named("Tomcat", new TomcatHttpServer()),
131131
named("Undertow", new UndertowHttpServer())
132132
);
133133
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package org.springframework.web.reactive.result.method.annotation;
2+
3+
import org.reactivestreams.Publisher;
4+
import org.springframework.context.ApplicationContext;
5+
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
6+
import org.springframework.http.HttpHeaders;
7+
import org.springframework.web.bind.annotation.GetMapping;
8+
import org.springframework.web.bind.annotation.RestController;
9+
import org.springframework.web.reactive.config.EnableWebFlux;
10+
import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer;
11+
import reactor.core.publisher.Flux;
12+
import reactor.core.scheduler.Schedulers;
13+
14+
import static org.assertj.core.api.Assertions.assertThat;
15+
16+
class ChannelSendOperatorRaceConditionIntegrationTest extends AbstractRequestMappingIntegrationTests {
17+
18+
@Override
19+
protected ApplicationContext initApplicationContext() {
20+
return new AnnotationConfigApplicationContext(WebConfig.class, TestRestController.class);
21+
}
22+
23+
24+
@ParameterizedHttpServerTest
25+
void handlePublishOn(HttpServer httpServer) throws Exception {
26+
startServer(httpServer);
27+
28+
String expected = "Hello world!";
29+
assertThat(performGet("/test", new HttpHeaders(), String.class).getBody()).isEqualTo(expected);
30+
}
31+
32+
@EnableWebFlux
33+
static class WebConfig {
34+
}
35+
@RestController
36+
@SuppressWarnings("unused")
37+
private static class TestRestController {
38+
39+
@GetMapping("/test")
40+
public Publisher<String> handlerWithPublishOn() {
41+
return Flux.just("Hello ", "world", "!")
42+
.publishOn(Schedulers.boundedElastic());
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)