<div dir="ltr">I can't change how it works, since i am only the client and don't control the server side. The server side is a RH/JBoss project:<div><ul><li><a href="https://github.com/hawkular/hawkular-inventory" target="_blank">https://github.com/hawkular/<wbr>hawkular-inventory</a><br></li></ul><div>Since the code currently supports deciding whether to encode the slash or not, i've raised a PR [1].</div></div><div><br></div><div>[1] <a href="https://github.com/resteasy/Resteasy/pull/945">https://github.com/resteasy/Resteasy/pull/945</a></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 16, 2016 at 5:28 PM, Rebecca Searls <span dir="ltr"><<a href="mailto:rsearls@redhat.com" target="_blank">rsearls@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
As you have noted there is no simple clean way to alter this processing behavior.<br>
When it is this difficult and complex to control the processing behavior you<br>
desire, its an strong indication that you are attempting to use a feature outside<br>
its defined bounds and your implementation would be considered a bad code practice,<br>
fraught with potential maintenance nightmares.<br>
<br>
I strongly recommend you stop and reevaluate the problem you are attempting<br>
to solve and seek a means of addressing it in a way that is considered a standard<br>
practice.<br>
<br>
If you absolutely must proceed down this solution path then you would need<br>
to provide your own javax.ws.rs.core.URIBuilder implementation and pass it<br>
to the ProxyBuilder as a target.<br>
<br>
CustomURIBuilder cBuilder = new CustomURIBuilder();<br>
<br>
ProxyBuilder<T> proxyBuilder = client<br>
.target(cBuilder.uri(uri))<br>
//.target(uri)<br>
.proxyBuilder(apiClassType);<br>
<br>
After looking at the code you might think that you can extend Resteasy's<br>
URIBuilder implementation and override one of the resolveTemplates methods<br>
but there are several problems with that.<br>
<br>
- Overriding resolveTemplates method will not work because these methods<br>
call method buildString, which is private.<br>
- javax.ws.rs.core.URIBuilder is an abstract class that uses<br>
RuntimeDelegate.getInstance().<wbr>createUriBuilder() in a handful of methods<br>
for creating a UriBuilder object. In Resteasy the RuntimeDelegate is<br>
tied to ResteasyProviderFactory so you can not use methods newInstance,<br>
fromUri, fromPath, fromResource, fromMethod because they will return<br>
Resteasy's implementation class not yours.<br>
- You will not be able to override URiBuilder.newInstance to avoid access to<br>
RuntimeDelegate because it is a static method. You don't want to replace<br>
Resteasy's RuntimeDelegate because then you will break Resteasy itself.<br>
<br>
<br>
So now that we have discussed what you don't want to do and what you can't do<br>
lets consider other options.<br>
<br>
URI variables "{path}" can be matched by a regular expression "[^/]+?". There are<br>
a variety of web sites that discuss this. The disadvantage to this solution is<br>
the more unrestricted a string you want to support the more complicated the the<br>
expression may be. This could cause long term maintenance issues.<br>
<br>
Use the URI variable as it is intended, in particular don't embed a forward slack in the value<br>
and use another methodology to process the path. Here is a post with some good suggests,<br>
<a href="http://stackoverflow.com/questions/17000193/can-we-have-more-than-one-path-annotation-for-same-rest-method" rel="noreferrer" target="_blank">http://stackoverflow.com/<wbr>questions/17000193/can-we-<wbr>have-more-than-one-path-<wbr>annotation-for-same-rest-<wbr>method</a><br>
<br>
Don't pass the "path" information as a URI variable. Pass it as a QueryParam to<br>
your REST method, and process it internally.<br>
<span class="im HOEnZb"><br>
<br>
<br>
----- Original Message -----<br>
> From: "Rebecca Searls" <<a href="mailto:rsearls@redhat.com">rsearls@redhat.com</a>><br>
> To: "Gareth Healy" <<a href="mailto:garethahealy@gmail.com">garethahealy@gmail.com</a>><br>
> Cc: <a href="mailto:resteasy@lists.jboss.org">resteasy@lists.jboss.org</a><br>
</span><div class="HOEnZb"><div class="h5">> Sent: Friday, September 16, 2016 7:34:46 AM<br>
> Subject: Re: [resteasy] Client escapes slashes causing failure<br>
><br>
> I'm putting together an example of how to override the "encodeSlash" setting.<br>
> Should be available later today.<br>
><br>
><br>
> ----- Original Message -----<br>
> > From: "Gareth Healy" <<a href="mailto:garethahealy@gmail.com">garethahealy@gmail.com</a>><br>
> > To: "Rebecca Searls" <<a href="mailto:rsearls@redhat.com">rsearls@redhat.com</a>><br>
> > Cc: <a href="mailto:resteasy@lists.jboss.org">resteasy@lists.jboss.org</a><br>
> > Sent: Friday, September 16, 2016 4:27:27 AM<br>
> > Subject: Re: [resteasy] Client escapes slashes causing failure<br>
> ><br>
> > Just digging into this a bit more, i can see the param processor is loaded<br>
> > [1] which calls the web target [2], but this calls an overload which always<br>
> > passes in true for "encodeSlash".<br>
> ><br>
> > [1] <a href="https://github.com/resteasy/Resteasy/blob/master/resteasy-" rel="noreferrer" target="_blank">https://github.com/resteasy/<wbr>Resteasy/blob/master/resteasy-</a><br>
> > client/src/main/java/org/<wbr>jboss/resteasy/client/jaxrs/<br>
> > internal/proxy/processors/<wbr>webtarget/PathParamProcessor.<wbr>java<br>
> > [2] <a href="https://github.com/resteasy/Resteasy/blob/master/resteasy-" rel="noreferrer" target="_blank">https://github.com/resteasy/<wbr>Resteasy/blob/master/resteasy-</a><br>
> > client/src/main/java/org/<wbr>jboss/resteasy/client/jaxrs/<br>
> > internal/ClientWebTarget.java#<wbr>L134<br>
> > [3] <a href="https://github.com/resteasy/Resteasy/blob/master/resteasy-" rel="noreferrer" target="_blank">https://github.com/resteasy/<wbr>Resteasy/blob/master/resteasy-</a><br>
> > jaxrs/src/main/java/org/jboss/<wbr>resteasy/specimpl/<br>
> > ResteasyUriBuilder.java#L1085<br>
> ><br>
> > The param processor is created by the factory [4] so i can't see how to<br>
> > change the default behaviour.<br>
> ><br>
> > [4]<br>
> > <a href="https://github.com/resteasy/Resteasy/blob/master/resteasy-client/src/main/java/org/jboss/resteasy/client/jaxrs/internal/proxy/processors/ProcessorFactory.java" rel="noreferrer" target="_blank">https://github.com/resteasy/<wbr>Resteasy/blob/master/resteasy-<wbr>client/src/main/java/org/<wbr>jboss/resteasy/client/jaxrs/<wbr>internal/proxy/processors/<wbr>ProcessorFactory.java</a><br>
> ><br>
> > On Thu, Sep 15, 2016 at 9:54 AM, Gareth Healy <<a href="mailto:garethahealy@gmail.com">garethahealy@gmail.com</a>><br>
> > wrote:<br>
> ><br>
> > > I've added a simple unit test which shows the behaviour @<br>
> > > <a href="https://github.com/garethahealy/resteast-pathparam-escape" rel="noreferrer" target="_blank">https://github.com/<wbr>garethahealy/resteast-<wbr>pathparam-escape</a><br>
> > ><br>
> > > Contains 1 test, which uses a ClientRequestFilter to check what the URI<br>
> > > is, if it contains "%2F", then it fails.<br>
> > ><br>
> > > Cheers.<br>
> > ><br>
> > > On Wed, Sep 14, 2016 at 8:01 PM, Rebecca Searls <<a href="mailto:rsearls@redhat.com">rsearls@redhat.com</a>><br>
> > > wrote:<br>
> > ><br>
> > >><br>
> > >> If you replace RelativePath with String do you have the same issue?<br>
> > >> What RelativePath class are you using?<br>
> > >><br>
> > >> ----- Original Message -----<br>
> > >> > From: "Gareth Healy" <<a href="mailto:garethahealy@gmail.com">garethahealy@gmail.com</a>><br>
> > >> > To: <a href="mailto:resteasy@lists.jboss.org">resteasy@lists.jboss.org</a><br>
> > >> > Sent: Wednesday, September 14, 2016 11:36:31 AM<br>
> > >> > Subject: [resteasy] Client escapes slashes causing failure<br>
> > >> ><br>
> > >> > I have a client which uses the following method:<br>
> > >> ><br>
> > >> ><br>
> > >> ><br>
> > >> > @GET<br>
> > >> > @Path("/{path}/treeHash")<br>
> > >> > Response getEntityHash(@PathParam("<wbr>path") RelativePath path);<br>
> > >> ><br>
> > >> > The RelativePath object gets converted into a value of:<br>
> > >> > t;unit-testing/e;ua2shhq9<br>
> > >> ><br>
> > >> ><br>
> > >> ><br>
> > >> ><br>
> > >> > Example full URL: /entity/t;unit-testing/e;<wbr>ua2shhq9/treeHash<br>
> > >> ><br>
> > >> > When its executed, the forward slash is converted to %2F (encoded /).<br>
> > >> This<br>
> > >> > causes the call to fail. What do i need to do, to make sure its not<br>
> > >> > URL<br>
> > >> > encoded?<br>
> > >> ><br>
> > >> > I've tried adding @Encoded, but that has no effect.<br>
> > >> ><br>
> > >> > Cheers.<br>
> > >> ><br>
> > >> > ______________________________<wbr>_________________<br>
> > >> > resteasy mailing list<br>
> > >> > <a href="mailto:resteasy@lists.jboss.org">resteasy@lists.jboss.org</a><br>
> > >> > <a href="https://lists.jboss.org/mailman/listinfo/resteasy" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/resteasy</a><br>
> > >> ><br>
> > >><br>
> > ><br>
> > ><br>
> ><br>
> ______________________________<wbr>_________________<br>
> resteasy mailing list<br>
> <a href="mailto:resteasy@lists.jboss.org">resteasy@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/resteasy" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/resteasy</a><br>
><br>
</div></div></blockquote></div><br></div>