You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Sergey Beryozkin (JIRA)" <ji...@apache.org> on 2015/11/05 18:20:27 UTC

[jira] [Resolved] (CXF-6664) NullpointerException in LinkBuilderImpl#getResolvedUri when linkheader url has a matrix parameter

     [ https://issues.apache.org/jira/browse/CXF-6664?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sergey Beryozkin resolved CXF-6664.
-----------------------------------
       Resolution: Fixed
         Assignee: Sergey Beryozkin
    Fix Version/s: 3.2.0
                   3.0.8
                   3.1.5

> NullpointerException in LinkBuilderImpl#getResolvedUri when linkheader url has a matrix parameter
> -------------------------------------------------------------------------------------------------
>
>                 Key: CXF-6664
>                 URL: https://issues.apache.org/jira/browse/CXF-6664
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 3.0.3
>            Reporter: Michael Krenn
>            Assignee: Sergey Beryozkin
>             Fix For: 3.1.5, 3.0.8, 3.2.0
>
>
> 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) {
>                     String name = theToken.substring(0, i);
>                     String value = stripQuotes(theToken.substring(i + 1));
>                     params.put(name, value);
>                 } else {
>                     potentialUrlPart = token;
>                 }
>             }
>         }
>         return this;
>     }



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)