Repository: phoenix Updated Branches: refs/heads/4.x-cdh5.11 810ed4e37 -> c892e5c7d
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/c892e5c7 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/c892e5c7 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/c892e5c7 Branch: refs/heads/4.x-cdh5.11 Commit: c892e5c7d7ac5a705452060857aceb686cb57d23 Parents: 810ed4e Author: Ankit Singhal <ankitsingha...@gmail.com> Authored: Wed May 9 22:11:58 2018 +0100 Committer: Pedro Boado <pbo...@apache.org> Committed: Wed May 9 23:44:45 2018 +0100 ---------------------------------------------------------------------- .../org/apache/phoenix/log/QueryLoggerUtil.java | 24 ++++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/c892e5c7/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();