Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6848417E60 for ; Mon, 1 Jun 2015 22:09:38 +0000 (UTC) Received: (qmail 43278 invoked by uid 500); 1 Jun 2015 22:09:38 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 43233 invoked by uid 500); 1 Jun 2015 22:09:38 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 43222 invoked by uid 99); 1 Jun 2015 22:09:38 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Jun 2015 22:09:38 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 35DE3E0593; Mon, 1 Jun 2015 22:09:38 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tabish@apache.org To: commits@activemq.apache.org Date: Mon, 01 Jun 2015 22:09:38 -0000 Message-Id: <8ad2eb2a874647b7998cc9f25aa505a1@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] activemq git commit: https://issues.apache.org/jira/browse/AMQ-5816 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 Authored: Mon Jun 1 17:50:20 2015 -0400 Committer: Timothy Bish 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 { public void setPlistLocator(Object plistLocator) { this.plistLocator = plistLocator; } + + private Object readResolve() { + dataLocator = new AtomicReference(); + 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; + } +}