[1/2] activemq-artemis git commit: ARTEMIS-1332 Always return a response to the client on session metadata add

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[1/2] activemq-artemis git commit: ARTEMIS-1332 Always return a response to the client on session metadata add

clebertsuconic-2
Repository: activemq-artemis
Updated Branches:
  refs/heads/master 840ff8d23 -> e81c8c26d


ARTEMIS-1332 Always return a response to the client on session metadata add

This will make sure that if there is an ActiveMQException thrown the
client will get notified and not hang.


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

Branch: refs/heads/master
Commit: 64bacee28a74743007f8c8f2f547e2edc203db85
Parents: 840ff8d
Author: Christopher L. Shannon (cshannon) <[hidden email]>
Authored: Tue Aug 8 13:09:03 2017 -0400
Committer: Clebert Suconic <[hidden email]>
Committed: Thu Aug 10 12:28:14 2017 -0400

----------------------------------------------------------------------
 .../core/ServerSessionPacketHandler.java        |  2 +
 .../client/SessionMetadataAddExceptionTest.java | 93 ++++++++++++++++++++
 2 files changed, 95 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/64bacee2/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java
index 982bc88..7b45c9f 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java
@@ -593,6 +593,7 @@ public class ServerSessionPacketHandler implements ChannelHandler {
                   break;
                }
                case PacketImpl.SESS_ADD_METADATA2: {
+                  requiresResponse = true;
                   SessionAddMetaDataMessageV2 message = (SessionAddMetaDataMessageV2) packet;
                   if (message.isRequiresConfirmations()) {
                      response = new NullResponseMessage();
@@ -601,6 +602,7 @@ public class ServerSessionPacketHandler implements ChannelHandler {
                   break;
                }
                case PacketImpl.SESS_UNIQUE_ADD_METADATA: {
+                  requiresResponse = true;
                   SessionUniqueAddMetaDataMessage message = (SessionUniqueAddMetaDataMessage) packet;
                   if (session.addUniqueMetaData(message.getKey(), message.getData())) {
                      response = new NullResponseMessage();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/64bacee2/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/SessionMetadataAddExceptionTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/SessionMetadataAddExceptionTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/SessionMetadataAddExceptionTest.java
new file mode 100644
index 0000000..f1bd289
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/SessionMetadataAddExceptionTest.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.tests.integration.jms.client;
+
+import javax.jms.Connection;
+import javax.jms.JMSException;
+
+import org.apache.activemq.artemis.api.core.ActiveMQException;
+import org.apache.activemq.artemis.api.core.client.ClientSession;
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.core.server.ServerSession;
+import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerPlugin;
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
+import org.apache.activemq.artemis.tests.util.JMSTestBase;
+import org.junit.Test;
+
+/**
+ * Test that the client receives an exception if there is an error when metadata
+ * is added
+ */
+public class SessionMetadataAddExceptionTest extends JMSTestBase {
+
+   @Override
+   protected Configuration createDefaultConfig(boolean netty) throws Exception {
+      Configuration config = super.createDefaultConfig(netty);
+      config.registerBrokerPlugin(new ActiveMQServerPlugin() {
+
+         @Override
+         public void beforeSessionMetadataAdded(ServerSession session, String key, String data)
+               throws ActiveMQException {
+
+            if (ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY.equals(key)) {
+               if ("invalid".equals(data)) {
+                  throw new ActiveMQException("Invalid clientId");
+               }
+            }
+         }
+
+      });
+
+      return config;
+   }
+
+   @Test(timeout = 5000, expected = JMSException.class)
+   public void testInvalidClientIdSetConnection() throws Exception {
+      Connection con = cf.createConnection();
+      con.setClientID("invalid");
+   }
+
+   @Test(timeout = 5000, expected = JMSException.class)
+   public void testInvalidClientIdSetFactory() throws Exception {
+      ActiveMQConnectionFactory activeMQConnectionFactory = (ActiveMQConnectionFactory) cf;
+      activeMQConnectionFactory.setClientID("invalid");
+      cf.createConnection();
+   }
+
+   @Test(timeout = 5000)
+   public void testValidIdSetConnection() throws Exception {
+      Connection con = cf.createConnection();
+      try {
+         con.setClientID("valid");
+         con.start();
+      } finally {
+         con.close();
+      }
+   }
+
+   @Test(timeout = 5000)
+   public void testValidClientIdSetFactory() throws Exception {
+      ActiveMQConnectionFactory activeMQConnectionFactory = (ActiveMQConnectionFactory) cf;
+      activeMQConnectionFactory.setClientID("valid");
+      Connection con = cf.createConnection();
+      try {
+         con.start();
+      } finally {
+         con.close();
+      }
+   }
+}

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[2/2] activemq-artemis git commit: This closes #1450

clebertsuconic-2
This closes #1450


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

Branch: refs/heads/master
Commit: e81c8c26d02f156e75fe03cb8cc8ad92e4bca30e
Parents: 840ff8d 64bacee
Author: Clebert Suconic <[hidden email]>
Authored: Thu Aug 10 12:28:44 2017 -0400
Committer: Clebert Suconic <[hidden email]>
Committed: Thu Aug 10 12:28:44 2017 -0400

----------------------------------------------------------------------
 .../core/ServerSessionPacketHandler.java        |  2 +
 .../client/SessionMetadataAddExceptionTest.java | 93 ++++++++++++++++++++
 2 files changed, 95 insertions(+)
----------------------------------------------------------------------


Loading...