ARTEMIS-3422 mitigate NPE for audit logging

This commit is contained in:
Justin Bertram 2021-08-20 14:12:43 -05:00 committed by Clebert Suconic
parent 02a8296821
commit c8d71cbebc
1 changed files with 6 additions and 2 deletions

View File

@ -1902,8 +1902,12 @@ public class QueueImpl extends CriticalComponentImpl implements Queue {
}
if (AuditLogger.isMessageLoggingEnabled()) {
ServerSession session = server.getSessionByID(consumer.getSessionID());
AuditLogger.coreAcknowledgeMessage(session.getRemotingConnection().getAuditSubject(), session.getRemotingConnection().getRemoteAddress(), getName().toString(), ref.getMessage().toString());
ServerSession session = null;
// it's possible for the consumer to be null (e.g. acking the message administratively)
if (consumer != null) {
session = server.getSessionByID(consumer.getSessionID());
}
AuditLogger.coreAcknowledgeMessage(session == null ? null : session.getRemotingConnection().getAuditSubject(), session == null ? null : session.getRemotingConnection().getRemoteAddress(), getName().toString(), ref.getMessage().toString());
}
if (server != null && server.hasBrokerMessagePlugins()) {
server.callBrokerMessagePlugins(plugin -> plugin.messageAcknowledged(ref, reason, consumer));