@@ -152,21 +152,44 @@ public void testClientSendOldStream() throws Exception {
152152
153153 @ Test
154154 public void testImplicitClose () throws Exception {
155+ doTestImplicitClose (5 );
156+ }
157+
158+
159+ // https://bz.apache.org/bugzilla/show_bug.cgi?id=64467
160+ @ Test
161+ public void testImplicitCloseLargeId () throws Exception {
162+ doTestImplicitClose (Integer .MAX_VALUE - 8 );
163+ }
164+
165+
166+ private void doTestImplicitClose (int lastStreamId ) throws Exception {
167+
168+ long startFirst = System .nanoTime ();
155169 http2Connect ();
170+ long durationFirst = System .nanoTime () - startFirst ;
156171
157172 sendPriority (3 , 0 , 16 );
158- sendPriority (5 , 0 , 16 );
173+ sendPriority (lastStreamId , 0 , 16 );
159174
160- sendSimpleGetRequest (5 );
175+ long startSecond = System .nanoTime ();
176+ sendSimpleGetRequest (lastStreamId );
161177 readSimpleGetResponse ();
162- Assert .assertEquals (getSimpleResponseTrace (5 ), output .getTrace ());
178+ long durationSecond = System .nanoTime () - startSecond ;
179+
180+ Assert .assertEquals (getSimpleResponseTrace (lastStreamId ), output .getTrace ());
163181 output .clearTrace ();
164182
183+ // Allow second request to take up to 5 times first request or up to 1 second - whichever is the larger - mainly
184+ // to allow for CI systems under load that can exhibit significant timing variation.
185+ Assert .assertTrue ("First request took [" + durationFirst /1000000 + "ms], second request took [" +
186+ durationSecond /1000000 + "ms]" , durationSecond < 1000000000 || durationSecond < durationFirst * 3 );
187+
165188 // Should trigger an error since stream 3 should have been implicitly
166189 // closed.
167190 sendSimpleGetRequest (3 );
168191
169- handleGoAwayResponse (5 );
192+ handleGoAwayResponse (lastStreamId );
170193 }
171194
172195
0 commit comments