Uploaded image for project: 'FUSE Mediation Router'
  1. FUSE Mediation Router
  2. MR-625

Email attachments not handled correctly by camel-mail when deployed into Fuse ESB 7.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Critical
    • 2.9.0-fuse-01-xx
    • 2.9.0-fuse-00-00
    • None
    • None

    Description

      Email attachments are not handled correctly by the camel-mail component when deployed into Fuse ESB 7.

      The call of a Camel processor to

      exchange.getIn().getAttachments()
      

      always returns no attachments even though the email received contains attachments.
      When calling getAttachments() it will lazily process any attachments present on the email.
      This deep down calls

      javax.activation.DataSourceDateContentHandler.java
      public Object getContent(DataSource ds) throws IOException {
        if (dch != null)
          return dch.getContent(ds);
        else
          return ds.getInputStream();
      }
      

      Full call stack appended below [1].
      However dch is set to null when running inside ESB 7, hence it invokes ds.getInputStream(), which returns an instance of com.sun.mail.imap.IMAPInputStream and not of type javax.mail.internet.MimeMultipart.
      In case of running standalonne, dch is correctly set and hence
      return dch.getContent(ds);
      is called which correctly creates a javax.mail.internet.MimeMultipart instance.

      This instance is then set as the body of the in-message in the Camel exchange.

      Later the test for attachments in Camels MailBinding class checks if the body is of type javax.mail.Multipart. This is not the case when running inside ESB 7, as the body is of type com.sun.mail.imap.IMAPInputStream.

      org.apache.camel.component.mail.MailBinding.java
      public void extractAttachmentsFromMail(Message message, Map<String, DataHandler> map)
        throws MessagingException, IOException {
      
        LOG.trace("Extracting attachments +++ start +++");
      
        Object content = message.getContent();
        if (content instanceof Multipart) {
          extractAttachmentsFromMultipart((Multipart) content, map);
        } else if (content != null) {
         LOG.trace("No attachments to extract as content is not Multipart: " + content.getClass().getName());
        }
      
        LOG.trace("Extracting attachments +++ done +++");
      }
      

      As a result it does not extract any attachments from the email message and the splitter expression does not work.

      [1] full call stack for javax.activation.DataSourceDataContentHandler.getContent():

      Daemon Thread [Camel (243-camel-9) thread #7 - imaps://imap.gmail.com] (Suspended)	
      	javax.activation.DataSourceDataContentHandler.getContent(javax.activation.DataSource) line: 774	
      	javax.activation.DataHandler.getContent() line: 522 [local variables unavailable]	
      	com.sun.mail.imap.IMAPMessage(javax.mail.internet.MimeMessage).getContent() line: 1419	
      	org.apache.camel.component.mail.MailBinding.extractBodyFromMail(org.apache.camel.Exchange, org.apache.camel.component.mail.MailMessage) line: 240	
      	org.apache.camel.component.mail.MailMessage.createBody() line: 96	
      	org.apache.camel.component.mail.MailMessage(org.apache.camel.impl.MessageSupport).getBody() line: 41	
      	org.apache.camel.component.mail.MailMessage(org.apache.camel.impl.MessageSupport).copyFrom(org.apache.camel.Message) line: 135	
      	org.apache.camel.component.mail.MailMessage(org.apache.camel.impl.DefaultMessage).copyFrom(org.apache.camel.Message) line: 52	
      	org.apache.camel.component.mail.MailMessage.copyFrom(org.apache.camel.Message) line: 130	
      	org.apache.camel.component.mail.MailMessage(org.apache.camel.impl.MessageSupport).copy() line: 124	
      	org.apache.camel.component.mail.MailMessage.copy() line: 56	
      	org.apache.camel.component.mail.MailMessage.copy() line: 33	
      	org.apache.camel.impl.DefaultUnitOfWork.<init>(org.apache.camel.Exchange, org.slf4j.Logger) line: 91	
      	org.apache.camel.impl.DefaultUnitOfWork.<init>(org.apache.camel.Exchange) line: 71	
      	org.apache.camel.processor.UnitOfWorkProcessor.createUnitOfWork(org.apache.camel.Exchange) line: 190	
      	org.apache.camel.processor.UnitOfWorkProcessor.process(org.apache.camel.Exchange, org.apache.camel.AsyncCallback) line: 102	
      	org.apache.camel.processor.RouteInflightRepositoryProcessor.processNext(org.apache.camel.Exchange, org.apache.camel.AsyncCallback) line: 50	
      	org.apache.camel.processor.RouteInflightRepositoryProcessor(org.apache.camel.processor.DelegateAsyncProcessor).process(org.apache.camel.Exchange, org.apache.camel.AsyncCallback) line: 90	
      	org.apache.camel.util.AsyncProcessorHelper.process(org.apache.camel.AsyncProcessor, org.apache.camel.Exchange, org.apache.camel.AsyncCallback) line: 73	
      	org.apache.camel.management.InstrumentationProcessor(org.apache.camel.processor.DelegateAsyncProcessor).processNext(org.apache.camel.Exchange, org.apache.camel.AsyncCallback) line: 99	
      	org.apache.camel.management.InstrumentationProcessor(org.apache.camel.processor.DelegateAsyncProcessor).process(org.apache.camel.Exchange, org.apache.camel.AsyncCallback) line: 90	
      	org.apache.camel.management.InstrumentationProcessor.process(org.apache.camel.Exchange, org.apache.camel.AsyncCallback) line: 71	
      	org.apache.camel.util.AsyncProcessorHelper.process(org.apache.camel.AsyncProcessor, org.apache.camel.Exchange) line: 99	
      	org.apache.camel.management.InstrumentationProcessor(org.apache.camel.processor.DelegateAsyncProcessor).process(org.apache.camel.Exchange) line: 86	
      	org.apache.camel.component.mail.MailConsumer.processExchange(org.apache.camel.Exchange) line: 296	
      	org.apache.camel.component.mail.MailConsumer.processBatch(java.util.Queue<java.lang.Object>) line: 199	
      	org.apache.camel.component.mail.MailConsumer.poll() line: 121	
      	org.apache.camel.component.mail.MailConsumer(org.apache.camel.impl.ScheduledPollConsumer).doRun() line: 139	
      	org.apache.camel.component.mail.MailConsumer(org.apache.camel.impl.ScheduledPollConsumer).run() line: 91	
      	java.util.concurrent.Executors$RunnableAdapter<T>.call() line: 441	
      	java.util.concurrent.FutureTask$Sync.innerRunAndReset() line: 317	
      	java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask<V>(java.util.concurrent.FutureTask<V>).runAndReset() line: 150	
      	java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask<V>.access$101(java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask) line: 98	
      	java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask<V>.runPeriodic() line: 180	
      	java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask<V>.run() line: 204	
      	java.util.concurrent.ThreadPoolExecutor$Worker.runTask(java.lang.Runnable) line: 886	
      	java.util.concurrent.ThreadPoolExecutor$Worker.run() line: 908	
      	java.lang.Thread.run() line: 680	
      

      Attachments

        Activity

          People

            cibsen@redhat.com Claus Ibsen
            rhn-support-tmielke Torsten Mielke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: