cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <>
Subject [jira] [Commented] (CXF-7210) StringIndexOutOfBoundsException during construction of failover request
Date Wed, 11 Jan 2017 12:42:58 GMT


ASF GitHub Bot commented on CXF-7210:

GitHub user sebhoss opened a pull request:

    [CXF-7210] Fix StringIndexOutOfBoundsException

    The logic goes as follows:
    1) Base- & request-URI are the same, then only add base-URI.
    2) If request-URI starts with base-URI, only add the parts from request-URI that are not
already included in base-URI
    3) Otherwise add both base-URI and request-URI

You can merge this pull request into a Git repository by running:

    $ git pull master

Alternatively you can review and apply these changes as the patch at:

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #221
commit 1a8ae7afb254b77118aba543df2a720547a3ccf2
Author: Sebastian Hoß <>
Date:   2017-01-11T12:39:31Z

    [CXF-7210] Fix StringIndexOutOfBoundsException
    Signed-off-by: Sebastian Hoß <>


> StringIndexOutOfBoundsException during construction of failover request
> -----------------------------------------------------------------------
>                 Key: CXF-7210
>                 URL:
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>            Reporter: Sebastian Hoß
>            Priority: Trivial
> In {{AbstractClient}} we [have the following|]:
> {code}
> UriBuilder builder = new UriBuilderImpl().uri(newBaseURI);
> String basePath = reqURIPath.startsWith(baseURIPath) ? baseURIPath : getBaseURI().getRawPath();

> builder.path(reqURIPath.equals(basePath) ? "" : reqURIPath.substring(basePath.length()));
> {code}
> This covers two out of three potential cases:
> 1) {{baseURIPath}} and {{reqURIPath}} have the same value which will result in only the
base path being added to the builder.
> 2) {{baseURIPath}} and {{reqURIPath}} have a different value in which case the builder
will get the base path and and everything from the request path that is not already included
in the base path.
> What's missing (and what is causing the exception below) is that the base path might
be longer than the request path in which case {{reqURIPath.substring(basePath.length())}}
throws the following stack trace:
> {code}
> Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -7
>   at java.lang.String.substring(
>   at org.apache.cxf.jaxrs.client.AbstractClient.calculateNewRequestURI(
>   at org.apache.cxf.jaxrs.client.AbstractClient.calculateNewRequestURI(
>   at org.apache.cxf.jaxrs.client.AbstractClient.retryInvoke(
>   at org.apache.cxf.jaxrs.client.AbstractClient$RetryableImpl.invoke(
>   at org.apache.cxf.clustering.FailoverTargetSelector.performFailover(
>   at org.apache.cxf.clustering.FailoverTargetSelector.complete(
>   at org.talend.esb.servicelocator.cxf.internal.LocatorTargetSelector.complete(
>   at org.apache.cxf.jaxrs.client.AbstractClient.preProcessResult(
> {code}

This message was sent by Atlassian JIRA

View raw message