Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 42A66200BB8 for ; Sat, 8 Oct 2016 00:52:02 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 414A6160AE9; Fri, 7 Oct 2016 22:52:02 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 5C1CE160AE8 for ; Sat, 8 Oct 2016 00:52:01 +0200 (CEST) Received: (qmail 83888 invoked by uid 500); 7 Oct 2016 22:52:00 -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 83874 invoked by uid 99); 7 Oct 2016 22:52:00 -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; Fri, 07 Oct 2016 22:52:00 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 65ACEDFB81; Fri, 7 Oct 2016 22:52:00 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: clebertsuconic@apache.org To: commits@activemq.apache.org Date: Fri, 07 Oct 2016 22:52:00 -0000 Message-Id: <5a3135bbb0e04dd0abdc34c9e94cb857@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] activemq-artemis git commit: ARTEMIS-761 fix possible dup journal record ID archived-at: Fri, 07 Oct 2016 22:52:02 -0000 Repository: activemq-artemis Updated Branches: refs/heads/master ca2bf0ed8 -> de746a762 ARTEMIS-761 fix possible dup journal record ID Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/c47a9a5f Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/c47a9a5f Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/c47a9a5f Branch: refs/heads/master Commit: c47a9a5f802888443638c3bbb9aec769a6bf2e1d Parents: ca2bf0e Author: jbertram Authored: Tue Oct 4 10:34:00 2016 -0500 Committer: Clebert Suconic Committed: Fri Oct 7 18:50:44 2016 -0400 ---------------------------------------------------------------------- .../impl/journal/BatchingIDGenerator.java | 2 +- .../journal/DuplicateRecordIdTest.java | 54 ++++++++++++++++++++ .../RolesConfigurationStorageTest.java | 27 ++++++++++ .../impl/BatchIDGeneratorUnitTest.java | 2 +- 4 files changed, 83 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/c47a9a5f/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/BatchingIDGenerator.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/BatchingIDGenerator.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/BatchingIDGenerator.java index c61bf64..694cb2a 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/BatchingIDGenerator.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/BatchingIDGenerator.java @@ -90,7 +90,7 @@ public final class BatchingIDGenerator implements IDGenerator { encoding.decode(buffer); // Keep nextID and counter the same, the next generateID will update the checkpoint - nextID = encoding.id; + nextID = encoding.id + 1; counter.set(nextID); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/c47a9a5f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/DuplicateRecordIdTest.java ---------------------------------------------------------------------- diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/DuplicateRecordIdTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/DuplicateRecordIdTest.java new file mode 100644 index 0000000..7d89e2c --- /dev/null +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/DuplicateRecordIdTest.java @@ -0,0 +1,54 @@ +/* + * 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.artemis.tests.integration.journal; + +import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl; +import org.apache.activemq.artemis.api.core.management.AddressSettingsInfo; +import org.apache.activemq.artemis.cli.commands.tools.PrintData; +import org.apache.activemq.artemis.core.server.ActiveMQServer; +import org.apache.activemq.artemis.core.settings.impl.AddressSettings; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.junit.Before; +import org.junit.Test; + +public class DuplicateRecordIdTest extends ActiveMQTestBase { + + protected ActiveMQServer server; + + @Override + @Before + public void setUp() throws Exception { + super.setUp(); + server = createServer(false, createDefaultInVMConfig().addAddressesSetting("#", new AddressSettings().setDeadLetterAddress(new SimpleString("dlq")).setExpiryAddress(new SimpleString("dlq")))); + server.getConfiguration().setPersistenceEnabled(true); + } + + @Test + public void testDuplicateRecordId() throws Exception { + for (int i = 0; i < 3; i++) { + server.start(); + ActiveMQServerControl serverControl = server.getActiveMQServerControl(); + serverControl.removeAddressSettings("q"); + AddressSettingsInfo defaultSettings = AddressSettingsInfo.from(serverControl.getAddressSettingsAsJSON("#")); + serverControl.addAddressSettings("q", "dlq", defaultSettings.getExpiryAddress(), -1, false, 1, defaultSettings.getMaxSizeBytes(), defaultSettings.getPageSizeBytes(), defaultSettings.getPageCacheMaxSize(), defaultSettings.getRedeliveryDelay(), defaultSettings.getRedeliveryMultiplier(), defaultSettings.getMaxRedeliveryDelay(), defaultSettings.getRedistributionDelay(), defaultSettings.isSendToDLAOnNoRoute(), defaultSettings.getAddressFullMessagePolicy(), defaultSettings.getSlowConsumerThreshold(), defaultSettings.getSlowConsumerCheckPeriod(), defaultSettings.getSlowConsumerPolicy(), defaultSettings.isAutoCreateJmsQueues(), defaultSettings.isAutoDeleteJmsQueues(), defaultSettings.isAutoCreateJmsTopics(), defaultSettings.isAutoDeleteJmsTopics()); + server.stop(); + PrintData.printData(server.getConfiguration().getBindingsLocation().getAbsoluteFile(), server.getConfiguration().getJournalLocation().getAbsoluteFile(), server.getConfiguration().getPagingLocation().getAbsoluteFile()); + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/c47a9a5f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/RolesConfigurationStorageTest.java ---------------------------------------------------------------------- diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/RolesConfigurationStorageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/RolesConfigurationStorageTest.java index 655c500..6a1adda 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/RolesConfigurationStorageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/RolesConfigurationStorageTest.java @@ -80,6 +80,33 @@ public class RolesConfigurationStorageTest extends StorageManagerTestBase { } + @Test + public void testStoreSecuritySettings2() throws Exception { + createStorage(); + + checkSettings(); + + journal.stop(); + + createStorage(); + + checkSettings(); + + addSetting(new PersistedRoles("a#", "a1", "a1", "a1", "a1", "a1", "a1", "a1", "a1")); + + journal.stop(); + + createStorage(); + + checkSettings(); + + journal.stop(); + + createStorage(); + + checkSettings(); + } + /** * @param journal * @throws Exception http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/c47a9a5f/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/persistence/impl/BatchIDGeneratorUnitTest.java ---------------------------------------------------------------------- diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/persistence/impl/BatchIDGeneratorUnitTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/persistence/impl/BatchIDGeneratorUnitTest.java index 4b380ce..4c87e47 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/persistence/impl/BatchIDGeneratorUnitTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/persistence/impl/BatchIDGeneratorUnitTest.java @@ -57,7 +57,7 @@ public class BatchIDGeneratorUnitTest extends ActiveMQTestBase { long id3 = batch.generateID(); - Assert.assertEquals(1000, id3); + Assert.assertEquals(1001, id3); long id4 = batch.generateID();