XenoAmess edited a comment on pull request #168:
URL: https://github.com/apache/commons-vfs/pull/168#issuecomment-805917059


   @garydgregory 
   
   > You will find that this JDK code fails on macOs (adapt your path, the file 
exists):
   > 
   > ```
   > FileSystems.getDefault().provider().getPath(new 
URI("file:///Users/garydgregory/git/commons-vfs/commons-vfs2/src/test/resources/test-data/好.txt"));
   > ```
   > 
   > with:
   > 
   > ```
   > java.lang.IllegalArgumentException: Bad escape
   >    at sun.nio.fs.UnixUriUtils.fromUri(UnixUriUtils.java:87)
   >    at 
sun.nio.fs.UnixFileSystemProvider.getPath(UnixFileSystemProvider.java:98)
   >    at java.nio.file.Paths.get(Paths.java:138)
   >    at org.apache.commons.vfs2.FileObject.getPath(FileObject.java:320)
   >    at 
org.apache.commons.vfs2.FileObjectTest.lambda$0(FileObjectTest.java:57)
   >    at 
org.apache.commons.vfs2.FileObjectTest.testToFile(FileObjectTest.java:74)
   >    at 
org.apache.commons.vfs2.FileObjectTest.testToFile(FileObjectTest.java:57)
   >    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   >    at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   >    at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   >    at java.lang.reflect.Method.invoke(Method.java:498)
   >    at 
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
   >    at 
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
   >    at 
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
   >    at 
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
   >    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
   >    at 
org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
   >    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
   >    at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
   >    at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
   >    at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
   >    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
   >    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
   >    at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
   >    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
   >    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
   >    at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
   >    at 
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
   >    at 
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40)
   >    at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
   >    at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:768)
   >    at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464)
   >    at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
   > ```
   
   Yep , if you look my fix, there will never be `.getPath(new 
URI("file:///Users/garydgregory/git/commons-vfs/commons-vfs2/src/test/resources/test-data/好.txt"));`
 anymore.
   
   I changed it from the toPath() inside.
   
   This is actually happened because the dis-coinsidence between URI rule in 
vfs and in jdk-lib.
   
   BUT it is to much cost to change the rule in vfs, so I just make it return a 
correct Path object.
   
   At least it can work with no bug.
   
   If you still feel strange, you can run the UT I added on mac, and I don't 
think it can fail. (I don't have a mac myself. I hate apple.)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to