[ 
https://issues.apache.org/jira/browse/LUCENE-10227?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17442315#comment-17442315
 ] 

Mike Drob commented on LUCENE-10227:
------------------------------------

Switching the test to {{child = 
source.resolve(source.getFileSystem().getPath("child"))}} did the trick. Thank 
you, gents. I think it would be good to improve the exception message to 
something like:

{noformat}
mismatch, expected: FilterPath, got: class sun.nio.fs.UnixPath
Did you use Path.of with the default FileSystem instead of using an existing 
path as an anchor?
        at 
__randomizedtesting.SeedInfo.seed([318296D60FE95435:125A6A9E9053DCC3]:0)
        at org.apache.lucene.mockfile.FilterPath.toDelegate(FilterPath.java:292)
{noformat}

I had read the javadoc for Path.of previously but failed to comprehend the full 
implications of this subtlety. Happy to take input on better wording of the 
message. I worry that adding JavaDoc to FilterPath would get lost since I 
expect that most of the time people don't even know they're dealing with a 
FilterPath.

> 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]

Reply via email to