Incorrect coercion of URI to File in clojure.java.io

Description

`clojure.java.io/Coercions` currently uses URL as an intermediate representation when coercing a URI to a File. This causes an `IllegalArgumentException` when calling `as-file` on a relative URI. Java URIs and Files may be relative, but URLs are always absolute.

If a patch for this would be accepted, I'll submit one. Let me know.

Environment

None

Activity

Show:
Jeff Valk
April 23, 2019, 2:38 PM

Yep, closed. Thanks, Alex.

Alex Miller
April 22, 2019, 11:33 PM

So, ok to close?

Jeff Valk
April 22, 2019, 11:33 PM

No fix needed. Behavior is correct.

Jeff Valk
April 22, 2019, 11:32 PM

Upon further review, clojure.java.io's behvior seems to be correct. java.io.URL's error messages/terminology are the culprit. Please excuse the noise.

In case the details are of use to anyone:

The Java documentation says that URLs must be absolute. What it means by this, though, is that they must specify a scheme. The path component may be relative.

Hence, these both work as expected:

But because `as-file` coerces URI to File by first converting to URL, this does not:

Contrary to the wording, the exception isn't complaining about a relative path. It means that while URIs don't always have schemes, URLs must. If you give the URI a scheme, the function succeeds:

Alex Miller
April 22, 2019, 2:31 PM

Could you give an example?

Declined
Your pinned fields
Click on the next to a field label to start pinning.

Assignee

Unassigned

Reporter

Jeff Valk

Labels

Approval

Triaged

Priority

Minor

Affects versions