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

AbstractListGroupedExchangeAggregationStrategy produces failed exchange if first received exchange fails

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.11.3, 2.12.2
    • 2.12.4, 2.13.1, 2.14.0
    • camel-core
    • None
    • Moderate

    Description

      If the first exchange received by a (concrete implementation of) AggregationStrategy contains an exception, then the result of the aggregation will also contain that exception, and so will not continue routing without error. This makes the first received exchange have an effect that subsequent exchanges do not have.

      The specific use case multicasts to GroupedExchangeAggregationStrategy. The MulticastProcessor.doDone function uses ExchangeHelper.copyResults to copy the aggregated result to the original exchange. The copyResults method copies the exception as well, thereby propagating the error.

      The attached unit test has 3 tests, testAFail, testBFail, and testAllGood. All three of these should pass, but testAFail does not.

      What is happening is that AbstractListAggregationStrategy is directly storing its values on and returning the first exchange:
      public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
      List<V> list;

      if (oldExchange == null)

      { list = getList(newExchange); }

      else

      { list = getList(oldExchange); }

      if (newExchange != null) {
      V value = getValue(newExchange);
      if (value != null)

      { list.add(value); }

      }

      return oldExchange != null ? oldExchange : newExchange;
      }

      The pre-CAMEL-5579 version of GroupedExchangeAggregationStrategy created a fresh exchange to store and return the aggregated exchanges:
      public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
      List<Exchange> list;
      Exchange answer = oldExchange;

      if (oldExchange == null)

      { answer = new DefaultExchange(newExchange); list = new ArrayList<Exchange>(); answer.setProperty(Exchange.GROUPED_EXCHANGE, list); }

      else

      { list = oldExchange.getProperty(Exchange.GROUPED_EXCHANGE, List.class); }

      if (newExchange != null)

      { list.add(newExchange); }

      return answer;
      }

      Attachments

        1. camel-jira7271-test.zip
          3 kB
          Luke Hamaty

        Activity

          People

            davsclaus Claus Ibsen
            wlhamaty Luke Hamaty
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: