#369 - Traverson no defensively expands URIs handed to getAndFindLinkWithRel(…).

This commit is contained in:
Oliver Gierke
2015-07-21 11:17:52 +02:00
parent 07a5620d9f
commit e9d83c5c48
2 changed files with 12 additions and 2 deletions

View File

@@ -79,6 +79,15 @@ public class Hop {
return new Hop(rel, parameters);
}
/**
* Returns whether the {@link Hop} has parameters declared.
*
* @return
*/
boolean hasParameters() {
return !this.parameters.isEmpty();
}
/**
* Create a new {@link Map} starting with the supplied template parameters. Then add the ones for this hop. This
* allows a local hop to override global parameters.

View File

@@ -391,8 +391,9 @@ public class Traverson {
}
HttpEntity<?> request = prepareRequest(headers);
UriTemplate template = new UriTemplate(uri);
ResponseEntity<String> responseEntity = operations.exchange(uri, GET, request, String.class);
ResponseEntity<String> responseEntity = operations.exchange(template.expand(), GET, request, String.class);
MediaType contentType = responseEntity.getHeaders().getContentType();
String responseBody = responseEntity.getBody();
@@ -409,7 +410,7 @@ public class Traverson {
/**
* Don't expand if the parameters are empty
*/
if (thisHop.getParameters().isEmpty()) {
if (!thisHop.hasParameters()) {
return getAndFindLinkWithRel(link.getHref(), rels);
} else {
return getAndFindLinkWithRel(link.expand(thisHop.getMergedParameters(templateParameters)).getHref(), rels);