@@ -214,12 +214,15 @@ public AssertionError check(Tracker tracker,
214
214
long waitStart = System .nanoTime ();
215
215
long waited = 0 ;
216
216
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 ++) {
218
219
if (hasOutstanding .test (tracker )) {
219
220
System .gc ();
220
221
try {
221
222
if (i == 0 ) {
222
223
System .out .println ("Waiting for HTTP operations to terminate..." );
224
+ System .out .println ("\t gracedelay: " + graceDelayMs
225
+ + " ms, iterations: " + count + ", wait/iteration: " + toWait + "ms" );
223
226
}
224
227
waited += toWait ;
225
228
Thread .sleep (toWait );
@@ -250,7 +253,8 @@ public AssertionError check(Tracker tracker,
250
253
printThreads (msg , System .err );
251
254
}
252
255
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" );
254
258
}
255
259
return fail ;
256
260
}
@@ -261,21 +265,34 @@ public AssertionError check(long graceDelayMs,
261
265
boolean printThreads ) {
262
266
AssertionError fail = null ;
263
267
graceDelayMs = Math .max (graceDelayMs , 100 );
268
+ long waitStart = System .nanoTime ();
264
269
long delay = Math .min (graceDelayMs , 10 );
270
+ long toWait = Math .min (graceDelayMs , Math .max (delay , 1 ));
271
+ long waited = 0 ;
265
272
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 ++) {
267
275
if (TRACKERS .stream ().anyMatch (hasOutstanding )) {
268
276
System .gc ();
269
277
try {
270
278
if (i == 0 ) {
271
279
System .out .println ("Waiting for HTTP operations to terminate..." );
280
+ System .out .println ("\t gracedelay: " + graceDelayMs
281
+ + " ms, iterations: " + count + ", wait/iteration: " + toWait + "ms" );
272
282
}
273
- Thread .sleep (Math .min (graceDelayMs , Math .max (delay , 1 )));
283
+ waited += toWait ;
284
+ Thread .sleep (toWait );
274
285
} catch (InterruptedException x ) {
275
286
// OK
276
287
}
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
+ }
278
294
}
295
+ long duration = Duration .ofNanos (System .nanoTime () - waitStart ).toMillis ();
279
296
if (TRACKERS .stream ().anyMatch (hasOutstanding )) {
280
297
StringBuilder warnings = diagnose (new StringBuilder (), hasOutstanding );
281
298
addSummary (warnings );
@@ -284,14 +301,17 @@ public AssertionError check(long graceDelayMs,
284
301
}
285
302
} else {
286
303
System .out .println ("PASSED: No " + description + " found in "
287
- + getTrackedClientCount () + " clients" );
304
+ + getTrackedClientCount () + " clients in " + duration + " ms " );
288
305
}
289
306
if (fail != null ) {
290
307
Predicate <Tracker > isAlive = Tracker ::isSelectorAlive ;
291
308
if (printThreads && TRACKERS .stream ().anyMatch (isAlive )) {
292
309
printThreads ("Some selector manager threads are still alive: " , System .out );
293
310
printThreads ("Some selector manager threads are still alive: " , System .err );
294
311
}
312
+ System .out .println ("AssertionError: Found some " + description + " in "
313
+ + getTrackedClientCount () + " clients after " + i + " iterations and " + duration
314
+ + " ms, waited " + waited + " ms" );
295
315
}
296
316
return fail ;
297
317
}
0 commit comments