Skip to content

Commit

Permalink
Use standard code pattern for releasing locks
Browse files Browse the repository at this point in the history
This silences a CodeQL security warning.
This is not a real issue, though, since this is test-only code.
  • Loading branch information
chrisvest committed May 27, 2024
1 parent 1cfe94f commit 197e1f4
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/test/java/blackbox/AllocatorBasedPoolTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1007,16 +1007,19 @@ void claimMustStayWithinTimeoutEvenIfExpiredObjectIsReleased(Taps taps) throws E
assertNotNull(objs[i], "Did not claim an object in time");
}
lock.lock(); // prevent new allocations
Thread thread = fork($delayedReleases(10, TimeUnit.MILLISECONDS, objs));
try {
// must return before test times out:
GenericPoolable obj = tap.claim(new Timeout(50, TimeUnit.MILLISECONDS));
if (obj != null) {
obj.release();
Thread thread = fork($delayedReleases(10, TimeUnit.MILLISECONDS, objs));
try {
// must return before test times out:
GenericPoolable obj = tap.claim(new Timeout(50, TimeUnit.MILLISECONDS));
if (obj != null) {
obj.release();
}
} finally {
thread.interrupt();
thread.join();
}
} finally {
thread.interrupt();
thread.join();
lock.unlock();
}
}
Expand Down

0 comments on commit 197e1f4

Please sign in to comment.