camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Brewster (JIRA)" <j...@apache.org>
Subject [jira] Updated: (CAMEL-1922) BeanEndpoint fails in the presence of bridge methods
Date Sat, 22 Aug 2009 20:47:36 GMT

     [ https://issues.apache.org/activemq/browse/CAMEL-1922?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Adam Brewster updated CAMEL-1922:
---------------------------------

    Attachment: 0002-Unit-test.patch

Sorry for last night's rant.  Maybe I was just upset about the score of the game I was watching.

Here's what I've got for a unit test.  It's a bit more complicated than I expected.  I tried
out simpler versions, but this was the only one that actually failed the unpatched code (error'ed
it actually).

Maybe the awkwardness of the unit test required to catch this issue speaks to the setup I
was using when I discovered the problem in the first place.

This (like the first patch I posted) is against tags/camel-1.6.1.  I'm still working on getting
2.0 to do something useful.

@Hadrian,
According to [the docs|http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html]
{{mvn test}} ought to validate and compile (and do a dozen other things) before attempting
to test.

bq.  if you call a build phase, it will execute not only that build phase, but also every
build phase prior to the called build phase

@Willem,
also note

bq. # test - test the compiled source code using a suitable unit testing framework. These
tests should not require the code be packaged or deployed

> BeanEndpoint fails in the presence of bridge methods
> ----------------------------------------------------
>
>                 Key: CAMEL-1922
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1922
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 1.6.1
>         Environment: Java SE 5
>            Reporter: Adam Brewster
>            Assignee: Hadrian Zbarcea
>         Attachments: 0001-Reject-bridge-methods-while-introspecting-POJO-consu.patch,
0002-Unit-test.patch
>
>   Original Estimate: 2 days
>  Remaining Estimate: 2 days
>
> 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?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message