Uploaded image for project: 'Commons Email'
  1. Commons Email
  2. EMAIL-198

Performance in ImageHtmlEmail

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.5
    • 1.6.0
    • None

    Description

      In the class ImageHtmlEmail, there are two regular expressions (REGEX_SCRIPT_SRC, and
      REGEX_IMAGE_SRC), which can behave rather slow in exceptional cases, as evidenced by
      the following code snippet:

       

      @Test
      public void testSlowRegularExpressions() throws Exception {
          ImageHtmlEmail mail = new ImageHtmlEmail();
          mail.setHostName("example.com");
          mail.setFrom("from@example.com");
          mail.addTo("to@example.com");
          StringBuilder text = new StringBuilder("<img");
          for (int i = 0; i < 3000; i++)

      {         text.append(" ");     }

          mail.setMsg("<html><body><pre>" + text + "</pre></body></html>");

          long startTime = System.currentTimeMillis();
          mail.buildMimeMessage();
          long duration = System.currentTimeMillis() - startTime;
          assertTrue("Run time exceeds permitted duration of 50 seconds: " + duration,

                            duration < 100*1000);
      }

      Attachments

        Activity

          People

            jochen@apache.org Jochen Wiedmann
            jochen@apache.org Jochen Wiedmann
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: