This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push:
new 5e8b4b1e44 Fix spurious wait. Code is unused in normal Tomcat usage.
5e8b4b1e44 is described below
commit 5e8b4b1e44f5e4a2e7235afc4804d3d5b8b69638
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 5be02c469e..dfbdf11353 100644
--- a/java/org/apache/tomcat/util/threads/InlineExecutorService.java
+++ b/java/org/apache/tomcat/util/threads/InlineExecutorService.java
@@ -55,11 +55,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]