tabish121 commented on code in PR #4972:
URL: https://github.com/apache/activemq-artemis/pull/4972#discussion_r1636813616


##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/SimpleAddressManager.java:
##########
@@ -160,15 +172,7 @@ public Collection<Binding> getMatchingBindings(final 
SimpleString address) throw
    @Override
    public Collection<Binding> getDirectBindings(final SimpleString address) 
throws Exception {
       SimpleString realAddress = CompositeAddress.extractAddressName(address);
-      Collection<Binding> bindings = new ArrayList<>();
-
-      nameMap.forEach((bindingUniqueName, bindingAddressPair) -> {
-         if (bindingAddressPair.getA().getAddress().equals(realAddress)) {
-            bindings.add(bindingAddressPair.getA());
-         }
-      });
-
-      return bindings;
+      return new ArrayList<>(directBindingMap.getOrDefault(realAddress, 
Collections.emptyList()));

Review Comment:
   It seems rather odd to return a new ArrayList that's wrapping a potentially 
immutable empty list.  This should probably be made a bit smarter.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to