You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2015/04/16 18:07:18 UTC
svn commit: r1674105 - in /lucene/dev/trunk/lucene: CHANGES.txt
core/src/test/org/apache/lucene/mockfile/TestMockFilesystems.java
test-framework/src/java/org/apache/lucene/mockfile/FilterPath.java
Author: rmuir
Date: Thu Apr 16 16:07:18 2015
New Revision: 1674105
URL: http://svn.apache.org/r1674105
Log:
LUCENE-6430: FilterPath needs hashCode/equals
Modified:
lucene/dev/trunk/lucene/CHANGES.txt
lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/mockfile/TestMockFilesystems.java
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterPath.java
Modified: lucene/dev/trunk/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/CHANGES.txt?rev=1674105&r1=1674104&r2=1674105&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/CHANGES.txt (original)
+++ lucene/dev/trunk/lucene/CHANGES.txt Thu Apr 16 16:07:18 2015
@@ -94,8 +94,9 @@ Bug Fixes
* LUCENE-6409: Fixed integer overflow in LongBitSet.ensureCapacity.
(Luc Vanlerberghe via Adrien Grand)
-* LUCENE-6424: Fix many bugs with mockfs filesystems in the test-framework:
- always consistently wrap Path, fix buggy behavior for globs, etc.
+* LUCENE-6424, LUCENE-6430: Fix many bugs with mockfs filesystems in the
+ test-framework: always consistently wrap Path, fix buggy behavior for
+ globs, implement equals/hashcode for filtered Paths, etc.
(Ryan Ernst, Simon Willnauer, Robert Muir)
* LUCENE-6426: Fix FieldType's copy constructor to also copy over the numeric
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/mockfile/TestMockFilesystems.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/mockfile/TestMockFilesystems.java?rev=1674105&r1=1674104&r2=1674105&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/mockfile/TestMockFilesystems.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/mockfile/TestMockFilesystems.java Thu Apr 16 16:07:18 2015
@@ -341,4 +341,20 @@ public class TestMockFilesystems extends
assertEquals(1, count);
}
}
+
+ public void testHashCodeEquals() throws IOException {
+ Path dir = FilterPath.unwrap(createTempDir());
+ FileSystem fs = new FilterFileSystemProvider("test://", dir.getFileSystem()).getFileSystem(URI.create("file:///"));
+ Path wrapped = new FilterPath(dir, fs);
+
+ Path f1 = wrapped.resolve("file1");
+ Path f1Again = wrapped.resolve("file1");
+ Path f2 = wrapped.resolve("file2");
+
+ assertEquals(f1, f1);
+ assertFalse(f1.equals(null));
+ assertEquals(f1, f1Again);
+ assertEquals(f1.hashCode(), f1Again.hashCode());
+ assertFalse(f1.equals(f2));
+ }
}
Modified: lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterPath.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterPath.java?rev=1674105&r1=1674104&r2=1674105&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterPath.java (original)
+++ lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterPath.java Thu Apr 16 16:07:18 2015
@@ -234,6 +234,26 @@ public class FilterPath implements Path
return delegate.compareTo(toDelegate(other));
}
+ @Override
+ public int hashCode() {
+ return delegate.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (getClass() != obj.getClass()) return false;
+ FilterPath other = (FilterPath) obj;
+ if (delegate == null) {
+ if (other.delegate != null) return false;
+ } else if (!delegate.equals(other.delegate)) return false;
+ if (fileSystem == null) {
+ if (other.fileSystem != null) return false;
+ } else if (!fileSystem.equals(other.fileSystem)) return false;
+ return true;
+ }
+
/**
* Unwraps all {@code FilterPath}s, returning
* the innermost {@code Path}.