You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Christoph Berg (JIRA)" <ji...@apache.org> on 2015/11/18 16:05:11 UTC
[jira] [Created] (CXF-6683) LinkBuilderImpl build strips last path
segment with baseUri set
Christoph Berg created CXF-6683:
-----------------------------------
Summary: LinkBuilderImpl build strips last path segment with baseUri set
Key: CXF-6683
URL: https://issues.apache.org/jira/browse/CXF-6683
Project: CXF
Issue Type: Bug
Components: JAX-RS
Affects Versions: 3.1.4
Reporter: Christoph Berg
After I applied the fix I proposed in CXF-6682, I tried building a link to point to a specific entity of a REST resource, e.g. http://localhost:8080/resource/1.
We currently build the Link as follows:
{code}
new LinkBuilderImpl().baseUri("http://localhost:8080/resource/1").rel("self").build();
{code}
I would expect that the Link would then contain the value of the {{baseUri}}, but the last path segment is stripped.
The {{LinkerBuilderImpl#getResolvedUri(Object… values)}} creates an URI, which will have an empty path. If this is given to the {{HttpUtils.resolve}} method, it strips the last path component.
If I change the method to look like this, everything works as expected:
{code}
private URI getResolvedUri(Object... values) {
URI uri = ub.build(values);
if (!uri.isAbsolute() && baseUri != null) {
UriBuilder linkUriBuilder = UriBuilder.fromUri(baseUri);
String path = uri.getPath();
if (path == null || path.isEmpty()) {
return linkUriBuilder.build();
}
return HttpUtils.resolve(linkUriBuilder, uri);
} else {
return uri;
}
}
{code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)