If a String piped into LinkBuilderSupport.slash(…) is empty, the call to UriComponentsBuilder.fromUriString(…) fails with an assertion exception. We now guard against this specific case by returning the current builder instance in case an empty String (potentially returned from the toString() method of the object handed in) would be handed to the UriComponentsBuilder.
The issue was introduced by commit 84efebc7a6.
This commit is contained in:
@@ -21,6 +21,7 @@ import org.springframework.hateoas.Identifiable;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.LinkBuilder;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.util.UriComponents;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
@@ -59,7 +60,13 @@ public abstract class LinkBuilderSupport<T extends LinkBuilder> implements LinkB
|
||||
return slash((Identifiable<?>) object);
|
||||
}
|
||||
|
||||
UriComponents components = UriComponentsBuilder.fromUriString(object.toString()).build();
|
||||
String path = object.toString();
|
||||
|
||||
if (!StringUtils.hasText(path)) {
|
||||
return getThis();
|
||||
}
|
||||
|
||||
UriComponents components = UriComponentsBuilder.fromUriString(path).build();
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromUri(uriComponents.toUri());
|
||||
|
||||
for (String pathSegment : components.getPathSegments()) {
|
||||
|
||||
Reference in New Issue
Block a user