Repository: incubator-ranger
Updated Branches:
  refs/heads/master e191a4b4e -> 4e4bd02fd


RANGER-1097:Ranger KMS Plugin should not fails to download policy when UGI 
ticket expires


Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/4e4bd02f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/4e4bd02f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/4e4bd02f

Branch: refs/heads/master
Commit: 4e4bd02fd9f9c7a4c5873f04446e819e4f5353bd
Parents: e191a4b
Author: rmani <[email protected]>
Authored: Tue Jul 12 17:03:29 2016 -0700
Committer: rmani <[email protected]>
Committed: Tue Jul 12 17:03:29 2016 -0700

----------------------------------------------------------------------
 .../apache/ranger/audit/provider/MiscUtil.java   | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/4e4bd02f/agents-audit/src/main/java/org/apache/ranger/audit/provider/MiscUtil.java
----------------------------------------------------------------------
diff --git 
a/agents-audit/src/main/java/org/apache/ranger/audit/provider/MiscUtil.java 
b/agents-audit/src/main/java/org/apache/ranger/audit/provider/MiscUtil.java
index ff4dc76..0211bf3 100644
--- a/agents-audit/src/main/java/org/apache/ranger/audit/provider/MiscUtil.java
+++ b/agents-audit/src/main/java/org/apache/ranger/audit/provider/MiscUtil.java
@@ -480,7 +480,9 @@ public class MiscUtil {
        }
 
        public static UserGroupInformation getUGILoginUser() {
-               if (ugiLoginUser == null) {
+               UserGroupInformation ret = ugiLoginUser;
+
+               if (ret == null) {
                        try {
                                // Do not cache ugiLoginUser if it is not 
explicitly set with
                                // setUGILoginUser.
@@ -489,12 +491,21 @@ public class MiscUtil {
                                // in when the token is scheduled to expire. So 
it is better
                                // to get the user object every time from 
UserGroupInformation class and
                                // not cache it
-                               return getLoginUser();
+                               ret = getLoginUser();
                        } catch (IOException e) {
                                logger.error("Error getting UGI.", e);
                        }
                }
-               return ugiLoginUser;
+
+               if(ret != null) {
+                       try {
+                       ret.checkTGTAndReloginFromKeytab();
+                       } catch(IOException excp) {
+                               // ignore
+                       }
+               }
+
+               return ret;
        }
 
        public static Subject getSubjectLoginUser() {
@@ -785,7 +796,7 @@ public class MiscUtil {
 
        public static UserGroupInformation getLoginUser() throws IOException {
                UserGroupInformation ugi = UserGroupInformation.getLoginUser();
-               ugi.checkTGTAndReloginFromKeytab();
+
                return ugi;
        }
 

Reply via email to