From 1dbbad5582d2d504a0aeac9499d52677223ba763 Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Fri, 29 Apr 2022 08:29:39 -0400 Subject: [PATCH] NO-JIRA stopping object on finalize on openWire test trying to avoid a few test failure seen on CI --- .../transport/tcp/TcpTransportServerTest.java | 39 +++++++++++-------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpTransportServerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpTransportServerTest.java index dcda8f0a26..7abb0a5cc0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpTransportServerTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpTransportServerTest.java @@ -37,23 +37,30 @@ public class TcpTransportServerTest extends TestCase { TcpTransportServer server = (TcpTransportServer) TransportFactory.bind(new URI("tcp://localhost:61616?trace=true")); server.setTransportOption(new HashMap()); - server.setAcceptListener(new TransportAcceptListener() { - @Override - public void onAccept(Transport transport) { - assertTrue("This transport does not have a TransportLogger!!", hasTransportLogger(transport)); + try { + server.setAcceptListener(new TransportAcceptListener() { + @Override + public void onAccept(Transport transport) { + assertTrue("This transport does not have a TransportLogger!!", hasTransportLogger(transport)); + } + + @Override + public void onAcceptError(Exception error) { + fail("Should not have received an error!"); + } + }); + + server.start(); + + Socket socket = new Socket("localhost", 61616); + server.handleSocket(socket); + } finally { + try { + server.stop(); + } catch (Throwable e) { + e.printStackTrace(); } - - @Override - public void onAcceptError(Exception error) { - fail("Should not have received an error!"); - } - }); - - server.start(); - - Socket socket = new Socket("localhost", 61616); - server.handleSocket(socket); - server.stop(); + } }