activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [2/3] activemq-artemis git commit: ARTEMIS-825 - Invalid selector not handled correctly in AMQP
Date Mon, 21 Nov 2016 16:25:12 GMT
ARTEMIS-825 - Invalid selector not handled correctly in AMQP

this changes propogates the error to the client and closes the sender correctly

https://issues.apache.org/jira/browse/ARTEMIS-825


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

Branch: refs/heads/master
Commit: 6628db48927d404c2f259694fb84a35031f4f927
Parents: 329c533
Author: Andy Taylor <andy.tayls67@gmail.com>
Authored: Wed Oct 26 09:18:54 2016 +0100
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Mon Nov 21 11:24:51 2016 -0500

----------------------------------------------------------------------
 .../amqp/proton/ProtonServerSenderContext.java  |  7 +++++--
 .../integration/amqp/AmqpSendReceiveTest.java   | 20 ++++++++++++++++++++
 2 files changed, 25 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6628db48/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java
b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java
index ef075fc..960942d 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java
@@ -20,6 +20,7 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Objects;
 
+import org.apache.activemq.artemis.api.core.ActiveMQExceptionType;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.server.QueueQueryResult;
 import org.apache.activemq.artemis.core.transaction.Transaction;
@@ -140,8 +141,7 @@ public class ProtonServerSenderContext extends ProtonInitializable implements
Pr
             try {
                SelectorParser.parse(selector);
             } catch (FilterException e) {
-               close(new ErrorCondition(AmqpError.INVALID_FIELD, e.getMessage()));
-               return;
+               throw new ActiveMQAMQPException(AmqpError.INVALID_FIELD, "Invalid filter",
ActiveMQExceptionType.INVALID_FILTER_EXPRESSION);
             }
 
             supportedFilters.put(filter.getKey(), filter.getValue());
@@ -313,6 +313,9 @@ public class ProtonServerSenderContext extends ProtonInitializable implements
Pr
    @Override
    public void close(ErrorCondition condition) throws ActiveMQAMQPException {
       closed = true;
+      if (condition != null) {
+         sender.setCondition(condition);
+      }
       protonSession.removeSender(sender);
       synchronized (connection.getLock()) {
          sender.close();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6628db48/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpSendReceiveTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpSendReceiveTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpSendReceiveTest.java
index 6c50b86..aae2650 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpSendReceiveTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpSendReceiveTest.java
@@ -45,6 +45,8 @@ import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.jms.JMSException;
+
 /**
  * Test basic send and receive scenarios using only AMQP sender and receiver links.
  */
@@ -133,6 +135,24 @@ public class AmqpSendReceiveTest extends AmqpClientTestSupport {
    }
 
    @Test(timeout = 60000)
+   public void testInvalidFilter() throws Exception {
+      AmqpClient client = createAmqpClient();
+
+      AmqpConnection connection = addConnection(client.connect());
+      AmqpSession session = connection.createSession();
+
+      try {
+         session.createReceiver(getTestName(), "null = 'f''", true);
+         fail("should throw exception");
+      } catch (Exception e) {
+         assertTrue(e.getCause() instanceof JMSException);
+         //passed
+      }
+
+      connection.close();
+   }
+
+   @Test(timeout = 60000)
    public void testQueueReceiverReadMessage() throws Exception {
       sendMessages(getTestName(), 1);
 


Mime
View raw message