This is an automated email from the ASF dual-hosted git repository.
markt-asf 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 e9f2c8f420 Fix IDE resource leak warnings
e9f2c8f420 is described below
commit e9f2c8f420abc18effc754109567a047449ed90e
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]