Closed blacelle closed 1 year ago
Interesting, I'll have a look and report back.
Having looked a bit more into it I'm undecided so far. We have the constraint thatURI#getScheme()
has to return FileSystemProvider#getScheme()
. If you check the the URI
constructors there are basically two variants. One with a scheme and a path, and an opaque one with a scheme and scheme specific part.
We could put the name of the file system as the first element of the path but then URI#getPath()
would return the file path with a prefix.
May I ask why you expect URI#getPath()
to be non-null? Path#toUri()
makes no such guarantees. For example the path of JAR URIs is also null
URI.create("jar:file:///C:/proj/parser/jar/parser.jar!/test.xml").getPath()
May I ask why you expect URI#getPath() to be non-null?
This is expected by some library I rely on:
@Override
public boolean isNameCompatible(String simpleName, Kind kind) {
String baseName = simpleName + kind.extension;
return kind.equals(getKind())
&& (baseName.equals(toUri().getPath()). <--- Here, null is OK
|| toUri().getPath().endsWith("/" + baseName)); <--- Here, null is NPE
}
For some reason, they get the path after going through a URI. It looks awkward to me, but here I am.
For what it worth, the same scenario is OK with Jimfs.newFileSystem()
. With JimFS, the URI looks lile : jimfs://dfc87a7e-bf29-4569-ad85-3033052cc909/someModule/src/main/java/some_package/someFilePath.java
(which is similar to my suggestion)
Sorry, I somehow missed your reply. Do you happen to have a reproducer? I'm looking into opening a PR against OpenRewrite.
https://github.com/openrewrite/rewrite/pull/3010 let's see where it goes
My PR against OpenRewrite got merged so I'm closing this as won´t fix. I hope that's ok for you.
Nice @marschall
Hi. I'm a new MemoryFileSystem user, for Cleanthat. Thanks
I get unexpectly null on Path (from memoryFileSystem), when calling .getUri.getPath().
Here is a reproduction case:
The uri looks like:
memory:toto:///root/directory/file.txt
.Is this a limitation with a specific underlying reason, or could I hope a structural change of the URI to enable Java URI parsing a path from it?
Looking at
java.net.URI.Parser.parse(boolean)
, the uri parsing fails around:I feel URI expects a raw uri like
memory:/_g_1:///root/directory/file.txt
?Spec wise:
https://www.rfc-editor.org/rfc/rfc3986#section-3.2
https://www.rfc-editor.org/rfc/rfc3986#section-3.3
Alternative URI proposal: