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

Exception thrown when reading a mail with an attached file, which name contains a semicolon

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Workaround
    • 2.15.2
    • Future
    • camel-mail
    • None
    • Unknown

    Description

      Hi,

      I posted this issue in Camel users forum but unfortunately got no response.

      I'm using Camel 2.15.2 with JDK 1.7 under Windows 7 and Eclipse 4.2.2 as development tool.

      My route reads from an IMAP server (IBM Lotus Notes). I have one big problem : when the route handles an email, which contains a PDF attached file with a semicolon in his name (for exemple my;pdf.pdf), then the route always throws this exception :

      Failed to extract body due to: Unable to load BODYSTRUCTURE.

      4.08.15 15:10:11:313 CEST] 00000172 SystemOut O [15:10:11.313] WARN [Camel (Mail vers Indexation) thread #0 - imap://myimapserver.ch] org.apache.camel.util.CamelLogger.log:224 : Caused by: [org.apache.camel.RuntimeCamelException - Failed to extract body due to: Unable to load BODYSTRUCTURE. Exchange: Exchange[MailMessage@0x862446e3]. Message: com.sun.mail.imap.IMAPMessage@16e6c70e]
      org.apache.camel.RuntimeCamelException: Failed to extract body due to: Unable to load BODYSTRUCTURE. Exchange: Exchange[MailMessage@0x862446e3]. Message: com.sun.mail.imap.IMAPMessage@16e6c70e
      at org.apache.camel.component.mail.MailBinding.extractBodyFromMail(MailBinding.java:275) ~[camel-mail-2.15.2.jar:2.15.2]
      at org.apache.camel.component.mail.MailMessage.createBody(MailMessage.java:103) ~[camel-mail-2.15.2.jar:2.15.2]
      at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:41) ~[camel-core-2.15.2.jar:2.15.2]
      at org.apache.camel.component.mail.MailConsumer.createExchanges(MailConsumer.java:326) ~[camel-mail-2.15.2.jar:2.15.2]
      at org.apache.camel.component.mail.MailConsumer.poll(MailConsumer.java:121) ~[camel-mail-2.15.2.jar:2.15.2]
      at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:174) [camel-core-2.15.2.jar:2.15.2]
      at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:101) [camel-core-2.15.2.jar:2.15.2]
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:482) [na:1.7.0]
      at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:315) [na:1.7.0]
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:189) [na:1.7.0]
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [na:1.7.0]
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1156) [na:1.7.0]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:626) [na:1.7.0]
      at java.lang.Thread.run(Thread.java:804) [na:1.7.0]
      Caused by: javax.mail.MessagingException: Unable to load BODYSTRUCTURE
      at com.sun.mail.imap.IMAPMessage.loadBODYSTRUCTURE(IMAPMessage.java:1261) ~[com.ibm.ws.prereq.javamail.jar:na]
      at com.sun.mail.imap.IMAPMessage.getDataHandler(IMAPMessage.java:597) ~[com.ibm.ws.prereq.javamail.jar:na]
      at javax.mail.internet.MimeMessage.getContent(MimeMessage.java:1395) ~[com.ibm.ws.prereq.javamail.jar:na]
      at org.apache.camel.component.mail.MailBinding.extractBodyFromMail(MailBinding.java:247) ~[camel-mail-2.15.2.jar:2.15.2]
      ... 13 common frames omitted

      Here is the route (very simple) :

      @Override
      public void configure() throws Exception

      { from(getPropertiesUri()) /**/.to("log:dummy"); }

      protected String getPropertiesUri() {
      String prefix = Constants.MAIL.concat(provider);
      StringBuilder uri = new StringBuilder();

      uri.append(getContext().getProperties().get(prefix.concat(".protocol"))).append("://");
      uri.append(getContext().getProperties().get(prefix.concat(".host"))).append("?");
      uri.append("username=").append(getContext().getProperties().get(prefix.concat(".user")));
      uri.append("&password=").append(getContext().getProperties().get(prefix.concat(".password")));
      uri.append("&folderName=").append(getContext().getProperties().get(prefix.concat(".folder")));
      uri.append("&unseen=").append(getContext().getProperties().get(prefix.concat(".unseen")));
      uri.append("&consumer.delay=").append(getContext().getProperties().get(prefix.concat(".consuming.delay")));
      uri.append("&delete=").append(getContext().getProperties().get(prefix.concat(".delete")));

      String options = getContext().getProperties().get(prefix.concat(".options"));

      if (StringUtils.isNotBlank(options))

      { uri.append("&").append(getContext().getProperties().get(prefix.concat(".options"))); }

      return uri.toString();
      }

      and the uri used to retrieve the mail :

      imap://myimapserver.ch?username=username&password=password&folderName=IMAP&unseen=true&consumer.delay=30000&delete=true

      I didn't find anywhere a similar problem with Camel mail component so I don't know if it's a bug or if I'm doing something wrong.

      Kind regards and thanks a lot for helping.

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            frossart Thierry Frossard
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: