Copilot commented on code in PR #1668:
URL: https://github.com/apache/activemq/pull/1668#discussion_r2799305150
##########
activemq-unit-tests/src/test/java/org/apache/activemq/usecases/AdvisoryViaNetworkTest.java:
##########
@@ -270,18 +272,27 @@ public void testPrefetchSizePercent() throws Exception {
createConsumer("A", new ActiveMQTopic("A.FOO"));
}
- assertDeqInflight(7, 3);
+ assertDeqInflight(7, 3, new ActiveMQTopic("A.FOO"));
}
- private void assertDeqInflight(final int dequeue, final int inflight)
throws Exception {
+ private void assertDeqInflight(final int dequeue, final int inflight,
+ final ActiveMQTopic... topics) throws
Exception {
assertTrue("deq and inflight as expected", Wait.waitFor(new
Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
- RegionBroker regionBroker = (RegionBroker)
brokers.get("A").broker.getRegionBroker();
- LOG.info("A Deq:" +
regionBroker.getDestinationStatistics().getDequeues().getCount());
- LOG.info("A Inflight:" +
regionBroker.getDestinationStatistics().getInflight().getCount());
- return
regionBroker.getDestinationStatistics().getDequeues().getCount() == dequeue
- &&
regionBroker.getDestinationStatistics().getInflight().getCount() == inflight;
+ long actualDeq = 0;
+ long actualInflight = 0;
+ for (ActiveMQTopic topic : topics) {
+ ActiveMQTopic advisory =
AdvisorySupport.getConsumerAdvisoryTopic(topic);
+ Destination destination =
brokers.get("A").broker.getDestination(advisory);
Review Comment:
`BrokerService#getDestination(...)` lazily creates the destination (it calls
`addDestination`), so this assertion helper can still mutate broker state while
waiting. To avoid side effects in the assert, lookup the advisory destination
via the region broker’s existing destination map (e.g., `((RegionBroker)
broker.getRegionBroker()).getDestinationMap().get(advisory)`) rather than
calling `broker.getDestination(advisory)`.
```suggestion
RegionBroker regionBroker = (RegionBroker)
brokers.get("A").broker.getRegionBroker();
Destination destination =
regionBroker.getDestinationMap().get(advisory);
```
--
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