From bdbf3055c5c839d36121a259eff4673c2ff7e67a Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Thu, 12 Mar 2026 17:44:53 +0100 Subject: [PATCH] Fix ExecutorService leak in WS-RM oneway tests DeliveryAssuranceOnewayTest and MessageCallbackOnewayTest create ExecutorService instances via Executors.newSingleThreadExecutor() but never shut them down. The leaked non-daemon threads prevent clean test completion, causing intermittent timeouts in CI (~95-100s for DeliveryAssurance, ~75s for MessageCallback). Track the ExecutorService and shut it down in tearDown() with a 10-second grace period before forceful termination. Co-Authored-By: Claude Opus 4.6 --- .../systest/ws/rm/DeliveryAssuranceOnewayTest.java | 11 +++++++++++ .../cxf/systest/ws/rm/MessageCallbackOnewayTest.java | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/DeliveryAssuranceOnewayTest.java b/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/DeliveryAssuranceOnewayTest.java index 0477cdb7a83..054094adb64 100644 --- a/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/DeliveryAssuranceOnewayTest.java +++ b/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/DeliveryAssuranceOnewayTest.java @@ -76,6 +76,7 @@ public class DeliveryAssuranceOnewayTest extends AbstractBusClientServerTestBase private Endpoint endpoint; private Bus greeterBus; private Greeter greeter; + private ExecutorService executorService; @After public void tearDown() throws Exception { @@ -89,6 +90,13 @@ public void tearDown() throws Exception { } catch (Throwable t) { //ignore } + if (executorService != null) { + executorService.shutdown(); + if (!executorService.awaitTermination(10, TimeUnit.SECONDS)) { + executorService.shutdownNow(); + } + executorService = null; + } Thread.sleep(100); } @@ -380,6 +388,9 @@ private void initProxy(Executor executor) { if (null != executor) { gs.setExecutor(executor); + if (executor instanceof ExecutorService) { + this.executorService = (ExecutorService) executor; + } } greeter = gs.getGreeterPort(); diff --git a/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/MessageCallbackOnewayTest.java b/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/MessageCallbackOnewayTest.java index 6d73c098c13..6f30dfc6f6a 100644 --- a/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/MessageCallbackOnewayTest.java +++ b/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/MessageCallbackOnewayTest.java @@ -25,6 +25,7 @@ import java.util.Set; import java.util.concurrent.BlockingQueue; import java.util.concurrent.Executor; +import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; @@ -81,6 +82,7 @@ public class MessageCallbackOnewayTest extends AbstractBusClientServerTestBase { private Bus greeterBus; private Greeter greeter; private RecordingMessageCallback callback; + private ExecutorService executorService; @After public void tearDown() throws Exception { @@ -94,6 +96,13 @@ public void tearDown() throws Exception { } catch (Throwable t) { //ignore } + if (executorService != null) { + executorService.shutdown(); + if (!executorService.awaitTermination(10, TimeUnit.SECONDS)) { + executorService.shutdownNow(); + } + executorService = null; + } } @Test(timeout = 60000) @@ -216,6 +225,9 @@ private void initProxy(Executor executor) { if (null != executor) { gs.setExecutor(executor); + if (executor instanceof ExecutorService) { + this.executorService = (ExecutorService) executor; + } } greeter = gs.getGreeterPort();