Commons Email
  1. Commons Email
  2. EMAIL-137

MimeMessageParser throws ClassCastException for HtmlEmail

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3.2
    • Fix Version/s: 1.3.3
    • Labels:
      None
    • Environment:

      Java 1.6 + Scala 2.10.3 + Play! 2.2.2

      Description

      MimeMessageParser throws ClassCastException when parsing just created and built HtmlEmail:

      java.lang.ClassCastException: javax.mail.internet.MimeMultipart cannot be cast to java.lang.String
      at org.apache.commons.mail.util.MimeMessageParser.parse(MimeMessageParser.java:176) ~[commons-email-1.3.2.jar:1.3.2]
      at org.apache.commons.mail.util.MimeMessageParser.parse(MimeMessageParser.java:85) ~[commons-email-1.3.2.jar:1.3.2]
      at utils.EmailSender$.emailForAutomation(EmailSender.scala:382) ~[classes/:na]

      Here is the test code:

      def emailForAutomation(email: HtmlEmail): String =

      { email.buildMimeMessage() val mimeMessage = email.getMimeMessage() val parser = new MimeMessageParser(mimeMessage) parser.parse() parser.getHtmlContent() }

        Activity

        Hide
        Thomas Neidhart added a comment -

        Fixed in r1591128.

        The problem was that MimePart.isMimeType() was returning wrong results in case of empty content.

        The mime type detection has been improved, and the exception should not occur anymore.

        Thanks for the report!

        Show
        Thomas Neidhart added a comment - Fixed in r1591128. The problem was that MimePart.isMimeType() was returning wrong results in case of empty content. The mime type detection has been improved, and the exception should not occur anymore. Thanks for the report!

          People

          • Assignee:
            Unassigned
            Reporter:
            Alex Kogan
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development