commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lucian Burja (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (EMAIL-167) DataSourceClassPathResolver doesn't close InputStream when resolving resources
Date Thu, 23 Feb 2017 15:39:44 GMT

     [ https://issues.apache.org/jira/browse/EMAIL-167?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Lucian Burja updated EMAIL-167:
-------------------------------
    Description: 
DataSourceClassPathResolver opens an InputStream (via .class.getResourceAsStream) to read
a resource into a ByteArrayDataSource, but never closes it:
{code}
    public DataSource resolve(final String resourceLocation, final boolean isLenient) throws
IOException
    {
...
                final InputStream is = DataSourceClassPathResolver.class.getResourceAsStream(resourceName);

                if (is != null)
                {
                    final ByteArrayDataSource ds = new ByteArrayDataSource(is, mimeType);
                    // EMAIL-125: set the name of the DataSource to the normalized resource
URL
                    // similar to other DataSource implementations, e.g. FileDataSource, URLDataSource
                    ds.setName(DataSourceClassPathResolver.class.getResource(resourceName).toString());
                    result = ds;
                }
{code}
The 'is' variable above should be closed in a try ... finally

  was:
DataSourceClassPathResolver opens an InputStream (via .class.getResourceAsStream) to read
a resource into a ByteArrayDataSource, but never closes it:

    public DataSource resolve(final String resourceLocation, final boolean isLenient) throws
IOException
    {
...
                final InputStream is = DataSourceClassPathResolver.class.getResourceAsStream(resourceName);

                if (is != null)
                {
                    final ByteArrayDataSource ds = new ByteArrayDataSource(is, mimeType);
                    // EMAIL-125: set the name of the DataSource to the normalized resource
URL
                    // similar to other DataSource implementations, e.g. FileDataSource, URLDataSource
                    ds.setName(DataSourceClassPathResolver.class.getResource(resourceName).toString());
                    result = ds;
                }

The 'is' variable above should be closed in a try ... finally


> DataSourceClassPathResolver doesn't close InputStream when resolving resources
> ------------------------------------------------------------------------------
>
>                 Key: EMAIL-167
>                 URL: https://issues.apache.org/jira/browse/EMAIL-167
>             Project: Commons Email
>          Issue Type: Bug
>    Affects Versions: 1.4
>            Reporter: Lucian Burja
>
> DataSourceClassPathResolver opens an InputStream (via .class.getResourceAsStream) to
read a resource into a ByteArrayDataSource, but never closes it:
> {code}
>     public DataSource resolve(final String resourceLocation, final boolean isLenient)
throws IOException
>     {
> ...
>                 final InputStream is = DataSourceClassPathResolver.class.getResourceAsStream(resourceName);
>                 if (is != null)
>                 {
>                     final ByteArrayDataSource ds = new ByteArrayDataSource(is, mimeType);
>                     // EMAIL-125: set the name of the DataSource to the normalized resource
URL
>                     // similar to other DataSource implementations, e.g. FileDataSource,
URLDataSource
>                     ds.setName(DataSourceClassPathResolver.class.getResource(resourceName).toString());
>                     result = ds;
>                 }
> {code}
> The 'is' variable above should be closed in a try ... finally



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message