From: jsimomaa Date: Tue, 9 Jan 2018 12:51:02 +0000 (+0200) Subject: Minor NPE fix for auditlogging X-Git-Tag: v1.43.0~136^2~628 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F65%2F1365%2F1;p=simantics%2Fplatform.git Minor NPE fix for auditlogging refs #7684 Change-Id: I86f892bf133b1965d9631ce82ddf02b78ec88a5a --- 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;