Parsing too strict in java.net.URI?

David M. Lloyd david.lloyd at redhat.com
Mon Nov 14 16:47:34 UTC 2016


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?

[1] https://tools.ietf.org/html/rfc2396
-- 
- DML


More information about the net-dev mailing list