From commits-return-21147-archive-asf-public=cust-asf.ponee.io@phoenix.apache.org Wed May 9 23:11:37 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 7DE68180649 for ; Wed, 9 May 2018 23:11:36 +0200 (CEST) Received: (qmail 76096 invoked by uid 500); 9 May 2018 21:11:35 -0000 Mailing-List: contact commits-help@phoenix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@phoenix.apache.org Delivered-To: mailing list commits@phoenix.apache.org Received: (qmail 76087 invoked by uid 99); 9 May 2018 21:11:35 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 May 2018 21:11:35 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 6CE6FDFAE3; Wed, 9 May 2018 21:11:35 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ankit@apache.org To: commits@phoenix.apache.org Message-Id: <90deda47a8bf42c39d8a2adc121463d4@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: phoenix git commit: PHOENIX-4733 NPE while running sql through file using psql Date: Wed, 9 May 2018 21:11:35 +0000 (UTC) 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 Authored: Wed May 9 14:11:29 2018 -0700 Committer: Ankit Singhal 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 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 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();