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

camel-core - Checking redelivery reference while error handler creation

    XMLWordPrintableJSON

Details

    • Unknown

    Description

      The default error handler can have a reference to a redelivery policy, but the `DefaultErrorHandlerReifier` first calls the getter `getRedeliveryPolicy()`, which always returns or creates a redelivery policy.

      from `DefaultErrorHandlerReifier`

          private RedeliveryPolicy resolveRedeliveryPolicy(DefaultErrorHandlerDefinition definition, CamelContext camelContext) {
              RedeliveryPolicy answer = null;
              RedeliveryPolicyDefinition def = definition.getRedeliveryPolicy(); // THIS ROW
              if (def != null)
      {             answer = ErrorHandlerReifier.createRedeliveryPolicy(def, camelContext, null);         }
              if (def == null && definition.getRedeliveryPolicyRef() != null) {             answer = mandatoryLookup(definition.getRedeliveryPolicyRef(), RedeliveryPolicy.class);         }
              if (answer == null) {             answer = RedeliveryPolicy.DEFAULT_POLICY;         }
              return answer;
          }
      

      from `DefaultErrorHandlerDefinition`

      
          public RedeliveryPolicyDefinition getRedeliveryPolicy() {
              if (redeliveryPolicy == null) {             redeliveryPolicy = createRedeliveryPolicy();         }
              return redeliveryPolicy;
          }

      That is, the execution will never reach the check of the code for the presence of a link. Therefore, I assume that the link to the redelivery policy does not work in the default handler.

      I assume a similar problem in other types of handlers with redeliverty, for example, in `DeadLetterChannelReifier`

         

      private RedeliveryPolicy resolveRedeliveryPolicy(DeadLetterChannelDefinition definition, CamelContext camelContext) {
              RedeliveryPolicy answer = null;
              RedeliveryPolicyDefinition def = definition.getRedeliveryPolicy();
              if (def == null && definition.getRedeliveryPolicyRef() != null) {  // FIRST CHECK THE REF!!             // ref may point to a definition             def = lookupByNameAndType(definition.getRedeliveryPolicyRef(), RedeliveryPolicyDefinition.class);         }
              if (def != null) {             answer = ErrorHandlerReifier.createRedeliveryPolicy(def, camelContext, null);         }
       
              if (def == null && definition.getRedeliveryPolicyRef() != null)
      {             answer = mandatoryLookup(definition.getRedeliveryPolicyRef(), RedeliveryPolicy.class);         }
              if (answer == null)
      {             answer = RedeliveryPolicy.DEFAULT_POLICY;         }
              return answer;
          }
      

      it inherits `DefaultErrorHandlerDefinition` without overriding `getRedeliveryPolicy`
      ```java
      public class DeadLetterChannelDefinition extends DefaultErrorHandlerDefinition
      ```
       
      https://camel.zulipchat.com/#narrow/stream/257298-camel/topic/Possible.20bug.20while.20checking.20redelivery.20reference

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            dmitriiantonov Dmitrii Antonov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: