You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2021/08/21 10:43:00 UTC

[jira] [Resolved] (CAMEL-16878) using breadcrumbs can cause ClassCastException in MailBinding

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

Claus Ibsen resolved CAMEL-16878.
---------------------------------
    Fix Version/s: 3.11.2
         Assignee: Claus Ibsen
       Resolution: Fixed

Thanks for reporting and explaining how you run this with Camel.

> using breadcrumbs can cause ClassCastException in MailBinding
> -------------------------------------------------------------
>
>                 Key: CAMEL-16878
>                 URL: https://issues.apache.org/jira/browse/CAMEL-16878
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-mail
>            Reporter: Rik van Ballegooijen
>            Assignee: Claus Ibsen
>            Priority: Major
>             Fix For: 3.11.2, 3.12.0
>
>
> ClassCastException: class org.apache.camel.component.directvm.DirectVmEndpoint cannot be cast to class org.apache.camel.component.mail.MailEndpoint
>  
> This is caused by:
>  
> {code:java}
> MailConfiguration mailConfiguration = ((MailEndpoint) exchange.getFromEndpoint()).getConfiguration();{code}
> Which assumes the exchanges endpoint is always a MailEndpoint.
>  
> This piece of code from DefaultUnitOfWork will trigger the init of headers:
> {code:java}
> if (useBreadcrumb) {
>     // create or use existing breadcrumb
>     String breadcrumbId = exchange.getIn().getHeader(Exchange.BREADCRUMB_ID, String.class);
>     if (breadcrumbId == null) {
>         // no existing breadcrumb, so create a new one based on the exchange id
>         breadcrumbId = exchange.getExchangeId();
>         exchange.getIn().setHeader(Exchange.BREADCRUMB_ID, breadcrumbId);
>     }
> }
> {code}
> If message is of type MailMessage, it will be delegated there:
> {code:java}
> MailBinding binding = ExchangeHelper.getBinding(getExchange(), MailBinding.class);
> if (binding != null) {
>     map.putAll(binding.extractHeadersFromMail(mailMessage, getExchange()));
> }
> {code}
> This works for the initial route with a from imaps, but in a subroute the error occurs.
>  
> Possible solution could be to pass a reference to either the mail endpoint or mail configuration to the binding on create/set.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)