activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r1482117 - in /activemq/trunk: activemq-broker/src/main/java/org/apache/activemq/transport/vm/ activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/
Date Mon, 13 May 2013 21:43:40 GMT
Author: gtully
Date: Mon May 13 21:43:39 2013
New Revision: 1482117

URL: http://svn.apache.org/r1482117
Log:
https://issues.apache.org/jira/browse/AMQ-4532 - fix and test - ensure disposed exception
is propagated to clients on vm server shutdown

Modified:
    activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/transport/vm/VMTransport.java
    activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportThreadSafeTest.java
    activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VmTransportNetworkBrokerTest.java

Modified: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/transport/vm/VMTransport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/transport/vm/VMTransport.java?rev=1482117&r1=1482116&r2=1482117&view=diff
==============================================================================
--- activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/transport/vm/VMTransport.java
(original)
+++ activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/transport/vm/VMTransport.java
Mon May 13 21:43:39 2013
@@ -200,6 +200,12 @@ public class VMTransport implements Tran
             } catch (Exception ignore) {
             }
 
+            // let any requests pending a response see an exception
+            try {
+                peer.transportListener.onException(new TransportDisposedIOException("peer
(" + this + ") stopped."));
+            } catch (Exception ignore) {
+            }
+
             // shutdown task runner factory
             if (taskRunnerFactory != null) {
                 taskRunnerFactory.shutdownNow();

Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportThreadSafeTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportThreadSafeTest.java?rev=1482117&r1=1482116&r2=1482117&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportThreadSafeTest.java
(original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportThreadSafeTest.java
Mon May 13 21:43:39 2013
@@ -29,10 +29,14 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.activemq.command.BaseCommand;
+import org.apache.activemq.command.ExceptionResponse;
 import org.apache.activemq.command.Response;
 import org.apache.activemq.command.ShutdownInfo;
 import org.apache.activemq.state.CommandVisitor;
+import org.apache.activemq.transport.FutureResponse;
 import org.apache.activemq.transport.MutexTransport;
+import org.apache.activemq.transport.ResponseCallback;
+import org.apache.activemq.transport.ResponseCorrelator;
 import org.apache.activemq.transport.Transport;
 import org.apache.activemq.transport.TransportDisposedIOException;
 import org.apache.activemq.transport.TransportListener;
@@ -284,6 +288,47 @@ public class VMTransportThreadSafeTest {
     }
 
     @Test(timeout=60000)
+    public void testRemoteStopSendsExceptionToPendingRequests() throws Exception {
+
+        final VMTransport local = new VMTransport(new URI(location1));
+        final VMTransport remote = new VMTransport(new URI(location2));
+
+        local.setPeer(remote);
+        remote.setPeer(local);
+
+        final VMTestTransportListener remoteListener = new VMTestTransportListener(remoteReceived);
+        remote.setTransportListener(remoteListener);
+
+        final Response[] answer = new Response[1];
+        ResponseCorrelator responseCorrelator = new ResponseCorrelator(local);
+        responseCorrelator.setTransportListener(new VMTestTransportListener(localReceived));
+        responseCorrelator.start();
+        responseCorrelator.asyncRequest(new DummyCommand(), new ResponseCallback() {
+            @Override
+            public void onCompletion(FutureResponse resp) {
+                try {
+                    answer[0] = resp.getResult();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        });
+
+        // simulate broker stop
+        remote.stop();
+
+        assertTrue(Wait.waitFor(new Wait.Condition() {
+            @Override
+            public boolean isSatisified() throws Exception {
+                LOG.info("answer: " + answer[0]);
+                return answer[0] instanceof ExceptionResponse && ((ExceptionResponse)answer[0]).getException()
instanceof TransportDisposedIOException;
+            }
+        }));
+
+        local.stop();
+    }
+
+    @Test(timeout=60000)
     public void testMultipleStartsAndStops() throws Exception {
 
         final VMTransport local = new VMTransport(new URI(location1));

Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VmTransportNetworkBrokerTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VmTransportNetworkBrokerTest.java?rev=1482117&r1=1482116&r2=1482117&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VmTransportNetworkBrokerTest.java
(original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VmTransportNetworkBrokerTest.java
Mon May 13 21:43:39 2013
@@ -109,7 +109,7 @@ public class VmTransportNetworkBrokerTes
         		originalThreadCount + 
         		" threadCountAfterStop=" + 
         		threadCountAfterStop,
-            threadCountAfterStop == originalThreadCount);
+            threadCountAfterStop <= originalThreadCount);
     }
     
     



Mime
View raw message