Skip to content

ARTEMIS-5997 refactor SimpleAddressManager.getMatchingQueue#6364

Merged
tabish121 merged 1 commit intoapache:mainfrom
jbertram:ARTEMIS-5997
Apr 14, 2026
Merged

ARTEMIS-5997 refactor SimpleAddressManager.getMatchingQueue#6364
tabish121 merged 1 commit intoapache:mainfrom
jbertram:ARTEMIS-5997

Conversation

@jbertram
Copy link
Copy Markdown
Contributor

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

SimpleAddressManager am = getSimpleAddressManager();
am.addBinding(getLocalQueueBinding(addressName, RoutingType.ANYCAST));

assertNotNull(am.getMatchingQueue(addressName, RoutingType.ANYCAST));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

am.addBinding(getLocalQueueBinding(addressName, RoutingType.ANYCAST));
am.addBinding(getLocalQueueBinding(addressName, RoutingType.MULTICAST));

assertNotNull(am.getMatchingQueue(addressName, RoutingType.ANYCAST));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above it might be good to validate that what it got back matches the indicated preference for routing type

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

SimpleAddressManager am = getSimpleAddressManager();
am.addBinding(getLocalQueueBinding(addressName, RoutingType.MULTICAST));

assertNull(am.getMatchingQueue(addressName, RoutingType.ANYCAST));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to above, this returns nothing, but if we gave it good data would it return the thing we expect?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "good data" variation is tested by testCorrectNameCorrectRoutingTypeSingleQueue.

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
@tabish121 tabish121 merged commit 93eaead into apache:main Apr 14, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants