[
https://issues.apache.org/jira/browse/CXF-6683?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15011277#comment-15011277
]
Sergey Beryozkin commented on CXF-6683:
---------------------------------------
Thanks, well, this is really a side-effect of the fix to 6682, hence I did a
follow up update to CXF-6682, initializing UB later if needed.
Cheers, Sergey
> 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)