[
https://issues.apache.org/jira/browse/LUCENE-10227?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17442938#comment-17442938
]
Mike Drob commented on LUCENE-10227:
------------------------------------
Was thinking about this more, and I'm not convinced that FilterPath benefits
from being so strict about what it accepts in {{resolve}}.
Consider the case where I'm copying some files from one file system to another.
Java doesn't have a recursive directory copy, but
[Files.copy|https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/nio/file/Files.html#copy(java.nio.file.Path,java.nio.file.Path,java.nio.file.CopyOption...)]
suggests using {{walkFileTree}} to handle that, and the
[examples|https://docs.oracle.com/javase/tutorial/displayCode.html?code=https://docs.oracle.com/javase/tutorial/essential/io/examples/Copy.java]
linked from the [official
tutorial|https://docs.oracle.com/javase/tutorial/essential/io/copy.html] call
{{target.resolve(source.relativize(file))}}. Does this work across file
systems? I haven't been able to test yet, but it would suggest to me that they
should. This situation will come up even without the bad use of {{Path.of}}.
> FilterPath.resolve(Path) doesn't work
> -------------------------------------
>
> Key: LUCENE-10227
> URL: https://issues.apache.org/jira/browse/LUCENE-10227
> Project: Lucene - Core
> Issue Type: Bug
> Reporter: Mike Drob
> Priority: Major
>
> Short reproducing sample that captures the error I encounter when trying to
> write a unit test:
> {code:java}
> package org.apache.lucene.mockfile;
> import org.apache.lucene.util.LuceneTestCase;
> import org.junit.Test;
> import java.nio.file.Path;
> public class TestFilterPath extends LuceneTestCase {
> @Test
> public void testMultiwrap() throws Exception {
> Path source = LuceneTestCase.createTempDir();
> Path child = source.resolve("child");
> assertEquals(source, child.getParent());
> child = source.resolve(Path.of("child")); // This line throws exception
> assertEquals(source, child.getParent());
> }
> }
> {code}
> When running this test (on my Mac) I get the following:
> {noformat}
> mismatch, expected: FilterPath, got: class sun.nio.fs.UnixPath
> java.nio.file.ProviderMismatchException: mismatch, expected: FilterPath, got:
> class sun.nio.fs.UnixPath
> at
> __randomizedtesting.SeedInfo.seed([318296D60FE95435:125A6A9E9053DCC3]:0)
> at org.apache.lucene.mockfile.FilterPath.toDelegate(FilterPath.java:292)
> at org.apache.lucene.mockfile.FilterPath.resolve(FilterPath.java:151)
> at
> org.apache.lucene.mockfile.TestFilterPath.testMultiwrap(TestFilterPath.java:16)
> {noformat}
> Part of the problem here might be that {{createTempDir()}} gives me a
> {{FilterPath}} wrapped four layers deep.
> Part of the problem might be that resolve calls toDelegate which is too
> strict about what it would accept?
> I'm not sure what the intent of all of these wrappings is, so I'm not
> completely sure how to fix it.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]