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

using breadcrumbs can cause ClassCastException in MailBinding

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 3.11.2, 3.12.0
    • camel-mail
    • None
    • Unknown

    Description

      ClassCastException: class org.apache.camel.component.directvm.DirectVmEndpoint cannot be cast to class org.apache.camel.component.mail.MailEndpoint

       

      This is caused by:

       

      MailConfiguration mailConfiguration = ((MailEndpoint) exchange.getFromEndpoint()).getConfiguration();

      Which assumes the exchanges endpoint is always a MailEndpoint.

       

      This piece of code from DefaultUnitOfWork will trigger the init of headers:

      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);
          }
      }
      

      If message is of type MailMessage, it will be delegated there:

      MailBinding binding = ExchangeHelper.getBinding(getExchange(), MailBinding.class);
      if (binding != null) {
          map.putAll(binding.extractHeadersFromMail(mailMessage, getExchange()));
      }
      

      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.

       

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            rikvb Rik van Ballegooijen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: