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 9f4d03ff3d Fix spurious wait. Code is unused in normal Tomcat usage.
9f4d03ff3d is described below
commit 9f4d03ff3d4b7eb5465f082038569d396f9f8bbd
Author: Mark Thomas <[email protected]>
AuthorDate: Sat Aug 30 14:58:16 2025 +0100
Fix spurious wait. Code is unused in normal Tomcat usage.
Identified by Coverity scan
---
.../apache/tomcat/util/threads/InlineExecutorService.java | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/java/org/apache/tomcat/util/threads/InlineExecutorService.java
b/java/org/apache/tomcat/util/threads/InlineExecutorService.java
index d065b8b915..71d730f17b 100644
--- a/java/org/apache/tomcat/util/threads/InlineExecutorService.java
+++ b/java/org/apache/tomcat/util/threads/InlineExecutorService.java
@@ -56,11 +56,17 @@ public class InlineExecutorService extends
AbstractExecutorService {
@Override
public boolean awaitTermination(long timeout, TimeUnit unit) throws
InterruptedException {
+ long timeoutExpiry = System.nanoTime() + unit.toNanos(timeout);
+ long timeoutMillis = unit.toMillis(timeout);
synchronized (lock) {
- if (terminated) {
- return true;
- }
- lock.wait(unit.toMillis(timeout));
+ /*
+ * Spurious wake-ups are possible. Keep waiting until the
service has been terminated or the timeout has
+ * expired.
+ */
+ while (!terminated && timeoutMillis > 0) {
+ lock.wait(timeoutMillis);
+ timeoutMillis = (timeoutExpiry - System.nanoTime()) /
1_000_000;
+ }
return terminated;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]