You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2013/08/07 16:05:42 UTC
svn commit: r1511321 - in /activemq/trunk:
activemq-broker/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java
activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4671Test.java
Author: tabish
Date: Wed Aug 7 14:05:42 2013
New Revision: 1511321
URL: http://svn.apache.org/r1511321
Log:
fix for: https://issues.apache.org/jira/browse/AMQ-4671
Added:
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4671Test.java (with props)
Modified:
activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java
Modified: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java?rev=1511321&r1=1511320&r2=1511321&view=diff
==============================================================================
--- activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java (original)
+++ activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java Wed Aug 7 14:05:42 2013
@@ -25,7 +25,13 @@ import org.apache.activemq.broker.Broker
import org.apache.activemq.broker.BrokerFilter;
import org.apache.activemq.broker.ConnectionContext;
import org.apache.activemq.broker.ProducerBrokerExchange;
-import org.apache.activemq.broker.region.*;
+import org.apache.activemq.broker.region.Destination;
+import org.apache.activemq.broker.region.DurableTopicSubscription;
+import org.apache.activemq.broker.region.MessageReference;
+import org.apache.activemq.broker.region.RegionBroker;
+import org.apache.activemq.broker.region.Subscription;
+import org.apache.activemq.broker.region.TopicRegion;
+import org.apache.activemq.broker.region.TopicSubscription;
import org.apache.activemq.command.*;
import org.apache.activemq.security.SecurityContext;
import org.apache.activemq.state.ProducerState;
@@ -251,9 +257,10 @@ public class AdvisoryBroker extends Brok
@Override
public void removeSubscription(ConnectionContext context, RemoveSubscriptionInfo info) throws Exception {
SubscriptionKey key = new SubscriptionKey(context.getClientId(), info.getSubscriptionName());
-
DurableTopicSubscription sub = ((TopicRegion)((RegionBroker)next).getTopicRegion()).getDurableSubscription(key);
+ super.removeSubscription(context, info);
+
if (sub == null) {
LOG.warn("We cannot send an advisory message for a durable sub removal when we don't know about the durable sub");
return;
@@ -261,8 +268,6 @@ public class AdvisoryBroker extends Brok
ActiveMQDestination dest = sub.getConsumerInfo().getDestination();
- super.removeSubscription(context, info);
-
// Don't advise advisory topics.
if (!AdvisorySupport.isAdvisoryTopic(dest)) {
ActiveMQTopic topic = AdvisorySupport.getConsumerAdvisoryTopic(dest);
Added: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4671Test.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4671Test.java?rev=1511321&view=auto
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4671Test.java (added)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4671Test.java Wed Aug 7 14:05:42 2013
@@ -0,0 +1,81 @@
+/**
+ * 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.bugs;
+
+import static org.junit.Assert.fail;
+
+import javax.jms.Connection;
+import javax.jms.Session;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.broker.BrokerService;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AMQ4671Test {
+
+ private static final transient Logger LOG = LoggerFactory.getLogger(AMQ4671Test.class);
+ private static BrokerService brokerService;
+ private static String BROKER_ADDRESS = "tcp://localhost:0";
+
+ private String connectionUri;
+
+ @Before
+ public void setUp() throws Exception {
+ brokerService = new BrokerService();
+ brokerService.setPersistent(false);
+ brokerService.setUseJmx(true);
+ brokerService.setDeleteAllMessagesOnStartup(true);
+ connectionUri = brokerService.addConnector(BROKER_ADDRESS).getPublishableConnectString();
+ connectionUri = connectionUri + "?trace=true";
+ brokerService.start();
+ brokerService.waitUntilStarted();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ brokerService.stop();
+ brokerService.waitUntilStopped();
+ }
+
+ @Test
+ public void testNonDurableSubscriberInvalidUnsubscribe() throws Exception {
+ ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(connectionUri);
+
+ Connection connection = connectionFactory.createConnection();
+ connection.setClientID(getClass().getName());
+ connection.start();
+
+ try {
+ Session ts = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ try {
+ ts.unsubscribe("invalid-subscription-name");
+ fail("this should fail");
+ } catch (javax.jms.InvalidDestinationException e) {
+ LOG.info("Test caught correct invalid destination exception");
+ }
+ } finally {
+ if (connection != null) {
+ connection.close();
+ }
+ }
+ }
+}
Propchange: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4671Test.java
------------------------------------------------------------------------------
svn:eol-style = native