[ 
https://issues.apache.org/jira/browse/EMAIL-198?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17838953#comment-17838953
 ] 

Sean Fabri commented on EMAIL-198:
----------------------------------

I thought this one looked interesting - see PR

> Performance in ImageHtmlEmail
> -----------------------------
>
>                 Key: EMAIL-198
>                 URL: https://issues.apache.org/jira/browse/EMAIL-198
>             Project: Commons Email
>          Issue Type: Improvement
>    Affects Versions: 1.5
>            Reporter: Jochen Wiedmann
>            Assignee: Jochen Wiedmann
>            Priority: Minor
>             Fix For: 1.6.0
>
>
> 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("[email protected]");
>     mail.addTo("[email protected]");
>     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);
>  }



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to