Browse Source

HADOOP-358. Fix a NPE in Path.equals(). Contributed by Frédéric Bertin.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@420772 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting 19 years ago
parent
commit
93ea3bb5d2

+ 3 - 0
CHANGES.txt

@@ -18,6 +18,9 @@ Trunk (unreleased changes)
     API fixes, making reduce optional, and adding an input type for
     StreamSequenceRecordReader.  (Michel Tourn via cutting)
 
+ 5. HADOOP-358.  Fix a NPE bug in Path.equals().
+    (Frédéric Bertin via cutting)
+
 
 Release 0.4.0 - 2006-06-28
 

+ 1 - 1
src/java/org/apache/hadoop/fs/Path.java

@@ -156,7 +156,7 @@ public class Path implements Comparable {
     return
       this.isAbsolute == that.isAbsolute &&
       Arrays.equals(this.elements, that.elements) &&
-      this.drive == null ? true : this.drive.equals(that.drive);
+      (this.drive == null ? true : this.drive.equals(that.drive));
   }
 
   public int hashCode() {

+ 4 - 0
src/test/org/apache/hadoop/fs/TestPath.java

@@ -93,5 +93,9 @@ public class TestPath extends TestCase {
       assertEquals(new Path("c:/foo"), new Path("d:/bar", "c:/foo"));
     }
   }
+  
+  public void testEquals() {
+    assertFalse(new Path("/").equals(new Path("/foo")));
+  }
 
 }