camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Luca Burgazzoli (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (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
Date Fri, 09 Dec 2016 14:29:58 GMT

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

Luca Burgazzoli updated CAMEL-10584:
------------------------------------
    Description: 
In *AutoConfiguration classes generated by camel-package-plugin, there is a check like 

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

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:

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



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

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

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:

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




> spring boot auto configuration mojo: use Class.isAssignableFrom instead of instanceof
as the later may fail at compile time in case of final classes
> ----------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-10584
>                 URL: https://issues.apache.org/jira/browse/CAMEL-10584
>             Project: Camel
>          Issue Type: Improvement
>          Components: tooling
>            Reporter: Luca Burgazzoli
>            Assignee: Luca Burgazzoli
>             Fix For: 2.19.0
>
>
> In *AutoConfiguration classes generated by camel-package-plugin, there is a check like

> {code:java}
> if (myInstance instanceof CamelContextAware) {
>     ((CamelContextAware) dataformat).setCamelContext(camelContext);
> }
> {code}
> 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:
> {code:java}
> if (CamelContextAware.class.isAssignableFrom(MyInstanceType.class)) {
>     CamelContext context = CamelContextAware.class.cast(myInstance);
>     if (context != null) {
>         context.setCamelContext(camelContext);
>     }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message