ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject incubator-ranger git commit: RANGER-1269 - Make MiscUtil.getGroupsForRequestUser more robust
Date Wed, 21 Dec 2016 15:02:28 GMT
Repository: incubator-ranger
Updated Branches:
  refs/heads/master 263bf4353 -> c4b054289


RANGER-1269 - Make MiscUtil.getGroupsForRequestUser more robust

Reviewed by Vel.


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

Branch: refs/heads/master
Commit: c4b0542896714b71bdac0d5e8398354b22e133ed
Parents: 263bf43
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Mon Dec 19 17:59:56 2016 +0000
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Wed Dec 21 15:02:13 2016 +0000

----------------------------------------------------------------------
 .../apache/ranger/audit/provider/MiscUtil.java  | 32 ++++++++++----------
 1 file changed, 16 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/c4b05428/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 f204d36..d440b85 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
@@ -26,6 +26,7 @@ import java.security.PrivilegedExceptionAction;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Calendar;
+import java.util.Collections;
 import java.util.Date;
 import java.util.GregorianCalendar;
 import java.util.HashMap;
@@ -572,25 +573,24 @@ public class MiscUtil {
 	 * @return
 	 */
 	static public Set<String> getGroupsForRequestUser(String userName) {
-		if (userName == null) {
-			return null;
-		}
-		try {
-			UserGroupInformation ugi = UserGroupInformation
-					.createRemoteUser(userName);
-			String groups[] = ugi.getGroupNames();
-			if (groups != null && groups.length > 0) {
-				Set<String> groupsSet = new java.util.HashSet<String>();
-				for (int i = 0; i < groups.length; i++) {
-					groupsSet.add(groups[i]);
+		if (userName != null) {
+			try {
+				UserGroupInformation ugi = UserGroupInformation
+						.createRemoteUser(userName);
+				String[] groups = ugi.getGroupNames();
+				if (groups != null && groups.length > 0) {
+					Set<String> groupsSet = new java.util.HashSet<String>();
+					for (String group : groups) {
+						groupsSet.add(group);
+					}
+					return groupsSet;
 				}
-				return groupsSet;
+			} catch (Throwable e) {
+				logErrorMessageByInterval(logger,
+						"Error getting groups for users. userName=" + userName, e);
 			}
-		} catch (Throwable e) {
-			logErrorMessageByInterval(logger,
-					"Error getting groups for users. userName=" + userName, e);
 		}
-		return null;
+		return Collections.emptySet();
 	}
 
 	static public boolean logErrorMessageByInterval(Log useLogger,


Mime
View raw message