@@ -214,12 +214,15 @@ public AssertionError check(Tracker tracker,
214214 long waitStart = System .nanoTime ();
215215 long waited = 0 ;
216216 long toWait = Math .min (graceDelayMs , Math .max (delay , 1 ));
217- for (int i = 0 ; i < count ; i ++) {
217+ int i = 0 ;
218+ for (i = 0 ; i < count ; i ++) {
218219 if (hasOutstanding .test (tracker )) {
219220 System .gc ();
220221 try {
221222 if (i == 0 ) {
222223 System .out .println ("Waiting for HTTP operations to terminate..." );
224+ System .out .println ("\t gracedelay: " + graceDelayMs
225+ + " ms, iterations: " + count + ", wait/iteration: " + toWait + "ms" );
223226 }
224227 waited += toWait ;
225228 Thread .sleep (toWait );
@@ -250,7 +253,8 @@ public AssertionError check(Tracker tracker,
250253 printThreads (msg , System .err );
251254 }
252255 System .out .println ("AssertionError: Found some " + description + " in "
253- + tracker .getName () + " after " + duration + " ms, waited " + waited + " ms" );
256+ + tracker .getName () + " after " + i + " iterations and " + duration
257+ + " ms, waited " + waited + " ms" );
254258 }
255259 return fail ;
256260 }
@@ -261,21 +265,34 @@ public AssertionError check(long graceDelayMs,
261265 boolean printThreads ) {
262266 AssertionError fail = null ;
263267 graceDelayMs = Math .max (graceDelayMs , 100 );
268+ long waitStart = System .nanoTime ();
264269 long delay = Math .min (graceDelayMs , 10 );
270+ long toWait = Math .min (graceDelayMs , Math .max (delay , 1 ));
271+ long waited = 0 ;
265272 var count = delay > 0 ? graceDelayMs / delay : 1 ;
266- for (int i = 0 ; i < count ; i ++) {
273+ int i = 0 ;
274+ for (i = 0 ; i < count ; i ++) {
267275 if (TRACKERS .stream ().anyMatch (hasOutstanding )) {
268276 System .gc ();
269277 try {
270278 if (i == 0 ) {
271279 System .out .println ("Waiting for HTTP operations to terminate..." );
280+ System .out .println ("\t gracedelay: " + graceDelayMs
281+ + " ms, iterations: " + count + ", wait/iteration: " + toWait + "ms" );
272282 }
273- Thread .sleep (Math .min (graceDelayMs , Math .max (delay , 1 )));
283+ waited += toWait ;
284+ Thread .sleep (toWait );
274285 } catch (InterruptedException x ) {
275286 // OK
276287 }
277- } else break ;
288+ } else {
289+ System .out .println ("No outstanding HTTP operations remaining after "
290+ + i + "/" + count + " iterations and " + waited + "/" + graceDelayMs
291+ + " ms, (wait/iteration " + toWait + " ms)" );
292+ break ;
293+ }
278294 }
295+ long duration = Duration .ofNanos (System .nanoTime () - waitStart ).toMillis ();
279296 if (TRACKERS .stream ().anyMatch (hasOutstanding )) {
280297 StringBuilder warnings = diagnose (new StringBuilder (), hasOutstanding );
281298 addSummary (warnings );
@@ -284,14 +301,17 @@ public AssertionError check(long graceDelayMs,
284301 }
285302 } else {
286303 System .out .println ("PASSED: No " + description + " found in "
287- + getTrackedClientCount () + " clients" );
304+ + getTrackedClientCount () + " clients in " + duration + " ms " );
288305 }
289306 if (fail != null ) {
290307 Predicate <Tracker > isAlive = Tracker ::isSelectorAlive ;
291308 if (printThreads && TRACKERS .stream ().anyMatch (isAlive )) {
292309 printThreads ("Some selector manager threads are still alive: " , System .out );
293310 printThreads ("Some selector manager threads are still alive: " , System .err );
294311 }
312+ System .out .println ("AssertionError: Found some " + description + " in "
313+ + getTrackedClientCount () + " clients after " + i + " iterations and " + duration
314+ + " ms, waited " + waited + " ms" );
295315 }
296316 return fail ;
297317 }
0 commit comments