Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-8253

CXFRS Throws IndexOutOfBoundsException for Empty Headers

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.14.1
    • 2.13.4, 2.14.2, 2.15.0
    • camel-cxf
    • None
    • Unknown

    Description

      Getting an IndexOutOfBoundsException when empty HTTP request headers are passed to a camelrs web method calls (See stack trace below).

      The culprit appears to be related to the check on line 284 of class DefaultCxfRsBinding.java.

      More specifically here:
      ((List)entry.getValue()).get(0)

      Internally the ArrayList class will perform a range check and if the index is greater than or equal to the size of the list the IndexOutOfBoundsException is thrown.

      So we probably want to add an additional check before this one, something like:

      ((List)entry.getValue()).size() == 0 before the check above, since we probably want to account for empty lists.

      java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
      at java.util.ArrayList.rangeCheck(ArrayList.java:604) ~[na:1.7.0_25]
      at java.util.ArrayList.get(ArrayList.java:382) ~[na:1.7.0_25]
      at org.apache.camel.component.cxf.jaxrs.DefaultCxfRsBinding.copyProtocolHeader(DefaultCxfRsBinding.java:284) ~[camel-cxf-2.14.1.jar:2.14.1]
      at org.apache.camel.component.cxf.jaxrs.DefaultCxfRsBinding.populateExchangeFromCxfRsRequest(DefaultCxfRsBinding.java:116) ~[camel-cxf-2.14.1.jar:2.14.1]
      at org.apache.camel.component.cxf.jaxrs.CxfRsInvoker.syncInvoke(CxfRsInvoker.java:123) ~[camel-cxf-2.14.1.jar:2.14.1]
      at org.apache.camel.component.cxf.jaxrs.CxfRsInvoker.performInvocation(CxfRsInvoker.java:59) ~[camel-cxf-2.14.1.jar:2.14.1]
      at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:97) ~[cxf-core-3.0.2.jar:3.0.2]
      at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:200) [cxf-rt-frontend-jaxrs-3.0.2.jar:3.0.2]
      at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:99) [cxf-rt-frontend-jaxrs-3.0.2.jar:3.0.2]
      at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59) ~[cxf-core-3.0.2.jar:3.0.2]
      at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:96) ~[cxf-core-3.0.2.jar:3.0.2]
      at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307) ~[cxf-core-3.0.2.jar:3.0.2]
      at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) ~[cxf-core-3.0.2.jar:3.0.2]
      at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:243) ~[cxf-rt-transports-http-3.0.2.jar:3.0.2]
      at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:223) ~[cxf-rt-transports-http-3.0.2.jar:3.0.2]
      at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:197) ~[cxf-rt-transports-http-3.0.2.jar:3.0.2]
      at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:149) ~[cxf-rt-transports-http-3.0.2.jar:3.0.2]
      at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:171) ~[cxf-rt-transports-http-3.0.2.jar:3.0.2]
      at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:290) ~[cxf-rt-transports-http-3.0.2.jar:3.0.2]
      at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:214) ~[cxf-rt-transports-http-3.0.2.jar:3.0.2]
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:575) ~[geronimo-servlet_3.0_spec-1.0.jar:1.0]
      at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:265) ~[cxf-rt-transports-http-3.0.2.jar:3.0.2]
      at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:696) ~[jetty-servlet-9.1.0.v20131115.jar:9.1.0.v20131115]
      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1568) ~[jetty-servlet-9.1.0.v20131115.jar:9.1.0.v20131115]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) ~[spring-security-web-3.2.1.RELEASE.jar:3.2.1.RELEASE]
      at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118) ~[spring-security-web-3.2.1.RELEASE.jar:3.2.1.RELEASE]
      at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84) ~[spring-security-web-3.2.1.RELEASE.jar:3.2.1.RELEASE]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) ~[spring-security-web-3.2.1.RELEASE.jar:3.2.1.RELEASE]
      at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) ~[spring-security-web-3.2.1.RELEASE.jar:3.2.1.RELEASE]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) ~[spring-security-web-3.2.1.RELEASE.jar:3.2.1.RELEASE]
      at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113) ~[spring-security-web-3.2.1.RELEASE.jar:3.2.1.RELEASE]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) ~[spring-security-web-3.2.1.RELEASE.jar:3.2.1.RELEASE]
      at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:139) ~[spring-security-web-3.2.1.RELEASE.jar:3.2.1.RELEASE]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) ~[spring-security-web-3.2.1.RELEASE.jar:3.2.1.RELEASE]
      at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154) ~[spring-security-web-3.2.1.RELEASE.jar:3.2.1.RELEASE]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) ~[spring-security-web-3.2.1.RELEASE.jar:3.2.1.RELEASE]
      at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50) ~[spring-security-web-3.2.1.RELEASE.jar:3.2.1.RELEASE]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-3.2.5.RELEASE.jar:3.2.5.RELEASE]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) ~[spring-security-web-3.2.1.RELEASE.jar:3.2.1.RELEASE]
      at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) ~[spring-security-web-3.2.1.RELEASE.jar:3.2.1.RELEASE]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) ~[spring-security-web-3.2.1.RELEASE.jar:3.2.1.RELEASE]
      at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) ~[spring-security-web-3.2.1.RELEASE.jar:3.2.1.RELEASE]
      at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) ~[spring-security-web-3.2.1.RELEASE.jar:3.2.1.RELEASE]
      at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343) ~[spring-web-3.2.5.RELEASE.jar:3.2.5.RELEASE]
      at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260) ~[spring-web-3.2.5.RELEASE.jar:3.2.5.RELEASE]
      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1548) ~[jetty-servlet-9.1.0.v20131115.jar:9.1.0.v20131115]
      at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:524) ~[jetty-servlet-9.1.0.v20131115.jar:9.1.0.v20131115]
      at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) ~[jetty-server-9.1.0.v20131115.jar:9.1.0.v20131115]
      at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:568) ~[jetty-security-9.1.0.v20131115.jar:9.1.0.v20131115]
      at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:221) ~[jetty-server-9.1.0.v20131115.jar:9.1.0.v20131115]
      at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1110) ~[jetty-server-9.1.0.v20131115.jar:9.1.0.v20131115]
      at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:453) ~[jetty-servlet-9.1.0.v20131115.jar:9.1.0.v20131115]
      at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183) ~[jetty-server-9.1.0.v20131115.jar:9.1.0.v20131115]
      at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1044) ~[jetty-server-9.1.0.v20131115.jar:9.1.0.v20131115]
      at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) ~[jetty-server-9.1.0.v20131115.jar:9.1.0.v20131115]
      at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109) ~[jetty-server-9.1.0.v20131115.jar:9.1.0.v20131115]
      at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) ~[jetty-server-9.1.0.v20131115.jar:9.1.0.v20131115]
      at org.eclipse.jetty.server.Server.handle(Server.java:459) ~[jetty-server-9.1.0.v20131115.jar:9.1.0.v20131115]
      at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:280) ~[jetty-server-9.1.0.v20131115.jar:9.1.0.v20131115]
      at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:229) ~[jetty-server-9.1.0.v20131115.jar:9.1.0.v20131115]
      at org.eclipse.jetty.io.AbstractConnection$1.run(AbstractConnection.java:505) ~[jetty-io-9.1.0.v20131115.jar:9.1.0.v20131115]
      at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:607) ~[jetty-util-9.1.0.v20131115.jar:9.1.0.v20131115]
      at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:536) ~[jetty-util-9.1.0.v20131115.jar:9.1.0.v20131115]
      at java.lang.Thread.run(Thread.java:724) ~[na:1.7.0_25]

      Attachments

        Activity

          People

            njiang Willem Jiang
            vrfurl Vincent Furlanetto
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: