Skip to content

Commit

Permalink
Polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Sep 8, 2024
1 parent 40bc1c4 commit 044f5cf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*Scope:* minor bug fixes and improvements since 5.11.0

For a complete list of all _closed_ issues and pull requests for this release, consult the
link:{junit5-repo}+/milestone/79?closed=1+[5.11.1] milestone page in the
JUnit repository on GitHub.
link:{junit5-repo}+/milestone/79?closed=1+[5.11.1] milestone page in the JUnit repository
on GitHub.


[[release-notes-5.11.1-junit-platform]]
Expand All @@ -16,8 +16,8 @@ JUnit repository on GitHub.
[[release-notes-5.11.1-junit-platform-bug-fixes]]
==== Bug Fixes

* Fix potential locking issue with `ExclusiveResource` in the `HierarchicalTestExecutorService`.
This could lead to deadlocks in certain scenarios.
* Fixed potential locking issue with `ExclusiveResource` in the
`HierarchicalTestExecutorService`, which could lead to deadlocks in certain scenarios.

[[release-notes-5.11.1-junit-platform-deprecations-and-breaking-changes]]
==== Deprecations and Breaking Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CompositeLock implements ResourceLock {

// for tests only
List<Lock> getLocks() {
return locks;
return this.locks;
}

@Override
Expand All @@ -38,9 +38,9 @@ public ResourceLock acquire() throws InterruptedException {
}

private void acquireAllLocks() throws InterruptedException {
List<Lock> acquiredLocks = new ArrayList<>(locks.size());
List<Lock> acquiredLocks = new ArrayList<>(this.locks.size());
try {
for (Lock lock : locks) {
for (Lock lock : this.locks) {
lock.lockInterruptibly();
acquiredLocks.add(lock);
}
Expand All @@ -53,7 +53,7 @@ private void acquireAllLocks() throws InterruptedException {

@Override
public void release() {
release(locks);
release(this.locks);
}

private void release(List<Lock> acquiredLocks) {
Expand All @@ -64,20 +64,20 @@ private void release(List<Lock> acquiredLocks) {

private class CompositeLockManagedBlocker implements ForkJoinPool.ManagedBlocker {

private boolean acquired;
private volatile boolean acquired;

@Override
public boolean block() throws InterruptedException {
if (!acquired) {
if (!this.acquired) {
acquireAllLocks();
acquired = true;
this.acquired = true;
}
return true;
}

@Override
public boolean isReleasable() {
return acquired;
return this.acquired;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SingleLock implements ResourceLock {

// for tests only
Lock getLock() {
return lock;
return this.lock;
}

@Override
Expand All @@ -37,25 +37,25 @@ public ResourceLock acquire() throws InterruptedException {

@Override
public void release() {
lock.unlock();
this.lock.unlock();
}

private class SingleLockManagedBlocker implements ForkJoinPool.ManagedBlocker {

private boolean acquired;
private volatile boolean acquired;

@Override
public boolean block() throws InterruptedException {
if (!acquired) {
lock.lockInterruptibly();
acquired = true;
if (!this.acquired) {
SingleLock.this.lock.lockInterruptibly();
this.acquired = true;
}
return true;
}

@Override
public boolean isReleasable() {
return acquired || (acquired = lock.tryLock());
return this.acquired || (this.acquired = SingleLock.this.lock.tryLock());
}

}
Expand Down

0 comments on commit 044f5cf

Please sign in to comment.