diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java index d93af438bb..915c2e7c70 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java @@ -997,8 +997,13 @@ public final class FileConfigurationParser extends XMLConfigurationUtil { Element node = (Element) elements.item(0); NodeList list = node.getElementsByTagName("address-setting"); for (int i = 0; i < list.getLength(); i++) { - Pair addressSettings = parseAddressSettings(list.item(i)); - config.getAddressesSettings().put(addressSettings.getA(), addressSettings.getB()); + Pair newAddressSettings = parseAddressSettings(list.item(i)); + Map addressSettings = config.getAddressesSettings(); + if (addressSettings.containsKey(newAddressSettings.getA())) { + ActiveMQServerLogger.LOGGER.duplicateAddressSettingMatch(newAddressSettings.getA()); + } else { + config.getAddressesSettings().put(newAddressSettings.getA(), newAddressSettings.getB()); + } } } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java index 59a4917cc6..03add71e45 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java @@ -1730,6 +1730,11 @@ public interface ActiveMQServerLogger extends BasicLogger { format = Message.Format.MESSAGE_FORMAT) void gettingSslHandlerFailed(String clientAddress, String cause); + @LogMessage(level = Logger.Level.WARN) + @Message(id = 222301, value = "Duplicate address-setting match found: {0}. These settings will be ignored! Please review your broker.xml and consolidate any duplicate address-setting elements.", + format = Message.Format.MESSAGE_FORMAT) + void duplicateAddressSettingMatch(String match); + @LogMessage(level = Logger.Level.ERROR) @Message(id = 224000, value = "Failure in initialisation", format = Message.Format.MESSAGE_FORMAT) void initializationError(@Cause Throwable e); diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationParserTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationParserTest.java index a4b0938b10..6ee93210a0 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationParserTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationParserTest.java @@ -38,6 +38,7 @@ import org.apache.activemq.artemis.core.deployers.impl.FileConfigurationParser; 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.apache.activemq.artemis.utils.ClassloadingUtil; import org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec; import org.apache.activemq.artemis.utils.PasswordMaskingUtil; import org.apache.activemq.artemis.utils.StringPrintStream; @@ -95,6 +96,14 @@ public class FileConfigurationParserTest extends ActiveMQTestBase { assertEquals(0, server.locateQueue(SimpleString.toSimpleString("q")).getMaxConsumers()); } + @Test + public void testDuplicateAddressSettings() throws Exception { + FileConfigurationParser parser = new FileConfigurationParser(); + Configuration config = parser.parseMainConfig(ClassloadingUtil.findResource("FileConfigurationParser-duplicateAddressSettings.xml").openStream()); + + Assert.assertEquals(123, config.getAddressesSettings().get("foo").getRedistributionDelay()); + } + @Test public void testParsingClusterConnectionURIs() throws Exception { FileConfigurationParser parser = new FileConfigurationParser(); diff --git a/artemis-server/src/test/resources/FileConfigurationParser-duplicateAddressSettings.xml b/artemis-server/src/test/resources/FileConfigurationParser-duplicateAddressSettings.xml new file mode 100644 index 0000000000..04619e97c6 --- /dev/null +++ b/artemis-server/src/test/resources/FileConfigurationParser-duplicateAddressSettings.xml @@ -0,0 +1,31 @@ + + + + false + + + 123 + + + 456 + + + +