Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show how http URI origins don't work #544

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

elharo
Copy link
Contributor

@elharo elharo commented Dec 29, 2023

java.nio.file.FileSystemNotFoundException: Provider "https" not installed
at java.nio.file.Paths.get(Paths.java:147)
at org.apache.commons.io.build.AbstractOrigin$URIOrigin.getPath(AbstractOrigin.java:402)
at org.apache.commons.io.build.AbstractOrigin.getInputStream(AbstractOrigin.java:540)
at org.apache.commons.io.build.URIOriginTest.testReadFromURL(URIOriginTest.java:47)
at java.lang.reflect.Method.invoke(Method.java:498)
at java.util.ArrayList.forEach(ArrayList.java:1257)
at java.util.ArrayList.forEach(ArrayList.java:1257)

@garydgregory
Copy link
Member

By default, there is no "ftp", "ldap", and so on, either ;-) The stock Java platform is extensible of course, using the file java.nio.file.spi.FileSystemProvider in the resource directory META-INF/services.

@elharo
Copy link
Contributor Author

elharo commented Dec 29, 2023

That is true, but that is an implementation detail. There's nothing in this class or API that indicates it should depend on which file system providers are installed. And this is about URIs, not file systems. I would be equally surprised if CharSequenceOrigin depended on file system providers.

URIOrigin should be able to provide at l;east streams and readers for any URL the JDK can handle.

Overall though as I explore this, I'm coming to the conclusion that Origin is attempting to provide an abstraction for something that doesn't exist. That is, there is no true common type for files, byte arrays, strings, URLs, etc. Hence all the UnsupportedOperationExceptions and surprising failures like this one.

@garydgregory
Copy link
Member

I suppose it's semi-surprising that Java versions 11 and up don't support HTTP since they do provide an HTTP client. At least a read-only file system should be "simple" without getting into the whole WebDAV thing.

@elharo
Copy link
Contributor Author

elharo commented Dec 29, 2023

That's not quite accurate. Java versions 1 and up do support HTTP. They just don't support it as a file system since it really isn't a file system. Neither are byte arrays or char sequences, of course.

@ecki
Copy link

ecki commented Dec 29, 2023

Not sure how useful this Origin abstraction is, but why would URIOrigin.getInputStresm not delegate to URI.getInputStresm?

@garydgregory
Copy link
Member

@elharo
If you rebase on git master, this should now work due to #630

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants