浏览代码

HDFS-7026. Introduce a string constant for "Failed to obtain user group info...". Contributed by Yongjun Zhang.

Aaron T. Myers 10 年之前
父节点
当前提交
cbd21fd13b

+ 2 - 0
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SecurityUtil.java

@@ -57,6 +57,8 @@ import com.google.common.annotations.VisibleForTesting;
 public class SecurityUtil {
   public static final Log LOG = LogFactory.getLog(SecurityUtil.class);
   public static final String HOSTNAME_PATTERN = "_HOST";
+  public static final String FAILED_TO_GET_UGI_MSG_HEADER = 
+      "Failed to obtain user group information:";
 
   // controls whether buildTokenService will use an ip or host/ip as given
   // by the user

+ 3 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

@@ -376,6 +376,9 @@ Release 2.7.0 - UNRELEASED
     HDFS-7202. Should be able to omit package name of SpanReceiver on "hadoop
     trace -add" (iwasakims via cmccabe)
 
+    HDFS-7026. Introduce a string constant for "Failed to obtain user group
+    info...". (Yongjun Zhang via atm)
+
   OPTIMIZATIONS
 
   BUG FIXES

+ 2 - 1
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java

@@ -354,7 +354,8 @@ public class WebHdfsFileSystem extends FileSystem
       // extract UGI-related exceptions and unwrap InvalidToken
       // the NN mangles these exceptions but the DN does not and may need
       // to re-fetch a token if either report the token is expired
-      if (re.getMessage().startsWith("Failed to obtain user group information:")) {
+      if (re.getMessage().startsWith(
+          SecurityUtil.FAILED_TO_GET_UGI_MSG_HEADER)) {
         String[] parts = re.getMessage().split(":\\s+", 3);
         re = new RemoteException(parts[1], parts[2]);
         re = ((RemoteException)re).unwrapRemoteException(InvalidToken.class);

+ 2 - 1
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/resources/UserProvider.java

@@ -27,6 +27,7 @@ import javax.ws.rs.ext.Provider;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hdfs.server.common.JspHelper;
+import org.apache.hadoop.security.SecurityUtil;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod;
 
@@ -54,7 +55,7 @@ public class UserProvider
           AuthenticationMethod.KERBEROS, false);
     } catch (IOException e) {
       throw new SecurityException(
-          "Failed to obtain user group information: " + e, e);
+          SecurityUtil.FAILED_TO_GET_UGI_MSG_HEADER + " " + e, e);
     }
   }
 

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestDelegationTokensWithHA.java

@@ -416,7 +416,7 @@ public class TestDelegationTokensWithHA {
             // Mimic the UserProvider class logic (server side) by throwing
             // SecurityException here
             throw new SecurityException(
-                "Failed to obtain user group information: " + e, e);
+                SecurityUtil.FAILED_TO_GET_UGI_MSG_HEADER + " " + e, e);
           }
         } catch (Exception oe) {
           //