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

After upgrade to Camel 3.11.0. Cannot write to HttpServletResponse when aggregator is used.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Not A Bug
    • 3.11.1, 3.11.0
    • 3.11.3, 3.12.0
    • None
    • None
    • Unknown

    Description

      To easily reproduce issue. We have created this mini repo:

      https://github.com/bugs84/springboot-camel-httpoutput-issue/tree/camel-minimal-sample

      Description is in README.md

       

      Issue description:

      We are experiencing issue in our project after upgrading Apache Camel from version 3.10.0 to 3.11.0 (3.11.1 has the same issue). The same route which worked without any problems in previous versions, does not work now. We managed to simplify the route from our project and simulate the problem on this simplified route.

       

      String synchronizerEndpoint = "direct:synchronizer";
      String httpOutputEndpoint = "direct:httpOutput";
      
      // HTTP Input
      from("servlet:///httpIssue?httpMethodRestrict=GET&servletName=CamelServlet")
              .log("Http request received")
              .process(new CorrelationIdGenerator())
              .to(synchronizerEndpoint);
      
      // Parallel Synchronizer
      from(synchronizerEndpoint)
              .log("Parallel Synchronizer")
              .setHeader("scaler-sync-correlation", correlationExpression)
              .aggregate(correlationExpression, new MyRoutesAggregator())
              .completionSize(1)
              .to(httpOutputEndpoint);
      
      // HTTP Output
      from(httpOutputEndpoint)
              .log("HTTP Output")
              .process(new ProcessHttpOutput());
      

       n ProcessHttpOutput processor we are writing the response into the OutputStream:

      private static class ProcessHttpOutput implements Processor {
          @Override
          public void process(Exchange exchange) throws Exception {
              HttpServletResponse response = exchange.getMessage().getBody(HttpMessage.class).getResponse();
              response.setStatus(200);
              try (ServletOutputStream outputStream = response.getOutputStream()) {
                  outputStream.write(("Response").getBytes(StandardCharsets.UTF_8));
                  outputStream.flush();
              }
          }
      }
      

      If we run this route on Camel version 3.11.0. We are getting NullPointerException during flushing / closing the stream. It works without any problems on 3.10.0.

      The problem is if aggregation is in the route (without aggregation it works fine). After aggregation, it is not possible to write to the output stream.

      Attachments

        Activity

          People

            Unassigned Unassigned
            bugs_ Jan Vondrouš
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: