You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "mike bell (JIRA)" <ji...@apache.org> on 2012/10/03 18:54:07 UTC

[jira] [Created] (EMAIL-120) attach(DataSource xx) doesn't close inputstream

mike bell created EMAIL-120:
-------------------------------

             Summary: attach(DataSource xx) doesn't close inputstream
                 Key: EMAIL-120
                 URL: https://issues.apache.org/jira/browse/EMAIL-120
             Project: Commons Email
          Issue Type: Bug
    Affects Versions: 1.2
         Environment: Windows 7, 64 bit
            Reporter: mike bell


Basically I have code like shown below.

message.attach(reports[1].getDatasource(),
					
				"Report" + new SimpleDateFormat("yyyymmdd").format(new java.util.Date()) + "." + selectedAttachment,
				selectedAttachment.toUpperCase() + " version of report");

Where the DataSource in question is a simple JAF FileDataSource.

What I found [when I found files were not being cleaned up by my cleaner)

1. I can delete the backing file before calling this method
2. I cannot delete the backing file after calling this method.
3. Workaround uses the URL version of attachment.

DataSource ds=reports[1].getDatasource();
			FileDataSource fds=(FileDataSource) ds;
			URL url=fds.getFile().toURI().toURL();
			
			/**
			 * MJB: We don't use the DataSource directly (as we should) because of a bug in Commons Email
			 * where it usually doesn't close the inputstream
			 */
			message.attach(url,"Report" + new SimpleDateFormat("yyyymmdd").format(new java.util.Date()) + "." + selectedAttachment,
					selectedAttachment.toUpperCase() + " version of report");

4. I therefore assume the inputstream has been opened and never closed.
5. Same test after calling send() provides same results


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Resolved] (EMAIL-120) attach(DataSource xx) doesn't close inputstream

Posted by "Thomas Neidhart (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/EMAIL-120?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Thomas Neidhart resolved EMAIL-120.
-----------------------------------

       Resolution: Fixed
    Fix Version/s: 1.3

Fixed in r1406832.

Thanks for the report!
                
> attach(DataSource xx) doesn't close inputstream
> -----------------------------------------------
>
>                 Key: EMAIL-120
>                 URL: https://issues.apache.org/jira/browse/EMAIL-120
>             Project: Commons Email
>          Issue Type: Bug
>    Affects Versions: 1.2
>         Environment: Windows 7, 64 bit
>            Reporter: mike bell
>             Fix For: 1.3
>
>
> Basically I have code like shown below.
> message.attach(reports[1].getDatasource(),
> 					
> 				"Report" + new SimpleDateFormat("yyyymmdd").format(new java.util.Date()) + "." + selectedAttachment,
> 				selectedAttachment.toUpperCase() + " version of report");
> Where the DataSource in question is a simple JAF FileDataSource.
> What I found [when I found files were not being cleaned up by my cleaner)
> 1. I can delete the backing file before calling this method
> 2. I cannot delete the backing file after calling this method.
> 3. Workaround uses the URL version of attachment.
> DataSource ds=reports[1].getDatasource();
> 			FileDataSource fds=(FileDataSource) ds;
> 			URL url=fds.getFile().toURI().toURL();
> 			
> 			/**
> 			 * MJB: We don't use the DataSource directly (as we should) because of a bug in Commons Email
> 			 * where it usually doesn't close the inputstream
> 			 */
> 			message.attach(url,"Report" + new SimpleDateFormat("yyyymmdd").format(new java.util.Date()) + "." + selectedAttachment,
> 					selectedAttachment.toUpperCase() + " version of report");
> 4. I therefore assume the inputstream has been opened and never closed.
> 5. Same test after calling send() provides same results

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira