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

BeanEndpoint fails in the presence of bridge methods

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6.1
    • 1.6.2, 2.1.0
    • camel-core
    • None
    • Java SE 5

    Description

      When a message is sent to a bean: endpoint, camel searches for a method with the right signature. If multiple methods are found, an exception is thrown.

      If a have an interface like

      public interface <T> I {
      T function(T arg);
      }

      and a class like

      public class C implements I<Number> {
      Number function(Number arg)

      { return new Double(arg.doubleValue() * 2); }
      }

      then I can't use an instance of C as an endpoint.

      The problem is that under the hood java has created a bridge method, and the "real" class C looks like

      public class C implements I<Number> {
      Number function(Number arg) { return new Double(arg.doubleValue() * 2); }

      Object function(Object arg)

      { return function((Number) arg); }

      }

      Camel then discovers that there are two methods it could call (f(Object) and f(Number)) and throws an exception even though there's no real ambiguity because both methods do the same thing.

      I recommend rejecting bridge methods in BeanInfo.isValidMethod with somehting like

      if (method.isBridgeMethod()) return false;

      Does this sound reasonable?

      Attachments

        Activity

          People

            hadrian Hadrian Zbarcea
            adambrewster Adam Brewster
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 20h
                20h
                Remaining:
                Remaining Estimate - 20h
                20h
                Logged:
                Time Spent - Not Specified
                Not Specified