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

DefaultConfigurerResolver always resolves to ExtendedCamelContextConfigurer if name contains CamelContext

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 3.6.0
    • 3.7.0
    • camel-core
    • None
    • Unknown

    Description

      DefaultConfigurerResolver uses a special fallback for configurer names containing the string CamelContext, that tries to resolve a configurer against ExtendedCamelContext FQCN, that usually results into a ExtendedCamelContextConfigurer.

      In some cases this can lead to ClassCastException due to an explicit cast to ExtendedCamelContext in ExtendedCamelContextConfigurer.configure, for example when using PropertyBindingSupport.

      Trying to to bind a target bean whose FQCN contains CamelContext (eg my.package.ClassNameWithCamelContextInside) fails with the following exception:

      Caused by: java.lang.ClassCastException: class my.package.ClassNameWithCamelContextInside cannot be cast to class org.apache.camel.ExtendedCamelContext (my.package.ClassNameWithCamelContextInside and org.apache.camel.ExtendedCamelContext are in unnamed module of loader 'app')
       at org.apache.camel.impl.ExtendedCamelContextConfigurer.configure(ExtendedCamelContextConfigurer.java:94)
       at org.apache.camel.support.PropertyBindingSupport.setSimplePropertyViaConfigurer(PropertyBindingSupport.java:847)

      The problem seems to be in the following snippet

      if (name.contains("CamelContext")) {
       // fallback special for camel context itself as we have an extended configurer
       type = findConfigurer(ExtendedCamelContext.class.getName(), context);
       }

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              mcollovati Marco Collovati
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: