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 a5df5e67be Rename tests to match standard naming convention.
a5df5e67be is described below
commit a5df5e67beabe2277b9f44635e9ac43a9618c80b
Author: Mark Thomas <[email protected]>
AuthorDate: Wed Sep 30 16:40:01 2026 +0100
Rename tests to match standard naming convention.
Alternative fix for resource leak warnings
---
.../core/TestExecutorAwaitTermination.java | 79 ----------------------
.../catalina/core/TestStandardThreadExecutor.java | 51 ++++++++++++++
.../core/TestStandardVirtualThreadExecutor.java | 52 ++++++++++++++
3 files changed, 103 insertions(+), 79 deletions(-)
diff --git a/test/org/apache/catalina/core/TestExecutorAwaitTermination.java
b/test/org/apache/catalina/core/TestExecutorAwaitTermination.java
deleted file mode 100644
index 2c33a0e1c2..0000000000
--- a/test/org/apache/catalina/core/TestExecutorAwaitTermination.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.catalina.core;
-
-import java.util.concurrent.TimeUnit;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class TestExecutorAwaitTermination {
-
- @Test
- public void testThreadExecutorAwaitTerminationNotStarted() throws
Exception {
- 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
{
- 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 {
- 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 {
- 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();
- }
- }
- }
-}
diff --git a/test/org/apache/catalina/core/TestStandardThreadExecutor.java
b/test/org/apache/catalina/core/TestStandardThreadExecutor.java
new file mode 100644
index 0000000000..0645f73c50
--- /dev/null
+++ b/test/org/apache/catalina/core/TestStandardThreadExecutor.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.catalina.core;
+
+import java.util.concurrent.TimeUnit;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestStandardThreadExecutor {
+
+ @Test
+ public void testAwaitTerminationNotStarted() throws Exception {
+ @SuppressWarnings("resource") // never started
+ 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 testAwaitTerminationDelegates() throws Exception {
+ @SuppressWarnings("resource") // stop() is called
+ 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();
+ }
+ }
+}
diff --git
a/test/org/apache/catalina/core/TestStandardVirtualThreadExecutor.java
b/test/org/apache/catalina/core/TestStandardVirtualThreadExecutor.java
new file mode 100644
index 0000000000..746e5e8cb5
--- /dev/null
+++ b/test/org/apache/catalina/core/TestStandardVirtualThreadExecutor.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.catalina.core;
+
+import java.util.concurrent.TimeUnit;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestStandardVirtualThreadExecutor {
+
+ @Test
+ public void testVirtualThreadExecutorAwaitTerminationNotStarted() throws
Exception {
+ @SuppressWarnings("resource") // never started
+ StandardVirtualThreadExecutor executor = new
StandardVirtualThreadExecutor();
+ 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 {
+ @SuppressWarnings("resource") // stop() is called
+ 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();
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]