hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1179472 - in /hadoop/common/branches/branch-0.20-security-205: CHANGES.txt src/hdfs/org/apache/hadoop/hdfs/server/namenode/NameNode.java src/test/org/apache/hadoop/hdfs/TestDefaultNameNodePort.java
Date Wed, 05 Oct 2011 23:21:46 GMT
Author: mattf
Date: Wed Oct  5 23:21:46 2011
New Revision: 1179472

URL: http://svn.apache.org/viewvc?rev=1179472&view=rev
Log:
HDFS-2358. NPE when the default filesystem's uri has no authority. Contributed by Daryn Sharp.

Modified:
    hadoop/common/branches/branch-0.20-security-205/CHANGES.txt   (contents, props changed)
    hadoop/common/branches/branch-0.20-security-205/src/hdfs/org/apache/hadoop/hdfs/server/namenode/NameNode.java
    hadoop/common/branches/branch-0.20-security-205/src/test/org/apache/hadoop/hdfs/TestDefaultNameNodePort.java

Modified: hadoop/common/branches/branch-0.20-security-205/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-205/CHANGES.txt?rev=1179472&r1=1179471&r2=1179472&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-205/CHANGES.txt (original)
+++ hadoop/common/branches/branch-0.20-security-205/CHANGES.txt Wed Oct  5 23:21:46 2011
@@ -56,6 +56,9 @@ Release 0.20.205.0 - 2011.09.28
 
   BUG FIXES
 
+    HDFS-2358. NPE when the default filesystem's uri has no authority.
+    (Daryn Sharp via mattf)
+
     MAPREDUCE-3112. Calling hadoop cli inside mapreduce job leads to errors.
     (Eric Yang via mattf)
 

Propchange: hadoop/common/branches/branch-0.20-security-205/CHANGES.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Oct  5 23:21:46 2011
@@ -1,6 +1,6 @@
 /hadoop/common/branches/branch-0.20/CHANGES.txt:826138,826568,829987,831184,833001,880632,898713,909245,909723,960946,990003,1044225
 /hadoop/common/branches/branch-0.20-append/CHANGES.txt:955380,955398,955448,956329
-/hadoop/common/branches/branch-0.20-security/CHANGES.txt:1170042,1170087,1170997,1171137,1171181,1171380,1171613,1171891,1171905,1172184,1172188,1172190,1172192,1173470,1173843,1174326,1174471,1174476,1174482,1175114,1176179,1176182,1176270,1176276,1176675,1176720,1177031,1177036,1177098,1177101,1177907,1178074,1179036,1179171
+/hadoop/common/branches/branch-0.20-security/CHANGES.txt:1170042,1170087,1170997,1171137,1171181,1171380,1171613,1171891,1171905,1172184,1172188,1172190,1172192,1173470,1173843,1174326,1174471,1174476,1174482,1175114,1176179,1176182,1176270,1176276,1176675,1176720,1177031,1177036,1177098,1177101,1177907,1178074,1179036,1179171,1179471
 /hadoop/common/branches/branch-0.20-security-203/CHANGES.txt:1096071,1097011,1097249,1097269,1097281,1097966,1098816,1098819,1098823,1098827,1098832,1098839,1098854,1098863,1099088,1099191,1099324,1099330,1099333,1102071,1128115
 /hadoop/common/branches/branch-0.20-security-204/CHANGES.txt:1128390,1147228,1148069,1149316,1154413,1159730,1161741
 /hadoop/core/branches/branch-0.18/CHANGES.txt:727226

Modified: hadoop/common/branches/branch-0.20-security-205/src/hdfs/org/apache/hadoop/hdfs/server/namenode/NameNode.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-205/src/hdfs/org/apache/hadoop/hdfs/server/namenode/NameNode.java?rev=1179472&r1=1179471&r2=1179472&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-205/src/hdfs/org/apache/hadoop/hdfs/server/namenode/NameNode.java
(original)
+++ hadoop/common/branches/branch-0.20-security-205/src/hdfs/org/apache/hadoop/hdfs/server/namenode/NameNode.java
Wed Oct  5 23:21:46 2011
@@ -223,7 +223,7 @@ public class NameNode implements ClientP
   }
 
   public static InetSocketAddress getAddress(Configuration conf) {
-    return getAddress(FileSystem.getDefaultUri(conf).getAuthority());
+    return getAddress(FileSystem.getDefaultUri(conf).toString());
   }
 
   public static URI getUri(InetSocketAddress namenode) {

Modified: hadoop/common/branches/branch-0.20-security-205/src/test/org/apache/hadoop/hdfs/TestDefaultNameNodePort.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-205/src/test/org/apache/hadoop/hdfs/TestDefaultNameNodePort.java?rev=1179472&r1=1179471&r2=1179472&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-205/src/test/org/apache/hadoop/hdfs/TestDefaultNameNodePort.java
(original)
+++ hadoop/common/branches/branch-0.20-security-205/src/test/org/apache/hadoop/hdfs/TestDefaultNameNodePort.java
Wed Oct  5 23:21:46 2011
@@ -17,7 +17,9 @@
  */
 package org.apache.hadoop.hdfs;
 
-import junit.framework.TestCase;
+import org.junit.*;
+import static org.junit.Assert.*;
+
 import java.io.*;
 import java.net.*;
 import java.util.*;
@@ -27,8 +29,8 @@ import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.hdfs.server.namenode.NameNode;
 
 /** Test NameNode port defaulting code. */
-public class TestDefaultNameNodePort extends TestCase {
-
+public class TestDefaultNameNodePort {
+  @Test
   public void testGetAddressFromString() throws Exception {
     assertEquals(NameNode.getAddress("foo").getPort(),
                  NameNode.DEFAULT_PORT);
@@ -40,6 +42,7 @@ public class TestDefaultNameNodePort ext
                  555);
   }
 
+  @Test
   public void testGetAddressFromConf() throws Exception {
     Configuration conf = new Configuration();
     FileSystem.setDefaultUri(conf, "hdfs://foo/");
@@ -57,4 +60,36 @@ public class TestDefaultNameNodePort ext
                                                        NameNode.DEFAULT_PORT)),
                  URI.create("hdfs://foo"));
   }
+
+  @Test
+  public void testSlashAddress() throws Exception {
+    verifyBadAuthAddress("/junk");
+  } 
+
+  @Test
+  public void testSlashSlashAddress() throws Exception {
+    verifyBadAuthAddress("//junk");
+  } 
+
+  @Test
+  public void testNoAuthAddress() throws Exception {
+    // this is actually the default value if the default fs isn't configured!
+    verifyBadAuthAddress("file:///");
+  } 
+
+  public void verifyBadAuthAddress(String noAuth) throws Exception {
+    Configuration conf = new Configuration();
+    FileSystem.setDefaultUri(conf, noAuth);
+    try {
+      InetSocketAddress addr = NameNode.getAddress(conf);
+      // this will show what we got back in case the test fails
+      assertEquals(null, addr);
+    } catch (IllegalArgumentException e) {
+      assertEquals(
+          "Does not contain a valid host:port authority: " + noAuth,
+          e.getMessage());
+    }
+  } 
+
+
 }



Mime
View raw message