Michael Breu created EMAIL-191:
----------------------------------

             Summary: MultiPartEmail attach( final DataSource ds, ...) closes 
the inputstream in data source ds, before reading it.
                 Key: EMAIL-191
                 URL: https://issues.apache.org/jira/browse/EMAIL-191
             Project: Commons Email
          Issue Type: Bug
    Affects Versions: 1.5
         Environment: Tested with email-commons 1.5 in tomcat 7.0.x on Windows 
and Linux.

The problem is quite straight forward visible in source code 
{{.org.apache.commons.mail.MultiPartEmail}} line 420 . Therefore I abstain from 
constructing a self contained example.
            Reporter: Michael Breu


We are creating watermarked pdf's and send them on-the-fly as email 
attachments. The pdf is created in a separate thread and piped into a 
PipedInputStream.

This runs into a Pipe closed IOException, because {{MultiPartEmail attach( 
final DataSource ds, final String name, final String description)}} closes the 
inputstream in data source ds, before reading it.

Comment say's that this is due to windows file locking

*Expected behavior*: The input stream is read before closing.

 

*Workaround*: Buffer the Stream into a ByteArrayInputStream. (This has the 
disadvantage that we have a high memory load, due to prepared, but not yet sent 
attachments.

 

*Minimum solution*: Document the problem in the java doc.

*Optimal solution*: It is not really clear to me, what the file locking problem 
is: Either provide two alternative methods for Files and InputStreams. Or 
improve the file handling.

 

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to