mirror of https://github.com/apache/lucene.git
LUCENE-6430: FilterPath needs hashCode/equals
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1674105 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f4c0546567
commit
5cbdc93244
|
@ -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
|
||||
|
|
|
@ -341,4 +341,20 @@ public class TestMockFilesystems extends LuceneTestCase {
|
|||
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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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}.
|
||||
|
|
Loading…
Reference in New Issue