From 96f2770332993854b7afc71d9d9902c538f911b4 Mon Sep 17 00:00:00 2001 From: jsimomaa Date: Tue, 9 Jan 2018 14:51:02 +0200 Subject: [PATCH] Minor NPE fix for auditlogging refs #7684 Change-Id: I86f892bf133b1965d9631ce82ddf02b78ec88a5a (cherry picked from commit aaa0aa90d9fdfc8350e36da4e0629c3f5916f68c) --- .../simantics/audit/client/AuditLoggingClient.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bundles/org.simantics.auditlogging/src/org/simantics/audit/client/AuditLoggingClient.java b/bundles/org.simantics.auditlogging/src/org/simantics/audit/client/AuditLoggingClient.java index 63045fdcf..e9043187d 100644 --- a/bundles/org.simantics.auditlogging/src/org/simantics/audit/client/AuditLoggingClient.java +++ b/bundles/org.simantics.auditlogging/src/org/simantics/audit/client/AuditLoggingClient.java @@ -91,21 +91,22 @@ public class AuditLoggingClient { private static void commit(Level level, Map message) throws AuditLoggingException { try { - AuditLoggingAPIClient client = fromEnv().apiClient; - if (client == null) { + AuditLoggingClient client = fromEnv(); + if (client == null || client.apiClient == null) { // No can do - at least log to file LOGGER.warn("Audit logging server not configured - printing event to log"); LOGGER.info(message.toString()); } else { + AuditLoggingAPIClient apiClient = client.apiClient; switch (level) { case INFO: - client.log(message); + apiClient.log(message); break; case ERROR: - client.error(message); + apiClient.error(message); break; case TRACE: - client.trace(message); + apiClient.trace(message); break; default: break; -- 2.47.1