Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
Description
When parsing a MimeMessage and the message has attachments it is eagerly loading the content in to a memory via byteArray to create a DataSource. This is inefficient when all I need is a list of attachments which can be pulled from the content disposition for file name.
If the attachments are large these lines load it in to memory when perhaps it should keep it as an input stream so as not to force loading in to memory until it's actually used by somewhere else in the code.
MimeMessageParser.java
protected DataSource createDataSource(final Multipart parent, final MimePart part) throws MessagingException, IOException { final DataHandler dataHandler = part.getDataHandler(); final DataSource dataSource = dataHandler.getDataSource(); final String contentType = getBaseMimeType(dataSource.getContentType()); ---->final byte[] content = this.getContent(dataSource.getInputStream()); ---->final ByteArrayDataSource result = new ByteArrayDataSource(content, contentType); final String dataSourceName = getDataSourceName(part, dataSource); result.setName(dataSourceName); return result; }
Attachments
Issue Links
- links to