Skip to content

Commit 42cbf20

Browse files
committed
SSL (for jooby-http2-netty) broken for reactor Flux
Fix #2372
1 parent 125fcc8 commit 42cbf20

File tree

3 files changed

+51
-3
lines changed

3 files changed

+51
-3
lines changed

modules/jooby-netty/src/main/java/io/jooby/internal/netty/NettyContext.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
import io.netty.buffer.Unpooled;
7474
import io.netty.channel.ChannelFuture;
7575
import io.netty.channel.ChannelFutureListener;
76+
import io.netty.channel.ChannelHandler;
7677
import io.netty.channel.ChannelHandlerContext;
7778
import io.netty.channel.ChannelPipeline;
7879
import io.netty.channel.ChannelPromise;
@@ -801,7 +802,7 @@ private void prepareChunked() {
801802
// remove flusher, doesn't play well with streaming/chunked responses
802803
ChannelPipeline pipeline = ctx.pipeline();
803804
if (pipeline.get("chunker") == null) {
804-
String base = Stream.of("compressor", "codec")
805+
String base = Stream.of("compressor", "codec", "http2")
805806
.filter(name -> pipeline.get(name) != null)
806807
.findFirst()
807808
.orElseThrow(() -> new IllegalStateException("No available handler for chunk writer"));

tests/src/test/java/io/jooby/FeaturedTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import static org.junit.jupiter.api.Assertions.assertNull;
1313
import static org.junit.jupiter.api.Assertions.assertTrue;
1414
import static reactor.core.scheduler.Schedulers.elastic;
15+
import static reactor.core.scheduler.Schedulers.parallel;
1516

1617
import java.io.ByteArrayInputStream;
1718
import java.io.IOException;
@@ -1060,12 +1061,12 @@ public void reactor(ServerTestRunner runner) {
10601061
app.get("/reactor/mono", ctx ->
10611062
Mono.fromCallable(() -> "Mono")
10621063
.map(s -> "Hello " + s)
1063-
.subscribeOn(elastic())
1064+
.subscribeOn(parallel())
10641065
);
10651066
app.get("/reactor/flux", ctx ->
10661067
Flux.range(1, 10)
10671068
.map(i -> i + ",")
1068-
.subscribeOn(elastic())
1069+
.subscribeOn(parallel())
10691070
);
10701071
}).ready(client -> {
10711072
client.get("/reactor/mono", rsp -> {
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package io.jooby;
2+
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
5+
import java.util.Arrays;
6+
7+
import io.jooby.junit.ServerTest;
8+
import io.jooby.junit.ServerTestRunner;
9+
import reactor.core.publisher.Flux;
10+
import reactor.core.publisher.Mono;
11+
12+
public class Issue2372 {
13+
14+
@ServerTest
15+
public void http2(ServerTestRunner runner) {
16+
runner.define(app -> {
17+
18+
app.setServerOptions(
19+
new ServerOptions()
20+
.setHttp2(true)
21+
.setSecurePort(8443)
22+
);
23+
24+
app.before(new SSLHandler());
25+
26+
app.get("/2372/mono", ctx -> {
27+
return Mono.fromCallable(() -> "Welcome to Jooby!");
28+
});
29+
30+
app.get("/2372/flux", ctx -> {
31+
return Flux.fromIterable(Arrays.asList("Welcome", "to", "Jooby!"))
32+
.map(it -> it + " ");
33+
});
34+
}).ready((http, https) -> {
35+
https.get("/2372/flux", rsp -> {
36+
assertEquals("Welcome to Jooby!",
37+
rsp.body().string().trim());
38+
});
39+
https.get("/2372/mono", rsp -> {
40+
assertEquals("Welcome to Jooby!",
41+
rsp.body().string());
42+
});
43+
});
44+
}
45+
46+
}

0 commit comments

Comments
 (0)