Skip to content

Explicitly mention proper URL-escaping in RestTemplate, UriTemplate, and UriComponents API Javadoc [SPR-10497] #15130

@spring-projects-issues

Description

@spring-projects-issues

Archie Cobbs opened SPR-10497 and commented

When examining the Javadoc for RestTemplate, it's not clear from reading it whether the replaced parameters are going to be properly escaped.

Same goes for UriTemplate and UriComponents. To verify this, I finally had to write a test case.

Suggest mentioning this explicitly and/or changing the examples to include an "unsafe" argument. For example, instead of this:

Map<String, String> uriVariables = new HashMap<String, String>();
uriVariables.put("booking", "42");
uriVariables.put("hotel", "1");

-> http://example.com/hotels/1/bookings/42

You could say this:

Map<String, String> uriVariables = new HashMap<String, String>();
uriVariables.put("booking", "42");
uriVariables.put("hotel", "Rest&Relax");

-> http://example.com/hotels/Rest%26Relax/bookings/42

Just a little something that would have saved me some time and worry.


Affects: 3.2.2

Referenced from: commits 5859649, c4d7976

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions