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 — Auto-port 4.1: Capture why threads get stuck in testCopyMultipleThrea… · netty/netty@0e416db

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
@@ -2326,6 +2326,11 @@ public void run() {
23262326
thread.start();
23272327
}
23282328

2329+
joinAllAndReportErrors(threads, errorRef);
2330+
}
2331+
2332+
private static void joinAllAndReportErrors(List<Thread> threads, AtomicReference<Throwable> errorRef)
2333+
throws Throwable {
23292334
try {
23302335
for (Thread thread : threads) {
23312336
thread.join();
@@ -2358,15 +2363,17 @@ public void testCopyMultipleThreads0() throws Throwable {
23582363
static void testCopyMultipleThreads0(final ByteBuf buffer) throws Throwable {
23592364
final ByteBuf expected = buffer.copy();
23602365
try {
2361-
final AtomicInteger counter = new AtomicInteger(30000);
2366+
final CyclicBarrier startBarrier = new CyclicBarrier(10);
23622367
final AtomicReference<Throwable> errorRef = new AtomicReference<Throwable>();
23632368
List<Thread> threads = new ArrayList<Thread>();
23642369
for (int i = 0; i < 10; i++) {
23652370
Thread thread = new Thread(new Runnable() {
23662371
@Override
23672372
public void run() {
23682373
try {
2369-
while (errorRef.get() == null && counter.decrementAndGet() > 0) {
2374+
startBarrier.await(10, TimeUnit.SECONDS);
2375+
int counter = 3000;
2376+
while (errorRef.get() == null && counter-- > 0) {
23702377
ByteBuf copy = buffer.copy();
23712378
try {
23722379
assertEquals(expected, copy);
@@ -2385,14 +2392,7 @@ public void run() {
23852392
thread.start();
23862393
}
23872394

2388-
for (Thread thread : threads) {
2389-
thread.join();
2390-
}
2391-
2392-
Throwable error = errorRef.get();
2393-
if (error != null) {
2394-
throw error;
2395-
}
2395+
joinAllAndReportErrors(threads, errorRef);
23962396
} finally {
23972397
expected.release();
23982398
}

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.