users@jersey.java.net

handling urls with {

From: Bill de hOra <bill_at_dehora.net>
Date: Tue, 03 Mar 2009 21:40:20 +0000

Jersey (1.0.2) throws a java.net.URISyntaxException when it encounters a
URL with a {. Trying an ExceptionMapper does not catch
UriBuilderException (t appears that the exception is thrown before the
ExceptionMappers are in place).

The exception looks like this

[[[
Caused by: java.net.URISyntaxException: Illegal character in query at
index 56:
http://192.168.3.200:8080/svc/data/user?fmt=pbuf&start=${rndstart}&count=50
at java.net.URI$Parser.fail(URI.java:2809)
at java.net.URI$Parser.checkChars(URI.java:2982)
at java.net.URI$Parser.parseHierarchical(URI.java:3072)
at java.net.URI$Parser.parse(URI.java:3014)
at java.net.URI.<init>(URI.java:578)
]]]

I thought it was something goofy in java.net.URI, but debugging this
call it seems like there is a method in UriComponent class that is not
fully encoding the query string, ie calling,

UriComponent.contextualEncode("start=^%|{rndstart}",
UriComponent.Type.QUERY, true)

returns start=%5E%25%7C{rndstart} leaving '{', '}' not encoded.

Does anyone else agrees this is a bug? If so I'll file a ticket and
submit a patch anon.

Bill