This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push: new 6170e45b41 Fix unlock logic after review from kkolinko 6170e45b41 is described below commit 6170e45b41853fc6d73adc4c94545bd11f2cb81b Author: Mark Thomas <ma...@apache.org> AuthorDate: Thu Jul 18 13:49:50 2024 +0100 Fix unlock logic after review from kkolinko Only call unlock() if lock() was successful --- java/org/apache/tomcat/jni/Library.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/java/org/apache/tomcat/jni/Library.java b/java/org/apache/tomcat/jni/Library.java index c8e62f4a27..c83b95e316 100644 --- a/java/org/apache/tomcat/jni/Library.java +++ b/java/org/apache/tomcat/jni/Library.java @@ -316,10 +316,12 @@ public final class Library { public static boolean tryCleanUpLock(long cleanupGeneration) { try { boolean result = cleanUpLock.readLock().tryLock(0, TimeUnit.SECONDS); - if (result && generation.get() == cleanupGeneration) { - return true; + if (result) { + if (generation.get() == cleanupGeneration) { + return true; + } + cleanUpLock.readLock().unlock(); } - cleanUpLock.readLock().unlock(); } catch (InterruptedException e) { // Treated the same way as not getting the lock } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org