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

Bjørn Ole Myrold updated CAMEL-17844:
-------------------------------------
    Description: 
Version 3.4.1 introduced fixes in regards to how BeanInfo gets built, this 
seems to break beans which are @FunctionalInterfaces.
I believe it was introduced with 
https://issues.apache.org/jira/browse/CAMEL-15278

The fix created in the above case only handles super classes, and does not look 
at interfaces. A lambda cast to a FunctionalInterface will only provide Object 
as super class, and BeanInfo will then not find any methods marked with 
@Handler in the interface.

 

This works in 3.4.0, but not in 3.4.1 or higher
{code:java}
public class TestRoute extends RouteBuilder {


    @Override public void configure() throws Exception {
        from("direct:testRoute").id("TestRoute")
            .setBody().method((Formatter) a -> String.format("%s %s", 
a.getName(), a.getOtherName()))
            .to("direct:testEndpoint");
    }

    @FunctionalInterface
    public interface Formatter {
        @Handler String test(@Body RandomPojo t);
    }
} {code}

  was:
Version 3.4.1 introduced fixes in regards to how `BeanInfo` gets built, this 
seems to break beans which are `@FunctionalInterface`s.

I believe it was introduced with 
https://issues.apache.org/jira/browse/CAMEL-15278

The fix created in the above case only handles super classes, and does not look 
at interfaces. A lambda cast to a `FunctionalInterface` will only provide 
`Object` as super class, and `BeanInfo` will then not find any methods marked 
with `@Handler` in the interface.

 

This works in 3.4.0, but not in 3.4.1
{code:java}
public class TestRoute extends RouteBuilder {


    @Override public void configure() throws Exception {
        from("direct:testRoute").id("TestRoute")
            .setBody().method((Formatter) a -> String.format("%s %s", 
a.getName(), a.getOtherName()))
            .to("direct:testEndpoint");
    }

    @FunctionalInterface
    public interface Formatter {
        @Handler String test(@Body RandomPojo t);
    }
} {code}


> camel-bean: @Handler annotation doesn't work with FunctionalInterfaces
> ----------------------------------------------------------------------
>
>                 Key: CAMEL-17844
>                 URL: https://issues.apache.org/jira/browse/CAMEL-17844
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-bean
>    Affects Versions: 3.4.1
>            Reporter: Bjørn Ole Myrold
>            Priority: Major
>
> Version 3.4.1 introduced fixes in regards to how BeanInfo gets built, this 
> seems to break beans which are @FunctionalInterfaces.
> I believe it was introduced with 
> https://issues.apache.org/jira/browse/CAMEL-15278
> The fix created in the above case only handles super classes, and does not 
> look at interfaces. A lambda cast to a FunctionalInterface will only provide 
> Object as super class, and BeanInfo will then not find any methods marked 
> with @Handler in the interface.
>  
> This works in 3.4.0, but not in 3.4.1 or higher
> {code:java}
> public class TestRoute extends RouteBuilder {
>     @Override public void configure() throws Exception {
>         from("direct:testRoute").id("TestRoute")
>             .setBody().method((Formatter) a -> String.format("%s %s", 
> a.getName(), a.getOtherName()))
>             .to("direct:testEndpoint");
>     }
>     @FunctionalInterface
>     public interface Formatter {
>         @Handler String test(@Body RandomPojo t);
>     }
> } {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to