3131import org .junit .jupiter .api .Test ;
3232import reactor .core .publisher .Mono ;
3333import reactor .netty .BaseHttpTest ;
34- import reactor .netty .DisposableServer ;
3534import reactor .netty .NettyPipeline ;
3635import reactor .netty .resources .ConnectionProvider ;
3736
5655 */
5756class Http2ConnectionLivenessHandlerTest extends BaseHttpTest {
5857
59- static SelfSignedCertificate ssc ;
6058 static SslContext sslServer ;
6159 static SslContext sslClient ;
6260
6361 @ BeforeAll
6462 static void createSelfSignedCertificate () throws CertificateException , SSLException {
65- ssc = new SelfSignedCertificate ();
63+ SelfSignedCertificate ssc = new SelfSignedCertificate ();
6664 sslServer = SslContextBuilder .forServer (ssc .certificate (), ssc .privateKey ())
6765 .build ();
6866 sslClient = SslContextBuilder .forClient ()
@@ -72,7 +70,7 @@ static void createSelfSignedCertificate() throws CertificateException, SSLExcept
7270
7371 @ Test
7472 void successReceiveResponse () {
75- DisposableServer disposableServer = createServer ()
73+ disposableServer = createServer ()
7674 .protocol (H2 )
7775 .secure (spec -> spec .sslContext (sslServer ))
7876 .handle ((req , resp ) -> resp .sendString (Mono .just ("Test" )))
@@ -93,7 +91,7 @@ void successReceiveResponse() {
9391 void noPingCheckWhenNotConfigured () {
9492 Http2PingFrameHandler handler = new Http2PingFrameHandler ();
9593
96- DisposableServer disposableServer = createServer ()
94+ disposableServer = createServer ()
9795 .protocol (H2 )
9896 .maxKeepAliveRequests (1 )
9997 .secure (spec -> spec .sslContext (sslServer ))
@@ -119,7 +117,7 @@ void noPingCheckWhenNotConfigured() {
119117 .single ()
120118 .block ();
121119
122- Mono .delay (Duration .ofMillis ( 100 ))
120+ Mono .delay (Duration .ofSeconds ( 1 ))
123121 .block ();
124122
125123 assertThat (handler .getReceivedPingTimes ()).isEmpty ();
@@ -137,7 +135,7 @@ void closeConnectionIfPingFrameDelayed() {
137135 .subscribe ()
138136 );
139137
140- DisposableServer disposableServer = createServer ()
138+ disposableServer = createServer ()
141139 .protocol (H2 )
142140 .maxKeepAliveRequests (1 )
143141 .secure (spec -> spec .sslContext (sslServer ))
@@ -166,7 +164,7 @@ void closeConnectionIfPingFrameDelayed() {
166164 .single ()
167165 .block ();
168166
169- Mono .delay (Duration .ofMillis ( 600 ))
167+ Mono .delay (Duration .ofSeconds ( 2 ))
170168 .block ();
171169
172170 assertThat (handler .getReceivedPingTimes ()).hasSize (1 );
@@ -184,7 +182,7 @@ void closeConnectionInPoolIfPingFrameDelayed() {
184182 .subscribe ()
185183 );
186184
187- DisposableServer disposableServer = createServer ()
185+ disposableServer = createServer ()
188186 .protocol (H2 )
189187 .maxKeepAliveRequests (1 )
190188 .secure (spec -> spec .sslContext (sslServer ))
@@ -214,7 +212,7 @@ void closeConnectionInPoolIfPingFrameDelayed() {
214212 .single ()
215213 .block ();
216214
217- Mono .delay (Duration .ofMillis ( 600 ))
215+ Mono .delay (Duration .ofSeconds ( 2 ))
218216 .block ();
219217
220218 assertThat (handler .getReceivedPingTimes ()).hasSize (1 );
@@ -225,7 +223,7 @@ void closeConnectionInPoolIfPingFrameDelayed() {
225223 void ackPingFrameWithinInterval () {
226224 Http2PingFrameHandler handler = new Http2PingFrameHandler ();
227225
228- DisposableServer disposableServer = createServer ()
226+ disposableServer = createServer ()
229227 .protocol (H2 )
230228 .maxKeepAliveRequests (1 )
231229 .secure (spec -> spec .sslContext (sslServer ))
@@ -246,15 +244,15 @@ void ackPingFrameWithinInterval() {
246244 .keepAlive (true )
247245 .secure (spec -> spec .sslContext (sslClient ))
248246 .http2Settings (builder -> {
249- builder .pingInterval (Duration .ofMillis ( 100 ));
247+ builder .pingInterval (Duration .ofSeconds ( 1 ));
250248 })
251249 .get ()
252250 .uri ("/" )
253251 .responseConnection ((conn , receiver ) -> Mono .just (receiver .channel ()))
254252 .single ()
255253 .block ();
256254
257- Mono .delay (Duration .ofSeconds (1 ))
255+ Mono .delay (Duration .ofSeconds (10 ))
258256 .block ();
259257
260258 assertThat (handler .getReceivedPingTimes ()).hasSizeGreaterThanOrEqualTo (2 );
@@ -265,7 +263,7 @@ void ackPingFrameWithinInterval() {
265263 void connectionRetentionInPoolOnPingFrameAck () {
266264 Http2PingFrameHandler handler = new Http2PingFrameHandler ();
267265
268- DisposableServer disposableServer = createServer ()
266+ disposableServer = createServer ()
269267 .protocol (H2 )
270268 .maxKeepAliveRequests (1 )
271269 .secure (spec -> spec .sslContext (sslServer ))
@@ -287,15 +285,15 @@ void connectionRetentionInPoolOnPingFrameAck() {
287285 .keepAlive (true )
288286 .secure (spec -> spec .sslContext (sslClient ))
289287 .http2Settings (builder -> {
290- builder .pingInterval (Duration .ofMillis ( 100 ));
288+ builder .pingInterval (Duration .ofSeconds ( 1 ));
291289 })
292290 .get ()
293291 .uri ("/" )
294292 .responseConnection ((conn , receiver ) -> Mono .just (receiver .channel ()))
295293 .single ()
296294 .block ();
297295
298- Mono .delay (Duration .ofSeconds (1 ))
296+ Mono .delay (Duration .ofSeconds (10 ))
299297 .block ();
300298
301299 assertThat (handler .getReceivedPingTimes ()).hasSizeGreaterThanOrEqualTo (2 );
@@ -322,6 +320,7 @@ private Http2PingFrameHandler(BiConsumer<ChannelHandlerContext, Http2PingFrame>
322320 protected void channelRead0 (ChannelHandlerContext ctx , Http2PingFrame frame ) throws InterruptedException {
323321 receivedPingTimes .add (LocalDateTime .now (ZoneId .systemDefault ()));
324322 consumer .accept (ctx , frame );
323+ ctx .fireChannelRead (frame );
325324 }
326325
327326 public List <LocalDateTime > getReceivedPingTimes () {
0 commit comments