Apache Lucene open-source search software
LUCENE-6430: fix URI delegation for non-ascii files
Robert Muir3dd6b59650fa
diff --git a/lucene/core/src/test/org/apache/lucene/mockfile/TestMockFilesystems.java b/lucene/core/src/test/org/apache/lucene/mockfile/TestMockFilesystems.javaindex 04800015eb7..507ce6fa1aa 100644--- a/lucene/core/src/test/org/apache/lucene/mockfile/TestMockFilesystems.java+++ b/lucene/core/src/test/org/apache/lucene/mockfile/TestMockFilesystems.java@@ -357,4 +357,20 @@ public class TestMockFilesystems extends LuceneTestCase {assertEquals(f1.hashCode(), f1Again.hashCode());assertFalse(f1.equals(f2));}++ public void testURI() 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");+ URI uri = f1.toUri();+ Path f2 = fs.provider().getPath(uri);+ assertEquals(f1, f2);++ Path f3 = wrapped.resolve("中国");+ URI uri2 = f3.toUri();+ Path f4 = fs.provider().getPath(uri2);+ assertEquals(f3, f4);+ }}diff --git a/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterFileSystemProvider.java b/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterFileSystemProvider.javaindex 0679c842ffd..1fe6dacbaf9 100644--- a/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterFileSystemProvider.java+++ b/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterFileSystemProvider.java@@ -17,12 +17,10 @@ package org.apache.lucene.mockfile;* limitations under the License.*/-import java.io.IOError;import java.io.IOException;import java.io.InputStream;import java.io.OutputStream;import java.net.URI;-import java.net.URISyntaxException;import java.nio.channels.AsynchronousFileChannel;import java.nio.channels.FileChannel;import java.nio.channels.SeekableByteChannel;@@ -126,7 +124,7 @@ public class FilterFileSystemProvider extends FileSystemProvider {if (fileSystem == null) {throw new IllegalStateException("subclass did not initialize singleton filesystem");}- Path path = delegate.getPath(toDelegate(uri));+ Path path = delegate.getPath(uri);return new FilterPath(path, fileSystem);}@@ -258,14 +256,6 @@ public class FilterFileSystemProvider extends FileSystemProvider {}}- private URI toDelegate(URI uri) {- try {- return new URI(delegate.getScheme(), uri.getSchemeSpecificPart(), uri.getFragment());- } catch (URISyntaxException e) {- throw new IOError(e);- }- }-/*** Override to trigger some behavior when the filesystem is closed.* <p>