javax.ws.rs.core.UriBuilder is not escaping } correctly:
import javax.ws.rs.core.UriBuilder;
public void test() {
final UriBuilder builder = UriBuilder.fromUri("http://host");
builder.path("dir}one");
l.info(builder.toString());
}
Will output http://host/dir}one, leaving } unescaped.
Whereas org.apache.http.client.utils.URIBuilder:
org.apache.http.client.utils.URIBuilder;
public void testApache() {
final URIBuilder builder = new URIBuilder(URI.create("http://host"));
builder.setPath("dir}one");
l.info(builder.toString());
}
Will output http://hostdir%7Done, escaping } with %7D as expected.
Is this a bug in the javax.ws.rs.core.UriBuilder?
According to RFC 3986 the character } is not a reserved character and therefore it need not be escaped. It can be escaped with %7D, but that is not necessary.
So both
UriBuilderimplementations behave correctly.