You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by je...@apache.org on 2016/04/05 17:01:31 UTC

incubator-geode git commit: GEODE-1173: NPE thrown from ServerConnection method getPostAuthzRequest()

Repository: incubator-geode
Updated Branches:
  refs/heads/develop 49e3f523d -> e92bf7073


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/develop
Commit: e92bf70738384c5998de5e3fe86d37d7aed738e6
Parents: 49e3f52
Author: Jens Deppe <jd...@pivotal.io>
Authored: Tue Apr 5 08:01:23 2016 -0700
Committer: Jens Deppe <jd...@pivotal.io>
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.");