users@jax-rs-spec.java.net

[jax-rs-spec users] [jsr339-experts] Re: UriBuilder.segment and build with encodePathSlash

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Mon, 22 Oct 2012 14:43:36 +0200

On Oct 22, 2012, at 1:26 PM, Sergey Beryozkin <sberyozkin_at_talend.com> wrote:

> I know that I'm the last one who still does not get it :-).
>
> Consider the following:
>
> uriBuilder.fromPath("http://localhost").segment("{a}").build("a/b", false);
>
> UriBuilder.segment() states that "/" have to be encoded.

The javadoc of segment() applies to the value passed to the segment(). Not to a template that was added via segment(). IOW, if you passed "a/b" into segment() directly, it would be encoded.

> So one possible output is:
>
> "http://localhost/a%2Fb"
>
> While build() requires this slash to be left as is.

>
> So the result is then:
>
> "http://localhost/a/b"
>
> If the last output is the right one (has to be really), then I guess
>
> UriBuilder.segment() docs can be improved a bit to state that only "/" in the literal expressions have to be encoded by default, otherwise the encoding is affected by the new build flag, similarly the same clarification needs to be applied to UriBuilder path docs

Can you please provide a javadoc version that would clarify the segment() behavior in a way that is, in your opinion, clear & understandable?

Thanks,
Marek

>
> Sergey
>
>