Return-Path: X-Original-To: apmail-geode-commits-archive@minotaur.apache.org Delivered-To: apmail-geode-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2D0ED19E33 for ; Fri, 8 Apr 2016 16:26:24 +0000 (UTC) Received: (qmail 9285 invoked by uid 500); 8 Apr 2016 16:26:24 -0000 Delivered-To: apmail-geode-commits-archive@geode.apache.org Received: (qmail 9248 invoked by uid 500); 8 Apr 2016 16:26:23 -0000 Mailing-List: contact commits-help@geode.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.incubator.apache.org Delivered-To: mailing list commits@geode.incubator.apache.org Received: (qmail 9221 invoked by uid 99); 8 Apr 2016 16:26:23 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Apr 2016 16:26:23 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id AE8AFC021C for ; Fri, 8 Apr 2016 16:26:23 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -3.221 X-Spam-Level: X-Spam-Status: No, score=-3.221 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001] autolearn=disabled Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id BvH5wk3LYhCm for ; Fri, 8 Apr 2016 16:26:22 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with SMTP id DF70E5FACD for ; Fri, 8 Apr 2016 16:26:20 +0000 (UTC) Received: (qmail 7518 invoked by uid 99); 8 Apr 2016 16:26:19 -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; Fri, 08 Apr 2016 16:26:19 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B106EE9E8E; Fri, 8 Apr 2016 16:26:19 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jinmeiliao@apache.org To: commits@geode.incubator.apache.org Date: Fri, 08 Apr 2016 16:26:27 -0000 Message-Id: In-Reply-To: <00dfed5274f145988a6426afa50cefc6@git.apache.org> References: <00dfed5274f145988a6426afa50cefc6@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [09/36] incubator-geode git commit: GEODE-1173: NPE thrown from ServerConnection method getPostAuthzRequest() GEODE-1173: NPE thrown from ServerConnection method getPostAuthzRequest() Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/e92bf707 Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/e92bf707 Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/e92bf707 Branch: refs/heads/feature/GEODE-17-2 Commit: e92bf70738384c5998de5e3fe86d37d7aed738e6 Parents: 49e3f52 Author: Jens Deppe Authored: Tue Apr 5 08:01:23 2016 -0700 Committer: Jens Deppe Committed: Tue Apr 5 08:01:23 2016 -0700 ---------------------------------------------------------------------- .../ServerToClientFunctionResultSender.java | 2 +- .../cache/tier/sockets/ServerConnection.java | 61 +++++++++++++++----- 2 files changed, 48 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e92bf707/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/execute/ServerToClientFunctionResultSender.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/execute/ServerToClientFunctionResultSender.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/execute/ServerToClientFunctionResultSender.java index 6fce3a3..14b81a1 100755 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/execute/ServerToClientFunctionResultSender.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/execute/ServerToClientFunctionResultSender.java @@ -239,7 +239,7 @@ public class ServerToClientFunctionResultSender implements ResultSender { } } - protected void authorizeResult(Object oneResult) { + protected void authorizeResult(Object oneResult) throws IOException { // check if the caller is authorised to receive these function execution // results from server AuthorizeRequestPP authzRequestPP = this.sc.getPostAuthzRequest(); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e92bf707/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/ServerConnection.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/ServerConnection.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/ServerConnection.java index 13427f8..1dd2562 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/ServerConnection.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/ServerConnection.java @@ -438,12 +438,22 @@ public class ServerConnection implements Runnable { } //hitesh:this is for backward compability - public long setUserAuthorizeAndPostAuthorizeRequest(AuthorizeRequest authzRequest, AuthorizeRequestPP postAuthzRequest) - { + public long setUserAuthorizeAndPostAuthorizeRequest( + AuthorizeRequest authzRequest, AuthorizeRequestPP postAuthzRequest) + throws IOException { UserAuthAttributes userAuthAttr = new UserAuthAttributes(authzRequest, postAuthzRequest); - if (this.clientUserAuths == null ) + if (this.clientUserAuths == null) { this.initializeClientUserAuths(); - return this.clientUserAuths.putUserAuth(userAuthAttr); + } + try { + return this.clientUserAuths.putUserAuth(userAuthAttr); + } catch (NullPointerException npe) { + if (this.isTerminated()) { + // Bug #52023. + throw new IOException("Server connection is terminated."); + } + throw npe; + } } //this is backward compability only, if any race condition happens. //where server is unregistering the client and client is creating new connection. @@ -967,11 +977,15 @@ public class ServerConnection implements Runnable { throw new AuthenticationFailedException("Authentication failed"); } - return this.clientUserAuths.removeUserId(aIds.getUniqueId(), keepalive); - } - catch(Exception ex) - { - throw new AuthenticationFailedException("Authentication failed"); + try { + return this.clientUserAuths.removeUserId(aIds.getUniqueId(), keepalive); + } catch (NullPointerException npe) { + // Bug #52023. + logger.debug("Exception {}", npe); + return false; + } + } catch (Exception ex) { + throw new AuthenticationFailedException("Authentication failed", ex); } } public byte[] setCredentials(Message msg) @@ -1940,7 +1954,7 @@ public class ServerConnection implements Runnable { } public AuthorizeRequest getAuthzRequest() - throws AuthenticationRequiredException { + throws AuthenticationRequiredException, IOException { //look client version and return authzrequest //for backward client it will be store in member variable userAuthId //for other look "requestMsg" here and get unique-id from this to get the authzrequest @@ -1983,8 +1997,17 @@ public class ServerConnection implements Runnable { .toLocalizedString()); } } - - UserAuthAttributes uaa = this.clientUserAuths.getUserAuthAttributes(uniqueId); + UserAuthAttributes uaa = null; + try { + uaa = this.clientUserAuths.getUserAuthAttributes(uniqueId); + } catch (NullPointerException npe) { + if (this.isTerminated()) { + // Bug #52023. + throw new IOException("Server connection is terminated."); + } else { + logger.debug("Unexpected exception {}", npe); + } + } if (uaa == null) { throw new AuthenticationRequiredException( "User authorization attributes not found."); @@ -2002,7 +2025,7 @@ public class ServerConnection implements Runnable { } public AuthorizeRequestPP getPostAuthzRequest() - throws AuthenticationRequiredException{ + throws AuthenticationRequiredException, IOException { //look client version and return authzrequest //for backward client it will be store in member variable userAuthId //for other look "requestMsg" here and get unique-id from this to get the authzrequest @@ -2045,7 +2068,17 @@ public class ServerConnection implements Runnable { } } - UserAuthAttributes uaa = this.clientUserAuths.getUserAuthAttributes(uniqueId); + UserAuthAttributes uaa = null; + try { + uaa = this.clientUserAuths.getUserAuthAttributes(uniqueId); + } catch (NullPointerException npe) { + if (this.isTerminated()) { + // Bug #52023. + throw new IOException("Server connection is terminated."); + } else { + logger.debug("Unexpected exception {}", npe); + } + } if (uaa == null) { throw new AuthenticationRequiredException( "User authorization attributes not found.");