ARTEMIS-4056 Fixing compatibility with getFirstMessage()

if Empty the previous method was returning new Map[1] and the JSON output would be slightly different and I am playing safe here just in case.
This commit is contained in:
Clebert Suconic 2022-10-18 13:42:12 -04:00
parent 77ad2b0bc0
commit 51c50d8546
1 changed files with 3 additions and 2 deletions

View File

@ -888,7 +888,6 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
clearIO();
try {
List<Map<String, Object>> messages = new ArrayList<>();
final int attributeSizeLimit = addressSettingsRepository.getMatch(address).getManagementMessageAttributeSizeLimit();
MessageReference firstMessage = queue.peekFirstMessage();
if (firstMessage != null) {
@ -908,7 +907,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
AuditLogger.getFirstMessageAsJSON(queue);
}
Map<String, Object> message = getFirstMessage();
return toJSON(message == null ? new Map[0] : new Map[]{message});
// I"m returning a new Map[1] in case of no first message, because older versions used to return that when null
// and I'm playing safe with the compatibility here.
return toJSON(message == null ? new Map[1] : new Map[]{message});
}
@Override