We are using Jersey Client 2.21. I am noticing that when we put curly braces (aka curly brackets) as a param value, then it does not get properly encoded. Not only that, but anything inside the curly braces does not get encoded either. This is not true for regular brackets or other unsafe characters that I have tested with.
Please see the example below. In this example I enter three params. A control param with just spaces. One with curly braces, and one with regular brackets.
public static void testJerseyEncoding() {
Client client = ClientBuilder.newClient();
String url = "http://foo.com/path";
Map<String, String> map = new HashMap<>();
map.put("paramWithCurly", " {with a space}");
map.put("paramWithOutCurly", "with a space");
map.put("paramWithBracket", "[with a space]");
WebTarget target = client.target(url);
for (Map.Entry<String, String> entry : map.entrySet()) {
target = target.queryParam(entry.getKey(), entry.getValue());
}
System.out.println(target.toString());
}
Here is the output:
JerseyWebTarget { http://foo.com/path?paramWithBracket=%5Bwith+a+space%5D¶mWithOutCurly=with+a+space¶mWithCurly=+{with a space} }
Is something broken with the Jersey Client or am I missing something? The curly braces should have been encoded to "%7B".