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

Camel servlet component throw "IOException: Stream closed" during route processing for HTTP get request with custom processor

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Not A Bug
    • 2.21.0
    • None
    • camel-servlet
    • None
    • Unknown

    Description

      If i just build a simple Route like this to proxy a incoming Get request to external host:

          @Override
          public void configure() throws Exception {
              from(format("servlet://%s?httpMethodRestrict=GET&servletName=%s", RETRIEVE_PATH, servletName))
                      .process((exchange) -> {
                          exchange.getOut().setHeader(Exchange.HTTP_URI, "https://some.external.system/");
                      }).to("https4:something");
          }
      

      The following exception is thrown:

      org.apache.camel.RuntimeCamelException: java.io.IOException: Stream closed
      	at org.apache.camel.http.common.HttpMessage.createBody(HttpMessage.java:80)
      	at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:54)
      	at org.apache.camel.processor.DefaultExchangeFormatter.getBodyTypeAsString(DefaultExchangeFormatter.java:468)
      	at org.apache.camel.processor.DefaultExchangeFormatter.format(DefaultExchangeFormatter.java:126)
      	at org.apache.camel.processor.CamelLogProcessor.process(CamelLogProcessor.java:88)
      	at org.apache.camel.component.log.LogProducer.process(LogProducer.java:40)
      	at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:148)
      	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548)
      	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
      	at org.apache.camel.processor.Pipeline.process(Pipeline.java:138)
      	at org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
      	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
      	at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:97)
      	at org.apache.camel.http.common.CamelServlet.doService(CamelServlet.java:208)
      	at org.apache.camel.http.common.CamelServlet.service(CamelServlet.java:78)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      	at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:110)
      	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
      	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      	at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:108)
      	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      	at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)
      	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
      	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      	at org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:106)
      	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
      	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
      	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
      	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
      	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
      	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
      	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
      	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
      	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
      	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
      	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
      	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      	at java.lang.Thread.run(Thread.java:748)
      Caused by: java.io.IOException: Stream closed
      	at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:346)
      	at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:152)
      	at org.apache.camel.util.IOHelper.copy(IOHelper.java:202)
      	at org.apache.camel.util.IOHelper.copy(IOHelper.java:174)
      	at org.apache.camel.util.IOHelper.copyAndCloseInput(IOHelper.java:234)
      	at org.apache.camel.util.IOHelper.copyAndCloseInput(IOHelper.java:230)
      	at org.apache.camel.http.common.HttpHelper.readResponseBodyFromInputStream(HttpHelper.java:245)
      	at org.apache.camel.http.common.HttpHelper.readRequestBodyFromServletRequest(HttpHelper.java:196)
      	at org.apache.camel.http.common.DefaultHttpBinding.parseBody(DefaultHttpBinding.java:577)
      	at org.apache.camel.http.common.HttpMessage.createBody(HttpMessage.java:78)
      	... 60 more
      

      Workaround / Additional notice:

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            thopap Thomas Papke
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: