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

spring boot auto configuration mojo: use Class.isAssignableFrom instead of instanceof as the later may fail at compile time in case of final classes

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 2.19.0
    • tooling
    • None
    • Unknown

    Description

      In *AutoConfiguration classes generated by camel-package-plugin, there is a check like

      if (myInstance instanceof CamelContextAware) {
          ((CamelContextAware) dataformat).setCamelContext(camelContext);
      }
      

      This check may fail at compile time if myInstance is final and it is not an instance of CamelContextAware which make not possible to write final classes.

      We should do something like:

      if (CamelContextAware.class.isAssignableFrom(MyInstanceType.class)) {
          CamelContextAware context = CamelContextAware.class.cast(myInstance);
          if (context != null) {
              context.setCamelContext(camelContext);
          }
      }
      

      Attachments

        Activity

          People

            lb Luca Burgazzoli
            lb Luca Burgazzoli
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: