You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@artemis.apache.org by "jbertram (via GitHub)" <gi...@apache.org> on 2026/04/13 19:43:17 UTC
[PR] ARTEMIS-5997 refactor SimpleAddressManager.getMatchingQueue [artemis]
jbertram opened a new pull request, #6364:
URL: https://github.com/apache/artemis/pull/6364
The getMatchingQueue method on SimpleAddressManager is overloaded, but only one of them is actually necessary. The three-parameter version is only used once and the method that uses it has already performed all the same work.
Furthermore, the two-parameter version doesn't actually check the routing-type and the first if statement omits the wild check.
This commit:
- Removes the unnecessary version of getMatchingQueue
- Adds missing checks to the remaining getMatchingQueue
- Adds JavaDoc
- Adds tests
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@artemis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@artemis.apache.org
For additional commands, e-mail: issues-help@artemis.apache.org
Re: [PR] ARTEMIS-5997 refactor SimpleAddressManager.getMatchingQueue [artemis]
Posted by "tabish121 (via GitHub)" <gi...@apache.org>.
tabish121 commented on code in PR #6364:
URL: https://github.com/apache/artemis/pull/6364#discussion_r3081793708
##########
artemis-server/src/test/java/org/apache/activemq/artemis/core/postoffice/impl/AddressManagerGetMatchingQueueTest.java:
##########
@@ -0,0 +1,153 @@
+/*
+ * 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.core.postoffice.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.activemq.artemis.api.core.RoutingType;
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.config.WildcardConfiguration;
+import org.apache.activemq.artemis.core.postoffice.Binding;
+import org.apache.activemq.artemis.core.postoffice.Bindings;
+import org.apache.activemq.artemis.core.postoffice.BindingsFactory;
+import org.apache.activemq.artemis.core.server.Queue;
+import org.junit.jupiter.api.Test;
+
+import static org.apache.activemq.artemis.utils.RandomUtil.randomUUIDSimpleString;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class AddressManagerGetMatchingQueueTest {
+
+ @Test
+ public void testCorrectNameCorrectRoutingTypeSingleQueue() throws Exception {
+ SimpleString addressName = SimpleString.of("myAddress");
+ SimpleAddressManager am = getSimpleAddressManager();
+ am.addBinding(getLocalQueueBinding(addressName, RoutingType.ANYCAST));
+
+ assertNotNull(am.getMatchingQueue(addressName, RoutingType.ANYCAST));
+ }
+
+ @Test
+ public void testCorrectNameCorrectRoutingTypeMultipleQueues() throws Exception {
+ SimpleString addressName = SimpleString.of("myAddress");
+ SimpleAddressManager am = getSimpleAddressManager();
+ am.addBinding(getLocalQueueBinding(addressName, RoutingType.ANYCAST));
+ am.addBinding(getLocalQueueBinding(addressName, RoutingType.ANYCAST));
+
+ assertNotNull(am.getMatchingQueue(addressName, RoutingType.ANYCAST));
+ }
+
+ @Test
+ public void testCorrectNameCorrectRoutingTypeMultipleQueuesMixedRoutingTypes() throws Exception {
+ SimpleString addressName = SimpleString.of("myAddress");
+ SimpleAddressManager am = getSimpleAddressManager();
+ am.addBinding(getLocalQueueBinding(addressName, RoutingType.ANYCAST));
+ am.addBinding(getLocalQueueBinding(addressName, RoutingType.MULTICAST));
+
+ assertNotNull(am.getMatchingQueue(addressName, RoutingType.ANYCAST));
+ }
+
+ @Test
+ public void testCorrectNameIncorrectRoutingTypeSingleQueue() throws Exception {
+ SimpleString addressName = SimpleString.of("myAddress");
+ SimpleAddressManager am = getSimpleAddressManager();
+ am.addBinding(getLocalQueueBinding(addressName, RoutingType.MULTICAST));
+
+ assertNull(am.getMatchingQueue(addressName, RoutingType.ANYCAST));
Review Comment:
Similar to above, this returns nothing, but if we gave it good data would it return the thing we expect?
##########
artemis-server/src/test/java/org/apache/activemq/artemis/core/postoffice/impl/AddressManagerGetMatchingQueueTest.java:
##########
@@ -0,0 +1,153 @@
+/*
+ * 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.core.postoffice.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.activemq.artemis.api.core.RoutingType;
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.config.WildcardConfiguration;
+import org.apache.activemq.artemis.core.postoffice.Binding;
+import org.apache.activemq.artemis.core.postoffice.Bindings;
+import org.apache.activemq.artemis.core.postoffice.BindingsFactory;
+import org.apache.activemq.artemis.core.server.Queue;
+import org.junit.jupiter.api.Test;
+
+import static org.apache.activemq.artemis.utils.RandomUtil.randomUUIDSimpleString;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class AddressManagerGetMatchingQueueTest {
+
+ @Test
+ public void testCorrectNameCorrectRoutingTypeSingleQueue() throws Exception {
+ SimpleString addressName = SimpleString.of("myAddress");
+ SimpleAddressManager am = getSimpleAddressManager();
+ am.addBinding(getLocalQueueBinding(addressName, RoutingType.ANYCAST));
+
+ assertNotNull(am.getMatchingQueue(addressName, RoutingType.ANYCAST));
Review Comment:
Returning non-null isn't really checking if it returns what you expect it should, seems like these methods should be a little bit of inspection on what comes back compared to what they added to be sure its doing what it is supposed to do.
##########
artemis-server/src/test/java/org/apache/activemq/artemis/core/postoffice/impl/AddressManagerGetMatchingQueueTest.java:
##########
@@ -0,0 +1,153 @@
+/*
+ * 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.core.postoffice.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.activemq.artemis.api.core.RoutingType;
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.config.WildcardConfiguration;
+import org.apache.activemq.artemis.core.postoffice.Binding;
+import org.apache.activemq.artemis.core.postoffice.Bindings;
+import org.apache.activemq.artemis.core.postoffice.BindingsFactory;
+import org.apache.activemq.artemis.core.server.Queue;
+import org.junit.jupiter.api.Test;
+
+import static org.apache.activemq.artemis.utils.RandomUtil.randomUUIDSimpleString;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class AddressManagerGetMatchingQueueTest {
+
+ @Test
+ public void testCorrectNameCorrectRoutingTypeSingleQueue() throws Exception {
+ SimpleString addressName = SimpleString.of("myAddress");
+ SimpleAddressManager am = getSimpleAddressManager();
+ am.addBinding(getLocalQueueBinding(addressName, RoutingType.ANYCAST));
+
+ assertNotNull(am.getMatchingQueue(addressName, RoutingType.ANYCAST));
+ }
+
+ @Test
+ public void testCorrectNameCorrectRoutingTypeMultipleQueues() throws Exception {
+ SimpleString addressName = SimpleString.of("myAddress");
+ SimpleAddressManager am = getSimpleAddressManager();
+ am.addBinding(getLocalQueueBinding(addressName, RoutingType.ANYCAST));
+ am.addBinding(getLocalQueueBinding(addressName, RoutingType.ANYCAST));
+
+ assertNotNull(am.getMatchingQueue(addressName, RoutingType.ANYCAST));
+ }
+
+ @Test
+ public void testCorrectNameCorrectRoutingTypeMultipleQueuesMixedRoutingTypes() throws Exception {
+ SimpleString addressName = SimpleString.of("myAddress");
+ SimpleAddressManager am = getSimpleAddressManager();
+ am.addBinding(getLocalQueueBinding(addressName, RoutingType.ANYCAST));
+ am.addBinding(getLocalQueueBinding(addressName, RoutingType.MULTICAST));
+
+ assertNotNull(am.getMatchingQueue(addressName, RoutingType.ANYCAST));
Review Comment:
As above it might be good to validate that what it got back matches the indicated preference for routing type
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@artemis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@artemis.apache.org
For additional commands, e-mail: issues-help@artemis.apache.org
Re: [PR] ARTEMIS-5997 refactor SimpleAddressManager.getMatchingQueue [artemis]
Posted by "jbertram (via GitHub)" <gi...@apache.org>.
jbertram commented on code in PR #6364:
URL: https://github.com/apache/artemis/pull/6364#discussion_r3082119458
##########
artemis-server/src/test/java/org/apache/activemq/artemis/core/postoffice/impl/AddressManagerGetMatchingQueueTest.java:
##########
@@ -0,0 +1,153 @@
+/*
+ * 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.core.postoffice.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.activemq.artemis.api.core.RoutingType;
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.config.WildcardConfiguration;
+import org.apache.activemq.artemis.core.postoffice.Binding;
+import org.apache.activemq.artemis.core.postoffice.Bindings;
+import org.apache.activemq.artemis.core.postoffice.BindingsFactory;
+import org.apache.activemq.artemis.core.server.Queue;
+import org.junit.jupiter.api.Test;
+
+import static org.apache.activemq.artemis.utils.RandomUtil.randomUUIDSimpleString;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class AddressManagerGetMatchingQueueTest {
+
+ @Test
+ public void testCorrectNameCorrectRoutingTypeSingleQueue() throws Exception {
+ SimpleString addressName = SimpleString.of("myAddress");
+ SimpleAddressManager am = getSimpleAddressManager();
+ am.addBinding(getLocalQueueBinding(addressName, RoutingType.ANYCAST));
+
+ assertNotNull(am.getMatchingQueue(addressName, RoutingType.ANYCAST));
+ }
+
+ @Test
+ public void testCorrectNameCorrectRoutingTypeMultipleQueues() throws Exception {
+ SimpleString addressName = SimpleString.of("myAddress");
+ SimpleAddressManager am = getSimpleAddressManager();
+ am.addBinding(getLocalQueueBinding(addressName, RoutingType.ANYCAST));
+ am.addBinding(getLocalQueueBinding(addressName, RoutingType.ANYCAST));
+
+ assertNotNull(am.getMatchingQueue(addressName, RoutingType.ANYCAST));
+ }
+
+ @Test
+ public void testCorrectNameCorrectRoutingTypeMultipleQueuesMixedRoutingTypes() throws Exception {
+ SimpleString addressName = SimpleString.of("myAddress");
+ SimpleAddressManager am = getSimpleAddressManager();
+ am.addBinding(getLocalQueueBinding(addressName, RoutingType.ANYCAST));
+ am.addBinding(getLocalQueueBinding(addressName, RoutingType.MULTICAST));
+
+ assertNotNull(am.getMatchingQueue(addressName, RoutingType.ANYCAST));
+ }
+
+ @Test
+ public void testCorrectNameIncorrectRoutingTypeSingleQueue() throws Exception {
+ SimpleString addressName = SimpleString.of("myAddress");
+ SimpleAddressManager am = getSimpleAddressManager();
+ am.addBinding(getLocalQueueBinding(addressName, RoutingType.MULTICAST));
+
+ assertNull(am.getMatchingQueue(addressName, RoutingType.ANYCAST));
Review Comment:
The "good data" variation is tested by `testCorrectNameCorrectRoutingTypeSingleQueue`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@artemis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@artemis.apache.org
For additional commands, e-mail: issues-help@artemis.apache.org
Re: [PR] ARTEMIS-5997 refactor SimpleAddressManager.getMatchingQueue [artemis]
Posted by "tabish121 (via GitHub)" <gi...@apache.org>.
tabish121 merged PR #6364:
URL: https://github.com/apache/artemis/pull/6364
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@artemis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@artemis.apache.org
For additional commands, e-mail: issues-help@artemis.apache.org
Re: [PR] ARTEMIS-5997 refactor SimpleAddressManager.getMatchingQueue [artemis]
Posted by "jbertram (via GitHub)" <gi...@apache.org>.
jbertram commented on code in PR #6364:
URL: https://github.com/apache/artemis/pull/6364#discussion_r3082135269
##########
artemis-server/src/test/java/org/apache/activemq/artemis/core/postoffice/impl/AddressManagerGetMatchingQueueTest.java:
##########
@@ -0,0 +1,153 @@
+/*
+ * 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.core.postoffice.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.activemq.artemis.api.core.RoutingType;
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.config.WildcardConfiguration;
+import org.apache.activemq.artemis.core.postoffice.Binding;
+import org.apache.activemq.artemis.core.postoffice.Bindings;
+import org.apache.activemq.artemis.core.postoffice.BindingsFactory;
+import org.apache.activemq.artemis.core.server.Queue;
+import org.junit.jupiter.api.Test;
+
+import static org.apache.activemq.artemis.utils.RandomUtil.randomUUIDSimpleString;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class AddressManagerGetMatchingQueueTest {
+
+ @Test
+ public void testCorrectNameCorrectRoutingTypeSingleQueue() throws Exception {
+ SimpleString addressName = SimpleString.of("myAddress");
+ SimpleAddressManager am = getSimpleAddressManager();
+ am.addBinding(getLocalQueueBinding(addressName, RoutingType.ANYCAST));
+
+ assertNotNull(am.getMatchingQueue(addressName, RoutingType.ANYCAST));
Review Comment:
Fixed.
##########
artemis-server/src/test/java/org/apache/activemq/artemis/core/postoffice/impl/AddressManagerGetMatchingQueueTest.java:
##########
@@ -0,0 +1,153 @@
+/*
+ * 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.core.postoffice.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.activemq.artemis.api.core.RoutingType;
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.config.WildcardConfiguration;
+import org.apache.activemq.artemis.core.postoffice.Binding;
+import org.apache.activemq.artemis.core.postoffice.Bindings;
+import org.apache.activemq.artemis.core.postoffice.BindingsFactory;
+import org.apache.activemq.artemis.core.server.Queue;
+import org.junit.jupiter.api.Test;
+
+import static org.apache.activemq.artemis.utils.RandomUtil.randomUUIDSimpleString;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class AddressManagerGetMatchingQueueTest {
+
+ @Test
+ public void testCorrectNameCorrectRoutingTypeSingleQueue() throws Exception {
+ SimpleString addressName = SimpleString.of("myAddress");
+ SimpleAddressManager am = getSimpleAddressManager();
+ am.addBinding(getLocalQueueBinding(addressName, RoutingType.ANYCAST));
+
+ assertNotNull(am.getMatchingQueue(addressName, RoutingType.ANYCAST));
+ }
+
+ @Test
+ public void testCorrectNameCorrectRoutingTypeMultipleQueues() throws Exception {
+ SimpleString addressName = SimpleString.of("myAddress");
+ SimpleAddressManager am = getSimpleAddressManager();
+ am.addBinding(getLocalQueueBinding(addressName, RoutingType.ANYCAST));
+ am.addBinding(getLocalQueueBinding(addressName, RoutingType.ANYCAST));
+
+ assertNotNull(am.getMatchingQueue(addressName, RoutingType.ANYCAST));
+ }
+
+ @Test
+ public void testCorrectNameCorrectRoutingTypeMultipleQueuesMixedRoutingTypes() throws Exception {
+ SimpleString addressName = SimpleString.of("myAddress");
+ SimpleAddressManager am = getSimpleAddressManager();
+ am.addBinding(getLocalQueueBinding(addressName, RoutingType.ANYCAST));
+ am.addBinding(getLocalQueueBinding(addressName, RoutingType.MULTICAST));
+
+ assertNotNull(am.getMatchingQueue(addressName, RoutingType.ANYCAST));
Review Comment:
Fixed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@artemis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@artemis.apache.org
For additional commands, e-mail: issues-help@artemis.apache.org