From 612c2fe9c3f252deb5322c6b168f72c95f27e3aa Mon Sep 17 00:00:00 2001 From: rusher Date: Tue, 9 Jul 2019 15:08:07 +0200 Subject: [PATCH] [CONJ-716] correcting possible NPE when logging information --- .../mariadb/jdbc/internal/logging/ProtocolLoggingProxy.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/mariadb/jdbc/internal/logging/ProtocolLoggingProxy.java b/src/main/java/org/mariadb/jdbc/internal/logging/ProtocolLoggingProxy.java index 03bd93e8..fbf70905 100644 --- a/src/main/java/org/mariadb/jdbc/internal/logging/ProtocolLoggingProxy.java +++ b/src/main/java/org/mariadb/jdbc/internal/logging/ProtocolLoggingProxy.java @@ -69,8 +69,8 @@ import org.mariadb.jdbc.internal.util.dao.ServerPrepareResult; public class ProtocolLoggingProxy implements InvocationHandler { - private static final NumberFormat numberFormat = DecimalFormat.getInstance(); private static final Logger logger = LoggerFactory.getLogger(ProtocolLoggingProxy.class); + private final NumberFormat numberFormat; private final boolean profileSql; private final Long slowQueryThresholdNanos; private final int maxQuerySizeToLog; @@ -89,11 +89,11 @@ public class ProtocolLoggingProxy implements InvocationHandler { this.slowQueryThresholdNanos = options.slowQueryThresholdNanos; this.maxQuerySizeToLog = options.maxQuerySizeToLog; this.logQuery = new LogQueryTool(options); + this.numberFormat = DecimalFormat.getInstance(); } @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - long startTime = System.nanoTime(); try { switch (method.getName()) { @@ -104,6 +104,7 @@ public class ProtocolLoggingProxy implements InvocationHandler { case "executeBatchClient": case "executeBatchServer": + final long startTime = System.nanoTime(); Object returnObj = method.invoke(protocol, args); if (logger.isInfoEnabled() && (profileSql || (slowQueryThresholdNanos != null