geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [7/8] incubator-geode git commit: GEODE-1173: NPE thrown from ServerConnection method getPostAuthzRequest()
Date Tue, 05 Apr 2016 17:39:15 GMT
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-1162
Commit: e92bf70738384c5998de5e3fe86d37d7aed738e6
Parents: 49e3f52
Author: Jens Deppe <jdeppe@pivotal.io>
Authored: Tue Apr 5 08:01:23 2016 -0700
Committer: Jens Deppe <jdeppe@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.");


Mime
View raw message