Description
The method LinkBuilderImpl#link(String) has a bug when in url between "<" and ">" a matrix parameter (begins with ";") is occuring.
Then the tokenizer splits the url at ";" and no "UriBuilder.fromUri" is called.
when accessing "ub" in getResolvedUri, a NullPointerException is thrown.
Example:
- LinkHeader Entry:
<http://localhost:8080/something/subresource;type=null?index=0&max=null>;rel="all";title="Read all resources";type="application/json";verb="GET"
- StackTrace:
java.lang.NullPointerException
at org.apache.cxf.jaxrs.impl.LinkBuilderImpl.getResolvedUri(LinkBuilderImpl.java:58)
at org.apache.cxf.jaxrs.impl.LinkBuilderImpl.build(LinkBuilderImpl.java:46)
at javax.ws.rs.core.Link.valueOf(Link.java:174)
at org.apache.cxf.jaxrs.impl.ResponseImpl.getAllLinks(ResponseImpl.java:362)
at org.apache.cxf.jaxrs.impl.ResponseImpl.getLink(ResponseImpl.java:305)
Following Patch of "LinkBuilderImpl#link(String)" supports this case:
@Override
public Builder link(String link) {
String[] tokens = StringUtils.split(link, ";");
String potentialUrlPart = null;
for (String token : tokens) {
if (potentialUrlPart != null)
{ token = potentialUrlPart + token; potentialUrlPart = null; }String theToken = token.trim();
if (theToken.startsWith("<") && theToken.endsWith(">"))
{ ub = UriBuilder.fromUri(theToken.substring(1, theToken.length() - 1)); } else {
int i = theToken.indexOf('=');
if (i != -1)
else
{ potentialUrlPart = token; } }
}
return this;
}