GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Capture why threads get stuck in testCopyMultipleThreads0 (#16404) · netty/netty@f7bd22d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • buffer/src/test/java/io/netty/buffer
    • AbstractByteBufTest.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java‎

Copy file name to clipboardExpand all lines: buffer/src/test/java/io/netty/buffer/AbstractByteBufTest.java
+10-10Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2330,6 +2330,11 @@ public void run() {
23302330
thread.start();
23312331
}
23322332

2333+
joinAllAndReportErrors(threads, errorRef);
2334+
}
2335+
2336+
private static void joinAllAndReportErrors(List<Thread> threads, AtomicReference<Throwable> errorRef)
2337+
throws Throwable {
23332338
try {
23342339
for (Thread thread : threads) {
23352340
thread.join();
@@ -2362,15 +2367,17 @@ public void testCopyMultipleThreads0() throws Throwable {
23622367
static void testCopyMultipleThreads0(final ByteBuf buffer) throws Throwable {
23632368
final ByteBuf expected = buffer.copy();
23642369
try {
2365-
final AtomicInteger counter = new AtomicInteger(30000);
2370+
final CyclicBarrier startBarrier = new CyclicBarrier(10);
23662371
final AtomicReference<Throwable> errorRef = new AtomicReference<Throwable>();
23672372
List<Thread> threads = new ArrayList<Thread>();
23682373
for (int i = 0; i < 10; i++) {
23692374
Thread thread = new Thread(new Runnable() {
23702375
@Override
23712376
public void run() {
23722377
try {
2373-
while (errorRef.get() == null && counter.decrementAndGet() > 0) {
2378+
startBarrier.await(10, TimeUnit.SECONDS);
2379+
int counter = 3000;
2380+
while (errorRef.get() == null && counter-- > 0) {
23742381
ByteBuf copy = buffer.copy();
23752382
try {
23762383
assertEquals(expected, copy);
@@ -2389,14 +2396,7 @@ public void run() {
23892396
thread.start();
23902397
}
23912398

2392-
for (Thread thread : threads) {
2393-
thread.join();
2394-
}
2395-
2396-
Throwable error = errorRef.get();
2397-
if (error != null) {
2398-
throw error;
2399-
}
2399+
joinAllAndReportErrors(threads, errorRef);
24002400
} finally {
24012401
expected.release();
24022402
}

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.