clebertsuconic commented on code in PR #4260:
URL: https://github.com/apache/activemq-artemis/pull/4260#discussion_r998288788


##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java:
##########
@@ -883,17 +883,12 @@ protected Map<String, Object>[] getFirstMessage() throws 
Exception {
       clearIO();
       try {
          List<Map<String, Object>> messages = new ArrayList<>();
-         queue.flushExecutor();
          final int attributeSizeLimit = 
addressSettingsRepository.getMatch(address).getManagementMessageAttributeSizeLimit();
-         try (LinkedListIterator<MessageReference> iterator = 
queue.browserIterator()) {
-            // returns just the first, as it's the first only
-            if (iterator.hasNext()) {
-               MessageReference ref = iterator.next();
-               Message message = ref.getMessage();
-               messages.add(message.toMap(attributeSizeLimit));
-            }
-            return messages.toArray(new Map[1]);
+         MessageReference firstMessage = queue.peekFirstMessage();
+         if (firstMessage != null) {
+            messages.add(firstMessage.getMessage().toMap(attributeSizeLimit));
          }
+         return messages.toArray(new Map[1]);

Review Comment:
   it makes sense... after reading what it does.. 
   
   I was just getting rid of the iterator() which caused an outage on an user I 
was helping out.
   
   But I will improve that part as well.. thanks



-- 
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]

Reply via email to