michaelandrepearce edited a comment on issue #2427: ARTEMIS-2170 Optimized CoreMessage's checkProperties and cleanupInternalProperties methods URL: https://github.com/apache/activemq-artemis/pull/2427#issuecomment-456125516 e.g. if you simply make a small change on master so you can get a callback, to see if its entering the if, and iterating, so you can test.... e.g. `public void cleanupInternalProperties(Consumer<Set<SimpleString>> consumer) { if (properties.hasInternalProperties()) { LinkedList<SimpleString> valuesToRemove = null; if (consumer != null) { consumer.accept(getPropertyNames()); } for (SimpleString name : getPropertyNames()) { // We use properties to establish routing context on clustering. // However if the client resends the message after receiving, it needs to be removed if ((name.startsWith(Message.HDR_ROUTE_TO_IDS) && !name.equals(Message.HDR_ROUTE_TO_IDS)) || (name.startsWith(Message.HDR_ROUTE_TO_ACK_IDS) && !name.equals(Message.HDR_ROUTE_TO_ACK_IDS))) { if (valuesToRemove == null) { valuesToRemove = new LinkedList<>(); } valuesToRemove.add(name); } } if (valuesToRemove != null) { for (SimpleString removal : valuesToRemove) { this.removeProperty(removal); } } } } ` Then run a little simple main, you can quickly see it only enters the iterating if an internal property was set. ` //This shows that we only iterate if an internal property has been set, // even if that itself is not optimised it shows that if no internal properties we avoid iterating. public static void main(String... args) { CoreMessage coreMessage = new CoreMessage(); coreMessage.checkProperties(); System.out.println("test one check empty we dont iterate"); //We should not see i got called. coreMessage.cleanupInternalProperties((s) -> System.out.println("i should NOT have been called")); System.out.println("test two, check on not using an internal property we dont iterate"); coreMessage.putStringProperty("ABC", "a"); //We should not see i got called. coreMessage.cleanupInternalProperties((s) -> System.out.println("i should NOT have been called")); System.out.println("test three, on setting an internal property, even if not one we want to remove, we iterate"); coreMessage.putStringProperty(HDR_ROUTE_TO_IDS, "a"); //We NOW should see i got called. coreMessage.cleanupInternalProperties((s) -> System.out.println("i should be called")); }`
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
