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 2016/01/14 00:08:42 UTC
activemq git commit: https://issues.apache.org/jira/browse/AMQ-6125
Repository: activemq
Updated Branches:
refs/heads/master b9805f7ac -> 928705533
https://issues.apache.org/jira/browse/AMQ-6125
Ensure that the redelivery policy is never null in the consumer.
Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/92870553
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/92870553
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/92870553
Branch: refs/heads/master
Commit: 92870553389ef288d81c4ad670463c4fb1002c69
Parents: b9805f7
Author: Timothy Bish <ta...@gmail.com>
Authored: Wed Jan 13 18:08:18 2016 -0500
Committer: Timothy Bish <ta...@gmail.com>
Committed: Wed Jan 13 18:08:18 2016 -0500
----------------------------------------------------------------------
.../activemq/ActiveMQMessageConsumer.java | 18 ++++-
.../org/apache/activemq/bugs/AMQ6125Test.java | 77 ++++++++++++++++++++
2 files changed, 94 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq/blob/92870553/activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java b/activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java
index db9c395..3f5167f 100755
--- a/activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java
+++ b/activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java
@@ -40,7 +40,20 @@ import javax.jms.MessageListener;
import javax.jms.TransactionRolledBackException;
import org.apache.activemq.blob.BlobDownloader;
-import org.apache.activemq.command.*;
+import org.apache.activemq.command.ActiveMQBlobMessage;
+import org.apache.activemq.command.ActiveMQDestination;
+import org.apache.activemq.command.ActiveMQMessage;
+import org.apache.activemq.command.ActiveMQObjectMessage;
+import org.apache.activemq.command.ActiveMQTempDestination;
+import org.apache.activemq.command.CommandTypes;
+import org.apache.activemq.command.ConsumerId;
+import org.apache.activemq.command.ConsumerInfo;
+import org.apache.activemq.command.MessageAck;
+import org.apache.activemq.command.MessageDispatch;
+import org.apache.activemq.command.MessageId;
+import org.apache.activemq.command.MessagePull;
+import org.apache.activemq.command.RemoveInfo;
+import org.apache.activemq.command.TransactionId;
import org.apache.activemq.management.JMSConsumerStatsImpl;
import org.apache.activemq.management.StatsCapable;
import org.apache.activemq.management.StatsImpl;
@@ -199,6 +212,9 @@ public class ActiveMQMessageConsumer implements MessageAvailableConsumer, StatsC
this.session = session;
this.redeliveryPolicy = session.connection.getRedeliveryPolicyMap().getEntryFor(dest);
+ if (this.redeliveryPolicy == null) {
+ this.redeliveryPolicy = new RedeliveryPolicy();
+ }
setTransformer(session.getTransformer());
this.info = new ConsumerInfo(consumerId);
http://git-wip-us.apache.org/repos/asf/activemq/blob/92870553/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ6125Test.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ6125Test.java b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ6125Test.java
new file mode 100644
index 0000000..3b4a982
--- /dev/null
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ6125Test.java
@@ -0,0 +1,77 @@
+/**
+ * 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.assertNotNull;
+
+import javax.jms.Connection;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.broker.region.policy.RedeliveryPolicyMap;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class AMQ6125Test {
+
+ private BrokerService broker;
+
+ @Before
+ public void setUp() throws Exception {
+ broker = new BrokerService();
+ broker.setPersistent(false);
+ broker.setUseJmx(false);
+ broker.start();
+ broker.waitUntilStarted();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ if (broker != null) {
+ broker.stop();
+ broker.waitUntilStopped();
+ }
+ }
+
+ @Test
+ public void testRollbackWithNoPolicy() throws Exception {
+ ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(broker.getVmConnectorURI());
+ cf.setRedeliveryPolicyMap(new RedeliveryPolicyMap());
+ Connection connection = cf.createConnection();
+ connection.start();
+
+ Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
+ Queue queue = session.createTemporaryQueue();
+ MessageProducer producer = session.createProducer(queue);
+
+ producer.send(session.createMessage());
+ session.commit();
+
+ MessageConsumer consumer = session.createConsumer(queue);
+ Message message = consumer.receive(2000);
+
+ assertNotNull(message);
+
+ session.rollback();
+ }
+}