users@jersey.java.net

Re: [Jersey] handling urls with {

From: James Strachan <james.strachan_at_gmail.com>
Date: Tue, 3 Mar 2009 21:52:28 +0000

2009/3/3 Bill de hOra <bill_at_dehora.net>:
> 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.

Spooky I've just hit this too today Bill! :) Yeah it looks like a bug to me.

BTW the main reason I hit it is the user navigable auto-generated HTML
representation of the REST API tends to use expressions like {id}
inside the URIs. More background here..

http://n2.nabble.com/-PATCH--to-allow-the-API-of-RESTful-services-to-be-rendered-using--hierarchial-Implicit-Views-tt2353447.html

-- 
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://fusesource.com/