This is an automated email from the ASF dual-hosted git repository.

markt-asf 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 0fb2b00591 Fix IDE resource leak warnings
0fb2b00591 is described below

commit 0fb2b0059171447f0e6d552a2603ecf2d18ee230
Author: Mark Thomas <[email protected]>
AuthorDate: Wed Sep 30 15:44:00 2026 +0100

    Fix IDE resource leak warnings
---
 .../core/TestExecutorAwaitTermination.java         | 58 ++++++++++++----------
 1 file changed, 31 insertions(+), 27 deletions(-)

diff --git a/test/org/apache/catalina/core/TestExecutorAwaitTermination.java 
b/test/org/apache/catalina/core/TestExecutorAwaitTermination.java
index 9dc6689622..2c33a0e1c2 100644
--- a/test/org/apache/catalina/core/TestExecutorAwaitTermination.java
+++ b/test/org/apache/catalina/core/TestExecutorAwaitTermination.java
@@ -25,51 +25,55 @@ public class TestExecutorAwaitTermination {
 
     @Test
     public void testThreadExecutorAwaitTerminationNotStarted() throws 
Exception {
-        StandardThreadExecutor executor = new StandardThreadExecutor();
-        try {
-            executor.awaitTermination(0, TimeUnit.MILLISECONDS);
-            Assert.fail("Expected an IllegalStateException before the executor 
is started");
-        } catch (IllegalStateException e) {
-            // Expected
+        try (StandardThreadExecutor executor = new StandardThreadExecutor()) {
+            try {
+                executor.awaitTermination(0, TimeUnit.MILLISECONDS);
+                Assert.fail("Expected an IllegalStateException before the 
executor is started");
+            } catch (IllegalStateException e) {
+                // Expected
+            }
         }
     }
 
 
     @Test
     public void testThreadExecutorAwaitTerminationDelegates() throws Exception 
{
-        StandardThreadExecutor executor = new StandardThreadExecutor();
-        executor.start();
-        try {
-            // The pool is running so termination has not been reached
-            Assert.assertFalse(executor.awaitTermination(0, 
TimeUnit.MILLISECONDS));
-        } finally {
-            executor.stop();
+        try (StandardThreadExecutor executor = new StandardThreadExecutor()) {
+            executor.start();
+            try {
+                // The pool is running so termination has not been reached
+                Assert.assertFalse(executor.awaitTermination(0, 
TimeUnit.MILLISECONDS));
+            } finally {
+                executor.stop();
+            }
         }
     }
 
 
     @Test
     public void testVirtualThreadExecutorAwaitTerminationNotStarted() throws 
Exception {
-        StandardVirtualThreadExecutor executor = new 
StandardVirtualThreadExecutor();
-        try {
-            executor.awaitTermination(0, TimeUnit.MILLISECONDS);
-            Assert.fail("Expected an IllegalStateException before the executor 
is started");
-        } catch (IllegalStateException e) {
-            // Expected
+        try (StandardThreadExecutor executor = new StandardThreadExecutor()) {
+            try {
+                executor.awaitTermination(0, TimeUnit.MILLISECONDS);
+                Assert.fail("Expected an IllegalStateException before the 
executor is started");
+            } catch (IllegalStateException e) {
+                // Expected
+            }
         }
     }
 
 
     @Test
     public void testVirtualThreadExecutorAwaitTerminationDelegates() throws 
Exception {
-        StandardVirtualThreadExecutor executor = new 
StandardVirtualThreadExecutor();
-        executor.start();
-        try {
-            // The executor has not been shut down so termination has not been
-            // reached; the call must delegate rather than block indefinitely
-            Assert.assertFalse(executor.awaitTermination(0, 
TimeUnit.MILLISECONDS));
-        } finally {
-            executor.stop();
+        try (StandardThreadExecutor executor = new StandardThreadExecutor()) {
+            executor.start();
+            try {
+                // The executor has not been shut down so termination has not 
been
+                // reached; the call must delegate rather than block 
indefinitely
+                Assert.assertFalse(executor.awaitTermination(0, 
TimeUnit.MILLISECONDS));
+            } finally {
+                executor.stop();
+            }
         }
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to