activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject [1/2] activemq git commit: https://issues.apache.org/jira/browse/AMQ-5816
Date Mon, 01 Jun 2015 22:09:38 GMT
Repository: activemq
Updated Branches:
  refs/heads/master 8095d8eab -> 73e8d1098


https://issues.apache.org/jira/browse/AMQ-5816

Apply patch from Ievgen Tarasov that ensures that the data locator is
initialized when a MessageId is deserialized.  

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

Branch: refs/heads/master
Commit: df06bdabdc0e9f892449e0ef0d8783aea6047802
Parents: 8095d8e
Author: Timothy Bish <tabish121@gmail.com>
Authored: Mon Jun 1 17:50:20 2015 -0400
Committer: Timothy Bish <tabish121@gmail.com>
Committed: Mon Jun 1 17:50:20 2015 -0400

----------------------------------------------------------------------
 .../org/apache/activemq/command/MessageId.java  |   5 +
 .../org/apache/activemq/bugs/AMQ5816Test.java   | 122 +++++++++++++++++++
 2 files changed, 127 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/df06bdab/activemq-client/src/main/java/org/apache/activemq/command/MessageId.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/command/MessageId.java b/activemq-client/src/main/java/org/apache/activemq/command/MessageId.java
index de8cc12..71319b2 100755
--- a/activemq-client/src/main/java/org/apache/activemq/command/MessageId.java
+++ b/activemq-client/src/main/java/org/apache/activemq/command/MessageId.java
@@ -244,4 +244,9 @@ public class MessageId implements DataStructure, Comparable<MessageId>
{
     public void setPlistLocator(Object plistLocator) {
         this.plistLocator = plistLocator;
     }
+
+    private Object readResolve() {
+        dataLocator = new AtomicReference<Object>();
+        return this;
+    }
 }

http://git-wip-us.apache.org/repos/asf/activemq/blob/df06bdab/activemq-http/src/test/java/org/apache/activemq/bugs/AMQ5816Test.java
----------------------------------------------------------------------
diff --git a/activemq-http/src/test/java/org/apache/activemq/bugs/AMQ5816Test.java b/activemq-http/src/test/java/org/apache/activemq/bugs/AMQ5816Test.java
new file mode 100644
index 0000000..5e28195
--- /dev/null
+++ b/activemq-http/src/test/java/org/apache/activemq/bugs/AMQ5816Test.java
@@ -0,0 +1,122 @@
+/**
+ * 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 java.io.File;
+import java.io.IOException;
+import java.net.ServerSocket;
+
+import javax.jms.Connection;
+import javax.jms.DeliveryMode;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.net.ServerSocketFactory;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.broker.TransportConnector;
+import org.apache.activemq.leveldb.LevelDBStore;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestName;
+
+public class AMQ5816Test {
+
+    private static BrokerService brokerService;
+
+    @Rule public TestName name = new TestName();
+
+    private File dataDirFile;
+    private String connectionURI;
+
+    @Before
+    public void setUp() throws Exception {
+
+        dataDirFile = new File("target/" + name.getMethodName());
+
+        brokerService = new BrokerService();
+        brokerService.setBrokerName("LevelDBBroker");
+        brokerService.setPersistent(true);
+        brokerService.setUseJmx(false);
+        brokerService.setAdvisorySupport(false);
+        brokerService.setDeleteAllMessagesOnStartup(true);
+        brokerService.setDataDirectoryFile(dataDirFile);
+
+        TransportConnector connector = brokerService.addConnector("http://0.0.0.0:" + getFreePort());
+
+        LevelDBStore persistenceFactory = new LevelDBStore();
+        persistenceFactory.setDirectory(dataDirFile);
+        brokerService.setPersistenceAdapter(persistenceFactory);
+        brokerService.start();
+        brokerService.waitUntilStarted();
+
+        connectionURI = connector.getPublishableConnectString();
+    }
+
+    /**
+     * @throws java.lang.Exception
+     */
+    @After
+    public void tearDown() throws Exception {
+        brokerService.stop();
+        brokerService.waitUntilStopped();
+    }
+
+    @Test
+    public void testSendPersistentMessage() throws JMSException {
+        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(connectionURI);
+        Connection connection = factory.createConnection();
+        connection.start();
+
+        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        Queue queue = session.createQueue(name.getMethodName());
+        MessageProducer producer = session.createProducer(queue);
+        MessageConsumer consumer = session.createConsumer(queue);
+
+        producer.setDeliveryMode(DeliveryMode.PERSISTENT);
+        producer.send(session.createTextMessage());
+
+        assertNotNull(consumer.receive(5000));
+    }
+
+    protected int getFreePort() {
+        int port = 8161;
+        ServerSocket ss = null;
+
+        try {
+            ss = ServerSocketFactory.getDefault().createServerSocket(0);
+            port = ss.getLocalPort();
+        } catch (IOException e) { // ignore
+        } finally {
+            try {
+                if (ss != null ) {
+                    ss.close();
+                }
+            } catch (IOException e) { // ignore
+            }
+        }
+
+        return port;
+    }
+}


Mime
View raw message