@@ -147,21 +147,44 @@ public void testClientSendOldStream() throws Exception {
147147
148148 @ Test
149149 public void testImplicitClose () throws Exception {
150+ doTestImplicitClose (5 );
151+ }
152+
153+
154+ // https://bz.apache.org/bugzilla/show_bug.cgi?id=64467
155+ @ Test
156+ public void testImplicitCloseLargeId () throws Exception {
157+ doTestImplicitClose (Integer .MAX_VALUE - 8 );
158+ }
159+
160+
161+ private void doTestImplicitClose (int lastStreamId ) throws Exception {
162+
163+ long startFirst = System .nanoTime ();
150164 http2Connect ();
165+ long durationFirst = System .nanoTime () - startFirst ;
151166
152167 sendPriority (3 , 0 , 16 );
153- sendPriority (5 , 0 , 16 );
168+ sendPriority (lastStreamId , 0 , 16 );
154169
155- sendSimpleGetRequest (5 );
170+ long startSecond = System .nanoTime ();
171+ sendSimpleGetRequest (lastStreamId );
156172 readSimpleGetResponse ();
157- Assert .assertEquals (getSimpleResponseTrace (5 ), output .getTrace ());
173+ long durationSecond = System .nanoTime () - startSecond ;
174+
175+ Assert .assertEquals (getSimpleResponseTrace (lastStreamId ), output .getTrace ());
158176 output .clearTrace ();
159177
178+ // Allow second request to take up to 5 times first request or up to 1 second - whichever is the larger - mainly
179+ // to allow for CI systems under load that can exhibit significant timing variation.
180+ Assert .assertTrue ("First request took [" + durationFirst /1000000 + "ms], second request took [" +
181+ durationSecond /1000000 + "ms]" , durationSecond < 1000000000 || durationSecond < durationFirst * 3 );
182+
160183 // Should trigger an error since stream 3 should have been implicitly
161184 // closed.
162185 sendSimpleGetRequest (3 );
163186
164- handleGoAwayResponse (5 );
187+ handleGoAwayResponse (lastStreamId );
165188 }
166189
167190
0 commit comments