activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [2/2] activemq-artemis git commit: ARTEMIS-1796 AMQP flush during handshake can break SASL
Date Mon, 09 Apr 2018 17:12:08 GMT
ARTEMIS-1796 AMQP flush during handshake can break SASL


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

Branch: refs/heads/master
Commit: 396056ce0438219d6981183256b277433d737e04
Parents: 6ca5f9e
Author: Clebert Suconic <clebertsuconic@apache.org>
Authored: Mon Apr 9 10:43:29 2018 -0400
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Mon Apr 9 13:11:41 2018 -0400

----------------------------------------------------------------------
 .../core/protocol/core/impl/RemotingConnectionImpl.java  |  6 ++++++
 .../spi/core/protocol/AbstractRemotingConnection.java    |  5 +++++
 .../artemis/spi/core/protocol/RemotingConnection.java    |  2 ++
 .../amqp/broker/ActiveMQProtonRemotingConnection.java    |  6 ++++++
 .../protocol/amqp/proton/AMQPConnectionContext.java      |  5 +++++
 .../protocol/amqp/proton/handler/ProtonHandler.java      | 11 +++++++++++
 .../artemis/core/protocol/mqtt/MQTTConnection.java       |  6 ++++++
 .../artemis/core/protocol/stomp/StompConnection.java     |  6 ++++++
 .../core/remoting/server/impl/RemotingServiceImpl.java   |  2 +-
 9 files changed, 48 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/396056ce/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/RemotingConnectionImpl.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/RemotingConnectionImpl.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/RemotingConnectionImpl.java
index ac73b57..f24fe87 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/RemotingConnectionImpl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/RemotingConnectionImpl.java
@@ -78,6 +78,12 @@ public class RemotingConnectionImpl extends AbstractRemotingConnection
implement
 
    private String clientID;
 
+
+   @Override
+   public void scheduledFlush() {
+      flush();
+   }
+
    // Constructors
    // ---------------------------------------------------------------------------------
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/396056ce/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/protocol/AbstractRemotingConnection.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/protocol/AbstractRemotingConnection.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/protocol/AbstractRemotingConnection.java
index a92a695..960cadd 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/protocol/AbstractRemotingConnection.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/protocol/AbstractRemotingConnection.java
@@ -53,6 +53,11 @@ public abstract class AbstractRemotingConnection implements RemotingConnection
{
    }
 
    @Override
+   public void scheduledFlush() {
+      flush();
+   }
+
+   @Override
    public List<FailureListener> getFailureListeners() {
       return new ArrayList<>(failureListeners);
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/396056ce/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/protocol/RemotingConnection.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/protocol/RemotingConnection.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/protocol/RemotingConnection.java
index f2ff5d7..a906a32 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/protocol/RemotingConnection.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/protocol/RemotingConnection.java
@@ -57,6 +57,8 @@ public interface RemotingConnection extends BufferHandler {
     */
    String getRemoteAddress();
 
+   void scheduledFlush();
+
    /**
     * add a failure listener.
     * <p>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/396056ce/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ActiveMQProtonRemotingConnection.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ActiveMQProtonRemotingConnection.java
b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ActiveMQProtonRemotingConnection.java
index 02f035a..a37b7b7 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ActiveMQProtonRemotingConnection.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ActiveMQProtonRemotingConnection.java
@@ -60,6 +60,12 @@ public class ActiveMQProtonRemotingConnection extends AbstractRemotingConnection
       return manager;
    }
 
+
+   @Override
+   public void scheduledFlush() {
+      amqpConnection.scheduledFlush();
+   }
+
    /*
     * This can be called concurrently by more than one thread so needs to be locked
     */

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/396056ce/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AMQPConnectionContext.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AMQPConnectionContext.java
b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AMQPConnectionContext.java
index efb438d..39f9609 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AMQPConnectionContext.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AMQPConnectionContext.java
@@ -123,6 +123,11 @@ public class AMQPConnectionContext extends ProtonInitializable implements
EventH
       }
    }
 
+
+   public void scheduledFlush() {
+      handler.scheduledFlush();
+   }
+
    public boolean isIncomingConnection() {
       return isIncomingConnection;
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/396056ce/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java
b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java
index 5bee66e..fb69208 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java
@@ -131,6 +131,17 @@ public class ProtonHandler extends ProtonInitializable implements SaslListener
{
       }
    }
 
+   /**
+    * We cannot flush until the initial handshake was finished.
+    * If this happens before the handshake, the connection response will happen without SASL
+    * and the client will respond and fail with an invalid code.
+    * */
+   public void scheduledFlush() {
+      if (receivedFirstPacket) {
+         flush();
+      }
+   }
+
    public int capacity() {
       lock.lock();
       try {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/396056ce/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTConnection.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTConnection.java
b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTConnection.java
index 012356b..26c1369 100644
--- a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTConnection.java
+++ b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTConnection.java
@@ -58,6 +58,12 @@ public class MQTTConnection implements RemotingConnection {
       this.destroyed = false;
    }
 
+
+   @Override
+   public void scheduledFlush() {
+      flush();
+   }
+
    @Override
    public boolean isWritable(ReadyListener callback) {
       return transportConnection.isWritable(callback);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/396056ce/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
index 4415c95..baaa36e 100644
--- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
+++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
@@ -116,6 +116,12 @@ public final class StompConnection implements RemotingConnection {
       return frameHandler;
    }
 
+
+   @Override
+   public void scheduledFlush() {
+      flush();
+   }
+
    public StompFrame decode(ActiveMQBuffer buffer) throws ActiveMQStompException {
       StompFrame frame = null;
       try {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/396056ce/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 5af9657..17351d9 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
@@ -716,7 +716,7 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif
                               // this is using a different thread
                               // as if anything wrong happens on flush
                               // failure detection could be affected
-                              conn.flush();
+                              conn.scheduledFlush();
                            } catch (Throwable e) {
                               ActiveMQServerLogger.LOGGER.failedToFlushOutstandingDataFromTheConnection(e);
                            }


Mime
View raw message