This is an automated email from the ASF dual-hosted git repository.

michaelpearce pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git

commit e595b7ca169c0eaa3c5ebd10d102e4252685d201
Author: Clebert Suconic <clebertsuco...@apache.org>
AuthorDate: Fri Jan 25 13:27:53 2019 -0500

    ARTEMIS-2238 Enhancement to queueQuery on producer
    
    this is an adjustment on top of 33f56c81bdefa3492f722a67b5282b527545886c
---
 .../artemis/jms/client/ActiveMQMessageProducer.java        | 14 +++++++-------
 .../integration/client/AutoCreateJmsDestinationTest.java   |  3 +--
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git 
a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageProducer.java
 
b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageProducer.java
index e1d71f3..ccc5d7c 100644
--- 
a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageProducer.java
+++ 
b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageProducer.java
@@ -395,18 +395,20 @@ public class ActiveMQMessageProducer implements 
MessageProducer, QueueSender, To
          if (defaultDestination == null) {
             throw new UnsupportedOperationException("Destination must be 
specified on send with an anonymous producer");
          }
+
          destination = defaultDestination;
-      } else if (defaultDestination != null) {
-         if (!destination.equals(defaultDestination)) {
+         // address is meant to be null on this case, as it will use the 
coreProducer's default address
+      } else {
+         if (defaultDestination != null && 
!destination.equals(defaultDestination)) {
+            // This is a JMS TCK & Rule Definition.
+            // if you specified a destination on the Producer, you cannot use 
it for a different destinations.
             throw new UnsupportedOperationException("Where a default 
destination is specified " + "for the sender and a destination is " + 
"specified in the arguments to the send, " + "these destinations must be 
equal");
          }
-      } else {
-         session.checkDestination(destination);
 
+         session.checkDestination(destination);
          address = destination.getSimpleAddress();
       }
 
-
       ActiveMQMessage activeMQJmsMessage;
 
       boolean foreign = false;
@@ -496,8 +498,6 @@ public class ActiveMQMessageProducer implements 
MessageProducer, QueueSender, To
       }
    }
 
-
-
    private void checkClosed() throws JMSException {
       if (clientProducer.isClosed()) {
          throw new IllegalStateException("Producer is closed");
diff --git 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AutoCreateJmsDestinationTest.java
 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AutoCreateJmsDestinationTest.java
index a7a7a87..f32c6fe 100644
--- 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AutoCreateJmsDestinationTest.java
+++ 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AutoCreateJmsDestinationTest.java
@@ -27,7 +27,6 @@ import javax.jms.Session;
 import javax.jms.TextMessage;
 import javax.jms.Topic;
 import java.util.HashSet;
-import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
 
@@ -363,7 +362,7 @@ public class AutoCreateJmsDestinationTest extends 
JMSTestBase {
       server.getAddressSettingsRepository().addMatch("#", settings);
 
       ConnectionFactory factory = cf;
-      try(Connection connection = factory.createConnection()) {
+      try (Connection connection = factory.createConnection()) {
          SimpleString addressName = 
UUIDGenerator.getInstance().generateSimpleStringUUID();
          clientSession.createAddress(addressName, RoutingType.ANYCAST, true); 
// this will force the system to create the address only
          javax.jms.Queue queue = new ActiveMQQueue(addressName.toString());

Reply via email to