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

maximumRedeliveries is inherited for other exceptions thrown while redelivering with maximumRedeliveries(-1)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.9.0, 2.10.0
    • 2.9.4, 2.10.2, 2.11.0
    • camel-core
    • None
    • Patch Available
    • Unknown

    Description

      Given a route:

      from("direct:source")
         .onException(FirstException.class)
               .handled(true)
               .maximumRedeliveries(-1)
          .end()
          .onException(SecondException.class)
              .handled(true)
              .to("direct:error")
          .end()
          .to("direct:destination");
      

      If the consumer of direct:destination throws a FirstException, the message will be redelivered. Now if a SecondException is thrown while redelivering the message to direct:destination, it does NOT go to direct:error, as you would expect, but is redelivered again; using the same RedeliveryPolicy as for FirstException.

      I have attached a test that illustrates this.

      In OnExceptionDefinition.createRedeliveryPolicy, maximumRedeliveries is set to 0 if the OnExceptionDefinition has outputs and the parent RedeliveryPolicy has explicitly set maximumRedeliveries > 0. The latter check fails when maximumRedeliveries is -1 (infinite retries), and the parent RedeliveryPolicy is returned.

      I have attached a patch that ensures that we don't inherit the parent maximumRedeliveries even if it is set to -1.

      Attachments

        1. redeliverypolicy-on-exception-while-redelivering-fix.patch
          1 kB
          Øyvind Ingebrigtsen Øvergaard
        2. redeliverypolicy-on-exception-while-redelivering-test.patch
          3 kB
          Øyvind Ingebrigtsen Øvergaard

        Activity

          People

            davsclaus Claus Ibsen
            oyvindio Øyvind Ingebrigtsen Øvergaard
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: