Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-7210

StringIndexOutOfBoundsException during construction of failover request

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • None
    • 3.1.10, 3.2.0
    • JAX-RS
    • None
    • Unknown

    Description

      In AbstractClient we have the following:

      UriBuilder builder = new UriBuilderImpl().uri(newBaseURI);
      String basePath = reqURIPath.startsWith(baseURIPath) ? baseURIPath : getBaseURI().getRawPath(); 
      builder.path(reqURIPath.equals(basePath) ? "" : reqURIPath.substring(basePath.length()));
      

      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:

      Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -7
        at java.lang.String.substring(String.java:1875)
        at org.apache.cxf.jaxrs.client.AbstractClient.calculateNewRequestURI(AbstractClient.java:652)
        at org.apache.cxf.jaxrs.client.AbstractClient.calculateNewRequestURI(AbstractClient.java:642)
        at org.apache.cxf.jaxrs.client.AbstractClient.retryInvoke(AbstractClient.java:688)
        at org.apache.cxf.jaxrs.client.AbstractClient$RetryableImpl.invoke(AbstractClient.java:1174)
        at org.apache.cxf.clustering.FailoverTargetSelector.performFailover(FailoverTargetSelector.java:207)
        at org.apache.cxf.clustering.FailoverTargetSelector.complete(FailoverTargetSelector.java:166)
        at org.talend.esb.servicelocator.cxf.internal.LocatorTargetSelector.complete(LocatorTargetSelector.java:57)
        at org.apache.cxf.jaxrs.client.AbstractClient.preProcessResult(AbstractClient.java:575)
      

      Attachments

        Issue Links

          Activity

            People

              ffang Freeman Yue Fang
              sebhoss Sebastian Hoß
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: