Skip to content

ConcurrentModificationException when importing from MimeMessage #202

Closed
@nedashley

Description

@nedashley

Hi,

I am experiencing a ConcurrentModificationException when converting from MimeMessage. I have narrowed the cause down to the moveInvalidEmbeddedResourcesToAttachments method in MimeMessageParser.

Here is a fix which I am currently testing:

private static void moveInvalidEmbeddedResourcesToAttachments(ParsedMimeMessageComponents parsedComponents) {
    final String htmlContent = parsedComponents.htmlContent.toString();
    for(Iterator<Map.Entry<String, DataSource>> it = parsedComponents.cidMap.entrySet().iterator(); it.hasNext(); ) {
        Map.Entry<String, DataSource> entry = it.next();
        String cid = extractCID(entry.getKey());
        if (!htmlContent.contains("cid:" + cid)) {
            parsedComponents.attachmentList.put(cid, entry.getValue());
            it.remove();
        }
    }
}

Thanks
Ned

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions