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

Using SpringBoot HealthEndpoint bean throws AmbiguousMethodCallException

Agile BoardAttach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Unknown

    Description

      I'm trying to re-use the Springboot Actuator HealthEndpoint and InfoEndpoint beans and exposing them via rest:

      @Autowired
      HealthEndpoint healthEndpoint;
      ...
      //build the route
      from("rest:get:health").routeId("REST-healthcheck").bean(healthEndpoint, "invoke");
      

      However when that gets invoked, it throws a AmbiguousMethodCallException and its other candidate for "invoke()" is on the abstract class that HealthEndpoint is extending

      It looks like the issue is here:
      https://github.com/apache/camel/blob/master/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java#L1020

      In this case HealthEndpoint extends AbstractHealthEndpoint, which is abstract, but invoke() is declared on the Endpoint interface. So this logic:

       !isFromInterface && Modifier.isAbstract(info.getMethod().getModifiers()) 

      Will not evaluate to true, and the abstract method will remain a candidate.

      Here are the sources for the Endpoint/HealthEndpoint/AbstractEndpoint classes:

      https://github.com/spring-projects/spring-boot/blob/master/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/Endpoint.java#L56

      https://github.com/spring-projects/spring-boot/blob/master/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/AbstractEndpoint.java#L32

      https://github.com/spring-projects/spring-boot/blob/master/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/HealthEndpoint.java#L36

      It seems this is intentional, due to the "if the class is an interface then keep the method" comment in BeanInfo.
      I'm curious as to why that is.

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            davsclaus Claus Ibsen
            charms Colin Harms
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment