GeezerVison is showing github.com — Fix flaky AbstractSingleThreadEventLoopTest (#16352) · netty/netty@0bbe495
File tree
Expand file treeCollapse file tree
Open diff view settings
testsuite/src/main/java/io/netty/testsuite/transport
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: testsuite/src/main/java/io/netty/testsuite/transport/AbstractSingleThreadEventLoopTest.java +9-5Lines changed: 9 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -373,14 +373,18 @@ public void testSubmittingTaskWakesUpSuspendedExecutor() throws Exception { |
373 | 373 | assertNotNull(suspendedLoop, "Could not find a suspended executor to test."); |
374 | 374 |
|
375 | 375 | // Submit a task directly to the suspended loop, this should trigger the wake-up mechanism. |
376 | | - Future<?> future = suspendedLoop.submit(() -> { }); |
377 | | - future.syncUninterruptibly(); |
378 | | - |
379 | | - assertFalse(suspendedLoop.isSuspended(), "Executor should wake up after task submission."); |
| 376 | + int i = 0; |
| 377 | + boolean isSuspended; |
| 378 | + do { |
| 379 | + Future<?> future = suspendedLoop.submit(() -> { }); |
| 380 | + future.sync(); |
| 381 | + } while ((isSuspended = suspendedLoop.isSuspended()) && i++ < 10); |
| 382 | + |
| 383 | + assertFalse(isSuspended, "Executor should wake up after task submission."); |
380 | 384 | assertEquals(SCALING_MAX_THREADS, countActiveExecutors(group), |
381 | 385 | "Active executor count should increase after wake-up."); |
382 | 386 | } finally { |
383 | | - group.shutdownGracefully().syncUninterruptibly(); |
| 387 | + group.shutdownGracefully().sync(); |
384 | 388 | } |
385 | 389 | } |
386 | 390 |
|
|