Skip to content

Commit

Permalink
8268428: Test java/foreign/TestResourceScope.java fails: expected [M]…
Browse files Browse the repository at this point in the history
… but found [N]

Reviewed-by: dfuchs
  • Loading branch information
mcimadamore committed Jun 10, 2021
1 parent 6b6ff53 commit f4b3170
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions test/jdk/java/foreign/TestResourceScope.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -192,22 +192,25 @@ public void testLockSharedMultiThread(Supplier<Cleaner> cleanerSupplier) {
AtomicInteger lockCount = new AtomicInteger();
for (int i = 0 ; i < N_THREADS ; i++) {
new Thread(() -> {
lockCount.incrementAndGet();
try {
ResourceScope.Handle handle = scope.acquire();
ResourceScope.Handle handle = scope.acquire(); // this can throw if segment has been closed
lockCount.incrementAndGet();
waitSomeTime();
scope.release(handle);
scope.release(handle); // make sure it's idempotent
scope.release(handle); // make sure it's idempotent
lockCount.decrementAndGet();
scope.release(handle); // cannot throw (acquired segments cannot be closed)
scope.release(handle); // cannot throw (idempotent)
scope.release(handle); // cannot throw (idempotent)
} catch (IllegalStateException ex) {
// might be already closed - do nothing
} finally {
lockCount.decrementAndGet();
}
}).start();
}

while (lockCount.get() > 0) {
while (lockCount.get() == 0) {
waitSomeTime(); // make sure some thread gets scheduled
}

while (true) {
try {
scope.close();
assertEquals(lockCount.get(), 0);
Expand Down

1 comment on commit f4b3170

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.