This is an automated email from the ASF dual-hosted git repository. reta pushed a commit to branch 3.2.x-fixes in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 6d596ba5c3c9e8b2d85a95ce39d5d87d8fbf0863 Author: reta <[email protected]> AuthorDate: Tue Dec 17 19:27:05 2019 -0500 CXF-8161: fix memory leak and thread leak in JMSDestination. Minor test cleanups. (cherry picked from commit a111a96f5faec215c409d816fc1b7149a74f0258) (cherry picked from commit 5021ff0fd5bbb1f5a9258745780e8863db7ad3a9) --- .../java/org/apache/cxf/transport/jms/JMSDestinationTest.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSDestinationTest.java b/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSDestinationTest.java index f7a38c9..11c5590 100644 --- a/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSDestinationTest.java +++ b/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSDestinationTest.java @@ -135,6 +135,7 @@ public class JMSDestinationTest extends AbstractJMSTester { private final AtomicInteger latch; private final ConnectionFactory delegate; private final Function<Connection, Connection> wrapper; + private final AtomicInteger connectionsCreated = new AtomicInteger(0); private FaultyConnectionFactory(ConnectionFactory delegate, int faults) { this(delegate, FaultyConnection::new, faults); @@ -150,6 +151,7 @@ public class JMSDestinationTest extends AbstractJMSTester { @Override public Connection createConnection() throws JMSException { if (latch.getAndDecrement() <= 0) { + connectionsCreated.incrementAndGet(); return wrapper.apply(delegate.createConnection()); } else { throw new JMSException("createConnection() failed (simulated)"); @@ -655,16 +657,17 @@ public class JMSDestinationTest extends AbstractJMSTester { destination.shutdown(); } + @SuppressWarnings("unused") @Test public void testSessionsExceptionHandling() throws Exception { - EndpointInfo ei = setupServiceInfo("HelloWorldPubSubService", "HelloWorldPubSubPort"); - final AtomicInteger latch = new AtomicInteger(5); + final EndpointInfo ei = setupServiceInfo("HelloWorldPubSubService", "HelloWorldPubSubPort"); + final AtomicInteger sessionsToFail = new AtomicInteger(5); final Function<Connection, Connection> connection = c -> new FaultyConnection(c) { @Override public Session createSession(boolean transacted, int acknowledgeMode) throws JMSException { // Fail five times, starting with on successful call - final int value = latch.getAndDecrement(); + final int value = sessionsToFail.getAndDecrement(); if (value >= 0 && value < 5) { throw new JMSException("createSession() failed (simulated)"); } else { @@ -704,7 +707,7 @@ public class JMSDestinationTest extends AbstractJMSTester { destination.shutdown(); assertEquals("Only two createConnection() calls allowed because restartConnection() should be " - + "called only once.", -2, faultyConnectionFactory.latch.get()); + + "called only once.", 2, faultyConnectionFactory.connectionsCreated.get()); }
