Parsing too strict in java.net.URI?

Chris Hegarty chris.hegarty at oracle.com
Mon Nov 14 18:16:07 UTC 2016


David,

On 14/11/16 16:47, David M. Lloyd wrote:
> The following statement:
>
> URI uri = URI.create("local:");
>
> fails with an exception like this:
>
> java.lang.IllegalArgumentException: Expected scheme-specific part at
> index 6: local:
>     at java.net.URI.create(URI.java:852)
>     at
> org.jboss.ejb.client.Affinity$LocalAffinity.<clinit>(Affinity.java:131)
>     ... 32 more
> Caused by: java.net.URISyntaxException: Expected scheme-specific part at
> index 6: local:
>     at java.net.URI$Parser.fail(URI.java:2848)
>     at java.net.URI$Parser.failExpecting(URI.java:2854)
>     at java.net.URI$Parser.parse(URI.java:3057)
>     at java.net.URI.<init>(URI.java:588)
>     at java.net.URI.create(URI.java:850)
>     ... 33 more
>
> However AFAICT scheme-only URIs are, while not strictly allowed by RFC
> 2396 [1], in common usage (for example, "about:" in web browsers).
>
> WDYT?

This seems to be allowable in the "more recent" RFC [2], that obsoletes
2396, which of course java.net.URI does not, yet, support. There was an
effort to support 3986 a number of years ago, but it was not successful.
The desire to support, keep up with standards, etc, has caused us to
give consideration to supporting 3986, but as of yet nothing concrete.

-Chris.


[1] https://tools.ietf.org/html/rfc3986#appendix-D.2


More information about the net-dev mailing list