ARTEMIS-1927 treat exceptions and disconnect properly

I couldn't do this with a test as this is dependent on windows. Regular 
testsuite should be sufficient as long as you run in Windows.


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/88833c79
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/88833c79
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/88833c79

Branch: refs/heads/master
Commit: 88833c790af1459990bc4203414966afd7438e02
Parents: 1d51288
Author: Clebert Suconic <clebertsuco...@apache.org>
Authored: Tue Jun 12 16:29:13 2018 -0400
Committer: Clebert Suconic <clebertsuco...@apache.org>
Committed: Tue Jun 12 18:54:45 2018 -0400

----------------------------------------------------------------------
 .../remoting/impl/netty/ActiveMQChannelHandler.java  |  3 +--
 .../remoting/server/impl/RemotingServiceImpl.java    | 15 ++++++---------
 2 files changed, 7 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/88833c79/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/ActiveMQChannelHandler.java
----------------------------------------------------------------------
diff --git 
a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/ActiveMQChannelHandler.java
 
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/ActiveMQChannelHandler.java
index d0d5c0e..de8b49e 100644
--- 
a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/ActiveMQChannelHandler.java
+++ 
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/ActiveMQChannelHandler.java
@@ -26,7 +26,6 @@ import io.netty.channel.group.ChannelGroup;
 import org.apache.activemq.artemis.api.core.ActiveMQException;
 import org.apache.activemq.artemis.core.buffers.impl.ChannelBufferWrapper;
 import org.apache.activemq.artemis.core.client.ActiveMQClientLogger;
-import org.apache.activemq.artemis.core.client.ActiveMQClientMessageBundle;
 import 
org.apache.activemq.artemis.spi.core.remoting.BaseConnectionLifeCycleListener;
 import org.apache.activemq.artemis.spi.core.remoting.BufferHandler;
 
@@ -99,7 +98,7 @@ public class ActiveMQChannelHandler extends 
ChannelDuplexHandler {
       // and we don't want to spew out stack traces in that event
       // The user has access to this exeception anyway via the 
ActiveMQException initial cause
 
-      ActiveMQException me = ActiveMQClientMessageBundle.BUNDLE.nettyError();
+      ActiveMQException me = new ActiveMQException(cause.getMessage());
       me.initCause(cause);
 
       synchronized (listener) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/88833c79/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java
----------------------------------------------------------------------
diff --git 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java
 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java
index 17351d9..5a1ddef 100644
--- 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java
+++ 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java
@@ -539,6 +539,10 @@ public class RemotingServiceImpl implements 
RemotingService, ServerConnectionLif
          logger.trace("Connection removed " + connectionID + " from server " + 
this.server, new Exception("trace"));
       }
 
+      issueFailure(connectionID, new ActiveMQRemoteDisconnectException());
+   }
+
+   private void issueFailure(Object connectionID, ActiveMQException e) {
       ConnectionEntry conn = connections.get(connectionID);
 
       if (conn != null && !conn.connection.isSupportReconnect()) {
@@ -554,20 +558,13 @@ public class RemotingServiceImpl implements 
RemotingService, ServerConnectionLif
                return;
             }
          }
-         conn.connection.fail(new ActiveMQRemoteDisconnectException());
+         conn.connection.fail(e);
       }
    }
 
    @Override
    public void connectionException(final Object connectionID, final 
ActiveMQException me) {
-      // We DO NOT call fail on connection exception, otherwise in event of 
real connection failure, the
-      // connection will be failed, the session will be closed and won't be 
able to reconnect
-
-      // E.g. if live server fails, then this handler wil be called on backup 
server for the server
-      // side replicating connection.
-      // If the connection fail() is called then the sessions on the backup 
will get closed.
-
-      // Connections should only fail when TTL is exceeded
+      issueFailure(connectionID, me);
    }
 
    @Override

Reply via email to