marschall / memoryfilesystem

An in memory implementation of a JSR-203 file system
282 stars 36 forks source link

Only support URL handling for the 'memory' scheme #144

Closed ascopes closed 1 year ago

ascopes commented 1 year ago

Just a quick one off the back of what was added earlier today.

Looks like the current implementation will allow itself to be initialised with any form of protocol. Right now, I can see that initialising a URL with a protocol of "some-crazy-random-scheme" gets assigned to the Handler class in this module, rather than it throwing an Exception about it.

image

I've added some additional checks to try and help avoid this, especially since this can occur implicitly if using the Java 9 SPI for the URL handler factory.

Upon performing these checks, the behaviour changes to the expected outcome:

java.net.MalformedURLException: unknown protocol: some-crazy-random-scheme
    at java.base/java.net.URL.<init>(URL.java:682)
    at java.base/java.net.URL.fromURI(URL.java:749)
    at java.base/java.net.URI.toURL(URI.java:1136)
    ... 58 more
marschall commented 1 year ago

Thank you. I'll create a release soon.

marschall commented 1 year ago

I just published 2.6.1 to Maven Central which has all your fixes plus additional ones.

ascopes commented 1 year ago

Thanks!