You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2019/12/19 02:49:41 UTC

[cxf] branch 3.3.x-fixes updated (7bb7a40 -> 5021ff0)

This is an automated email from the ASF dual-hosted git repository.

reta pushed a change to branch 3.3.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git.


    from 7bb7a40  Updating Tomcat
     new c3fb43c  [CXF-8161] test case with parallel error handling in JMSDestination and PollingMessageListenerContainer (#614)
     new f16c5b2  CXF-8161: fix memory leak and thread leak in JMSDestination. Minor test cleanups.
     new 5021ff0  CXF-8161: fix memory leak and thread leak in JMSDestination. Minor test cleanups.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../cxf/transport/jms/JMSDestinationTest.java      | 64 +++++++++++++---------
 1 file changed, 37 insertions(+), 27 deletions(-)


[cxf] 03/03: CXF-8161: fix memory leak and thread leak in JMSDestination. Minor test cleanups.

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch 3.3.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 5021ff0fd5bbb1f5a9258745780e8863db7ad3a9
Author: reta <dr...@gmail.com>
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)
---
 .../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 549f891..ab8d156 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
@@ -129,6 +129,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);
@@ -144,6 +145,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)");
@@ -571,16 +573,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 {
@@ -619,7 +622,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());
     }
 
 


[cxf] 02/03: CXF-8161: fix memory leak and thread leak in JMSDestination. Minor test cleanups.

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch 3.3.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit f16c5b27e4c4668ae54c66881e4a3a9bb6841994
Author: reta <dr...@gmail.com>
AuthorDate: Tue Dec 17 19:21:54 2019 -0500

    CXF-8161: fix memory leak and thread leak in JMSDestination. Minor test cleanups.
    
    (cherry picked from commit f5f8b798bb59065d91ac14819fa669fe9c3ebe57)
---
 .../org/apache/cxf/transport/jms/JMSDestinationTest.java     | 12 ++++++------
 1 file changed, 6 insertions(+), 6 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 a409ffb..549f891 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
@@ -126,7 +126,7 @@ public class JMSDestinationTest extends AbstractJMSTester {
     }
 
     private static final class FaultyConnectionFactory implements ConnectionFactory {
-        final AtomicInteger latch;
+        private final AtomicInteger latch;
         private final ConnectionFactory delegate;
         private final Function<Connection, Connection> wrapper;
 
@@ -580,8 +580,8 @@ public class JMSDestinationTest extends AbstractJMSTester {
             @Override
             public Session createSession(boolean transacted, int acknowledgeMode) throws JMSException {
                 // Fail five times, starting with on successful call
-                final int latchValue = latch.getAndDecrement();
-                if (latchValue >= 0 && latchValue < 5) {
+                final int value = latch.getAndDecrement();
+                if (value >= 0 && value < 5) {
                     throw new JMSException("createSession() failed (simulated)");
                 } else {
                     return super.createSession(transacted, acknowledgeMode);
@@ -617,9 +617,9 @@ public class JMSDestinationTest extends AbstractJMSTester {
 
         conduit.close();
         destination.shutdown();
-        assertEquals("Only two createConnection() calls allowed because "
-                     + "restartConnection() should be called only once.",
-                -2, faultyConnectionFactory.latch.get());
+        
+        assertEquals("Only two createConnection() calls allowed because restartConnection() should be "
+            + "called only once.", -2, faultyConnectionFactory.latch.get());
     }
 
 


[cxf] 01/03: [CXF-8161] test case with parallel error handling in JMSDestination and PollingMessageListenerContainer (#614)

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch 3.3.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit c3fb43cd1b6f86f9bbf62f7262349f2905b985a8
Author: steingebein <57...@users.noreply.github.com>
AuthorDate: Tue Dec 17 03:59:09 2019 +0100

    [CXF-8161] test case with parallel error handling in JMSDestination and PollingMessageListenerContainer (#614)
---
 .../cxf/transport/jms/JMSDestinationTest.java      | 59 ++++++++++++----------
 1 file changed, 33 insertions(+), 26 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 f559180..a409ffb 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
@@ -61,7 +61,7 @@ import static org.junit.Assert.assertTrue;
 public class JMSDestinationTest extends AbstractJMSTester {
     private static class FaultyConnection implements Connection {
         private final Connection delegate;
-        
+
         FaultyConnection(final Connection delegate) {
             this.delegate = delegate;
         }
@@ -118,23 +118,23 @@ public class JMSDestinationTest extends AbstractJMSTester {
         }
 
         @Override
-        public ConnectionConsumer createDurableConnectionConsumer(Topic topic, String subscriptionName, 
+        public ConnectionConsumer createDurableConnectionConsumer(Topic topic, String subscriptionName,
                 String messageSelector, ServerSessionPool sessionPool, int maxMessages) throws JMSException {
-            return delegate.createDurableConnectionConsumer(topic, subscriptionName, messageSelector, 
-                sessionPool, maxMessages);   
+            return delegate.createDurableConnectionConsumer(topic, subscriptionName, messageSelector,
+                sessionPool, maxMessages);
         }
     }
-    
+
     private static final class FaultyConnectionFactory implements ConnectionFactory {
+        final AtomicInteger latch;
         private final ConnectionFactory delegate;
         private final Function<Connection, Connection> wrapper;
-        private final AtomicInteger latch;
 
         private FaultyConnectionFactory(ConnectionFactory delegate, int faults) {
             this(delegate, FaultyConnection::new, faults);
         }
-        
-        private FaultyConnectionFactory(ConnectionFactory delegate, 
+
+        private FaultyConnectionFactory(ConnectionFactory delegate,
                 Function<Connection, Connection> wrapper, int faults) {
             this.delegate = delegate;
             this.wrapper = wrapper;
@@ -159,7 +159,7 @@ public class JMSDestinationTest extends AbstractJMSTester {
             }
         }
     }
-    
+
     @Test
     public void testGetConfigurationFromWSDL() throws Exception {
         EndpointInfo ei = setupServiceInfo("HelloWorldQueueBinMsgService", "HelloWorldQueueBinMsgPort");
@@ -570,35 +570,39 @@ public class JMSDestinationTest extends AbstractJMSTester {
         conduit.close();
         destination.shutdown();
     }
-    
+
     @Test
     public void testSessionsExceptionHandling() throws Exception {
         EndpointInfo ei = setupServiceInfo("HelloWorldPubSubService", "HelloWorldPubSubPort");
-        final AtomicInteger latch = new AtomicInteger(1);
-        
+        final AtomicInteger latch = new AtomicInteger(5);
+
         final Function<Connection, Connection> connection = c -> new FaultyConnection(c) {
-                @Override
-                public Session createSession(boolean transacted, int acknowledgeMode) throws JMSException {
-                    // Fail only once
-                    if (latch.getAndDecrement() == 0) {
-                        throw new JMSException("createSession() failed (simulated)");
-                    } else {
-                        return super.createSession(transacted, acknowledgeMode);
-                    }
+            @Override
+            public Session createSession(boolean transacted, int acknowledgeMode) throws JMSException {
+                // Fail five times, starting with on successful call
+                final int latchValue = latch.getAndDecrement();
+                if (latchValue >= 0 && latchValue < 5) {
+                    throw new JMSException("createSession() failed (simulated)");
+                } else {
+                    return super.createSession(transacted, acknowledgeMode);
                 }
-            };
-            
+            }
+        };
+
+        final FaultyConnectionFactory faultyConnectionFactory = new FaultyConnectionFactory(cf, connection, 0);
         final Function<ConnectionFactory, ConnectionFactory> wrapper =
             new Function<ConnectionFactory, ConnectionFactory>() {
                 @Override
                 public ConnectionFactory apply(ConnectionFactory cf) {
-                    return new FaultyConnectionFactory(cf, connection, 0);
+                    return faultyConnectionFactory;
                 }
             };
-            
         JMSConduit conduit = setupJMSConduitWithObserver(ei);
-        JMSDestination destination = setupJMSDestination(ei, wrapper);
-        destination.getJmsConfig().setRetryInterval(1000);
+        JMSConfiguration jmsConfig = JMSConfigFactory.createFromEndpointInfo(bus, ei, null);
+        jmsConfig.setConnectionFactory(wrapper.apply(cf));
+        jmsConfig.setRetryInterval(1000);
+        jmsConfig.setConcurrentConsumers(10);
+        JMSDestination destination = new JMSDestination(bus, ei, jmsConfig);
         destination.setMessageObserver(createMessageObserver());
 
         final Message outMessage = createMessage();
@@ -613,6 +617,9 @@ public class JMSDestinationTest extends AbstractJMSTester {
 
         conduit.close();
         destination.shutdown();
+        assertEquals("Only two createConnection() calls allowed because "
+                     + "restartConnection() should be called only once.",
+                -2, faultyConnectionFactory.latch.get());
     }