hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ji...@apache.org
Subject svn commit: r1529258 - in /hadoop/common/branches/branch-1: ./ src/contrib/gridmix/src/test/org/apache/hadoop/mapred/gridmix/ src/core/org/apache/hadoop/security/ src/test/org/apache/hadoop/security/
Date Fri, 04 Oct 2013 18:54:48 GMT
Author: jing9
Date: Fri Oct  4 18:54:48 2013
New Revision: 1529258

URL: http://svn.apache.org/r1529258
Log:
HADOOP-10009. Backport HADOOP-7808 to branch-1: fix NPE in SecurityUtil::setTokenService().
Contributed by Haohui Mai.

Modified:
    hadoop/common/branches/branch-1/CHANGES.txt
    hadoop/common/branches/branch-1/src/contrib/gridmix/src/test/org/apache/hadoop/mapred/gridmix/TestRandomAlgorithm.java
    hadoop/common/branches/branch-1/src/core/org/apache/hadoop/security/SecurityUtil.java
    hadoop/common/branches/branch-1/src/test/org/apache/hadoop/security/TestSecurityUtil.java

Modified: hadoop/common/branches/branch-1/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/CHANGES.txt?rev=1529258&r1=1529257&r2=1529258&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/CHANGES.txt (original)
+++ hadoop/common/branches/branch-1/CHANGES.txt Fri Oct  4 18:54:48 2013
@@ -145,6 +145,9 @@ Release 1.3.0 - unreleased
     MAPREDUCE-5508. JobTracker memory leak caused by unreleased FileSystem
     objects in JobInProgress#cleanupJob. (Xi Fang via cnauroth)
 
+    HADOOP-10009. Backport HADOOP-7808 to branch-1: fix NPE in 
+    SecurityUtil::setTokenService(). (Haohui Mai via jing9)
+
 Release 1.2.2 - unreleased
 
   INCOMPATIBLE CHANGES

Modified: hadoop/common/branches/branch-1/src/contrib/gridmix/src/test/org/apache/hadoop/mapred/gridmix/TestRandomAlgorithm.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/contrib/gridmix/src/test/org/apache/hadoop/mapred/gridmix/TestRandomAlgorithm.java?rev=1529258&r1=1529257&r2=1529258&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/src/contrib/gridmix/src/test/org/apache/hadoop/mapred/gridmix/TestRandomAlgorithm.java
(original)
+++ hadoop/common/branches/branch-1/src/contrib/gridmix/src/test/org/apache/hadoop/mapred/gridmix/TestRandomAlgorithm.java
Fri Oct  4 18:54:48 2013
@@ -17,7 +17,8 @@
  */
 package org.apache.hadoop.mapred.gridmix;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -30,8 +31,6 @@ import java.util.Set;
 
 import org.junit.Test;
 
-import com.sun.tools.javac.code.Attribute.Array;
-
 public class TestRandomAlgorithm {
   private static final int[][] parameters = new int[][] {
     {5, 1, 1}, 

Modified: hadoop/common/branches/branch-1/src/core/org/apache/hadoop/security/SecurityUtil.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/core/org/apache/hadoop/security/SecurityUtil.java?rev=1529258&r1=1529257&r2=1529258&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/src/core/org/apache/hadoop/security/SecurityUtil.java
(original)
+++ hadoop/common/branches/branch-1/src/core/org/apache/hadoop/security/SecurityUtil.java
Fri Oct  4 18:54:48 2013
@@ -332,7 +332,13 @@ public class SecurityUtil {
    * @param addr the socket for the rpc connection
    */
   public static void setTokenService(Token<?> token, InetSocketAddress addr) {
-    token.setService(buildTokenService(addr));
+    Text service = buildTokenService(addr);
+    if (token != null) {
+      token.setService(service);
+      LOG.info("Acquired token "+token);  // Token#toString() prints service
+    } else {
+      LOG.warn("Failed to get token for service "+service);
+    }
   }
   
   /**

Modified: hadoop/common/branches/branch-1/src/test/org/apache/hadoop/security/TestSecurityUtil.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/test/org/apache/hadoop/security/TestSecurityUtil.java?rev=1529258&r1=1529257&r2=1529258&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/src/test/org/apache/hadoop/security/TestSecurityUtil.java
(original)
+++ hadoop/common/branches/branch-1/src/test/org/apache/hadoop/security/TestSecurityUtil.java
Fri Oct  4 18:54:48 2013
@@ -16,7 +16,10 @@
  */
 package org.apache.hadoop.security;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
 import java.net.InetAddress;
@@ -28,6 +31,7 @@ import org.apache.commons.logging.LogFac
 import org.apache.hadoop.io.Text;
 import org.apache.hadoop.net.NetUtils;
 import org.apache.hadoop.security.token.Token;
+import org.apache.hadoop.security.token.TokenIdentifier;
 import org.junit.Test;
 import org.mockito.Mockito;
 
@@ -233,10 +237,11 @@ public class TestSecurityUtil {
     SecurityUtil.setTokenServiceUseIp(useIp);
     String serviceHost = useIp ? ip : host.toLowerCase();
     
-    Token token = new Token();
+    Token<TokenIdentifier> token = new Token<TokenIdentifier>();
     Text service = new Text(serviceHost+":"+port);
     
     assertEquals(service, SecurityUtil.buildTokenService(addr));
+
     SecurityUtil.setTokenService(token, addr);
     assertEquals(service, token.getService());
     
@@ -322,4 +327,11 @@ public class TestSecurityUtil {
     NetUtils.addStaticResolution(staticHost, "255.255.255.255");
     verifyServiceAddr(staticHost, "255.255.255.255");
   }
+  
+  @Test
+  public void testSetTokenServiceWithNoToken() {
+    InetSocketAddress addr = NetUtils.makeSocketAddr("127.0.0.1", 1234);
+    // Test whether setTokenService works when token is null
+    SecurityUtil.setTokenService(null, addr);
+  }
 }



Mime
View raw message