Repository: phoenix Updated Branches: refs/heads/4.x-HBase-1.3 cc0de5d27 -> 7f9166522
PHOENIX-4733 NPE while running sql through file using psql Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/7f916652 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/7f916652 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/7f916652 Branch: refs/heads/4.x-HBase-1.3 Commit: 7f916652298da0a7e4bca9c29a96f01000636e57 Parents: cc0de5d Author: Ankit Singhal <ankitsingha...@gmail.com> Authored: Wed May 9 14:11:29 2018 -0700 Committer: Ankit Singhal <ankitsingha...@gmail.com> Committed: Wed May 9 14:11:29 2018 -0700 ---------------------------------------------------------------------- .../org/apache/phoenix/log/QueryLoggerUtil.java | 24 ++++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/7f916652/phoenix-core/src/main/java/org/apache/phoenix/log/QueryLoggerUtil.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/log/QueryLoggerUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/log/QueryLoggerUtil.java index 2f22931..d5c4878 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/log/QueryLoggerUtil.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/log/QueryLoggerUtil.java @@ -30,10 +30,14 @@ import com.google.common.collect.ImmutableMap.Builder; public class QueryLoggerUtil { - public static void logInitialDetails(QueryLogger queryLogger, PName tenantId, - ConnectionQueryServices queryServices, String query, long startTime, List<Object> bindParameters) { - queryLogger.log(QueryLogState.STARTED, - getInitialDetails(tenantId, queryServices, query, startTime, bindParameters)); + public static void logInitialDetails(QueryLogger queryLogger, PName tenantId, ConnectionQueryServices queryServices, + String query, long startTime, List<Object> bindParameters) { + try { + queryLogger.log(QueryLogState.STARTED, + getInitialDetails(tenantId, queryServices, query, startTime, bindParameters)); + } catch (Exception e) { + // Ignore for now + } } @@ -46,15 +50,21 @@ public class QueryLoggerUtil { } catch (UnknownHostException e) { clientIP = "UnknownHost"; } - queryLogBuilder.put(QueryLogInfo.CLIENT_IP_I, clientIP); - queryLogBuilder.put(QueryLogInfo.QUERY_I, query); + + if (clientIP != null) { + queryLogBuilder.put(QueryLogInfo.CLIENT_IP_I, clientIP); + } + if (query != null) { + queryLogBuilder.put(QueryLogInfo.QUERY_I, query); + } queryLogBuilder.put(QueryLogInfo.START_TIME_I, startTime); if (bindParameters != null) { - queryLogBuilder.put(QueryLogInfo.BIND_PARAMETERS_I, StringUtils.join(bindParameters,",")); + queryLogBuilder.put(QueryLogInfo.BIND_PARAMETERS_I, StringUtils.join(bindParameters, ",")); } if (tenantId != null) { queryLogBuilder.put(QueryLogInfo.TENANT_ID_I, tenantId.getString()); } + queryLogBuilder.put(QueryLogInfo.USER_I, queryServices.getUserName() != null ? queryServices.getUserName() : queryServices.getUser().getShortName()); return queryLogBuilder.build();