You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2026/09/30 14:44:23 UTC
(tomcat) branch 11.0.x updated: Fix IDE resource leak warnings
This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/11.0.x by this push:
new 4c8c78201b Fix IDE resource leak warnings
4c8c78201b is described below
commit 4c8c78201b2c6d69623bd78c029e18a6367c148f
Author: Mark Thomas <ma...@apache.org>
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: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org