Camel
  1. Camel
  2. CAMEL-5456

Context scoped exception clauses incorrectly applying across RouteBuilders

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.10.0
    • Fix Version/s: 2.9.4, 2.10.2, 2.11.0
    • Component/s: camel-core
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      The attached patch shows a bug in the DefaultExceptionPolicyStrategy or the way ExceptionPolicys are added to a RouteBuilder's errorhandler.

      In ContextScopedOnExceptionMultipleRouteBuildersReverseTest, the ordering of the routes causes the onException(IllegalArgumentException.class) to added to the ExceptionProcessors for the direct:foo-RouteBuilder. When the route is run, the OnExceptionDefinition matches exactly on the exception-type, despite this OnExceptionDefiniton being registered on a different RouteBuilder. As far as we can tell, the processor is later ignored because it's identified as being from a different route-context.

      We have attached corresponding tests for camel-spring that show that the issue is tied to alphabetical ordering of RouteBuilders when using contextscan.

      1. camel-spring-context-scope-bug.patch
        10 kB
        Andreas Jacobsen
      2. camel-core-context-scope-bug.patch
        9 kB
        Andreas Jacobsen

        Activity

        Andreas Jacobsen created issue -
        Andreas Jacobsen made changes -
        Field Original Value New Value
        Attachment camel-core-context-scope-bug.patch [ 12537315 ]
        Attachment camel-spring-context-scope-bug.patch [ 12537316 ]
        Willem Jiang made changes -
        Assignee Willem Jiang [ njiang ]
        Hide
        Willem Jiang added a comment - - edited

        Hi Andreas,

        If you are using Context scoped exception clause,the error handler will be affect across the CamelContext, as the JAVA DSL onException() is called one by one in the two different route builder, the route will be effected different if the onException is called in different sequences. I don't think there is way to fix it in JAVA DSL, unless we setup the context scoped exception in one RouteBuilders or using the route scoped exception clauses.

        The error the test can be fixed by setting the onException to be route scoped like the one I just committed a fixed test[1] into the trunk.

        [1] http://svn.apache.org/viewvc?rev=1375896&view=rev

        Show
        Willem Jiang added a comment - - edited Hi Andreas, If you are using Context scoped exception clause,the error handler will be affect across the CamelContext, as the JAVA DSL onException() is called one by one in the two different route builder, the route will be effected different if the onException is called in different sequences. I don't think there is way to fix it in JAVA DSL, unless we setup the context scoped exception in one RouteBuilders or using the route scoped exception clauses. The error the test can be fixed by setting the onException to be route scoped like the one I just committed a fixed test [1] into the trunk. [1] http://svn.apache.org/viewvc?rev=1375896&view=rev
        Hide
        Andreas Jacobsen added a comment -

        It can't possibly be correct that route-context-scoped exception clauses are dependent on the order of the routes they are tied to. That's insane.

        Show
        Andreas Jacobsen added a comment - It can't possibly be correct that route-context-scoped exception clauses are dependent on the order of the routes they are tied to. That's insane.
        Hide
        Willem Jiang added a comment -

        That is caused by the onException() are called in different sequence in RouteBuilder.configure method.
        If you are using the spring DSL, you will never have this kind of issue.

           <camel>
              <onException>...</onException>
              <onException>...</onException>
              <route> ... </route>
              <route> ... </route>
           </camel>
        
        Show
        Willem Jiang added a comment - That is caused by the onException() are called in different sequence in RouteBuilder.configure method. If you are using the spring DSL, you will never have this kind of issue. <camel> <onException>...</onException> <onException>...</onException> <route> ... </route> <route> ... </route> </camel>
        Hide
        Andreas Jacobsen added a comment -

        So we've correctly identified a bug in the Java DSL then?

        Show
        Andreas Jacobsen added a comment - So we've correctly identified a bug in the Java DSL then?
        Claus Ibsen made changes -
        Assignee Willem Jiang [ njiang ] Claus Ibsen [ davsclaus ]
        Hide
        Claus Ibsen added a comment -

        Yes this issue is related to Java DSL. It has a slightly different initialization logic than XML DSL etc.

        Show
        Claus Ibsen added a comment - Yes this issue is related to Java DSL. It has a slightly different initialization logic than XML DSL etc.
        Claus Ibsen made changes -
        Fix Version/s 2.11.0 [ 12321695 ]
        Claus Ibsen made changes -
        Fix Version/s 2.9.4 [ 12323142 ]
        Fix Version/s 2.10.2 [ 12323141 ]
        Claus Ibsen made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Claus Ibsen
            Reporter:
            Andreas Jacobsen
          • Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development