You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
produces a collection of URL's with a file:/ scheme, which, when one invokes #toFile() on them, yield a string of the form:
"/C:/foo/bar"
Unfortunately, Paths.get("/C:/foo/bar") throws an exception:
java.nio.file.InvalidPathException: Illegal char <:> at index 2: /C:/foo/bar
at sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
at sun.nio.fs.WindowsPath.parse(WindowsPath.java:94)
at sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:255)
at java.nio.file.Paths.get(Paths.java:84)
at co.mewf.humpty.config.HumptyBootstrap.getDefaultLocator(HumptyBootstrap.java:184)
at co.mewf.humpty.config.HumptyBootstrap$$Lambda$22/321299532.get(Unknown Source)
at java.util.Optional.orElseGet(Optional.java:267)
at co.mewf.humpty.config.HumptyBootstrap.<init>(HumptyBootstrap.java:80)
at co.mewf.humpty.servlet.HumptyServletContextInitializer.onStartup(HumptyServletContextInitializer.java:29)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5156)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 43 more
Not sure if this is a JVM 'bug' or not, but I do note that the Javadoc for java.nio.files.Paths.get(String,String...) says:
Note that while this method is very convenient, using it will imply an assumed reference to the default FileSystem and limit the utility of the calling code. Hence it should not be used in library code intended for flexible reuse.
An alternative which happens to work is:
Paths.get(url.toURI())
... because it retains the 'file:' scheme, that seems to be better. This does seem to be the 'right' way to de-reference URLs to local file paths.
The text was updated successfully, but these errors were encountered:
dtbullock
pushed a commit
to dtbullock/humpty
that referenced
this issue
Jul 9, 2015
Thanks for identifying the issue and for the PR. I'm sorry for not having gotten to this yet. I will get to it soon, however as I don't have a Windows computer, I'll have to ask you to verify that it works before releasing it.
On Windows,
produces a collection of URL's with a
file:/
scheme, which, when one invokes #toFile() on them, yield a string of the form:Unfortunately,
Paths.get("/C:/foo/bar")
throws an exception:Not sure if this is a JVM 'bug' or not, but I do note that the Javadoc for
java.nio.files.Paths.get(String,String...)
says:An alternative which happens to work is:
... because it retains the 'file:' scheme, that seems to be better. This does seem to be the 'right' way to de-reference URLs to local file paths.
The text was updated successfully, but these errors were encountered: