Uploaded image for project: 'Commons Email'
  1. Commons Email
  2. EMAIL-167

DataSourceClassPathResolver doesn't close InputStream when resolving resources

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.4
    • 1.5
    • None

    Description

      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

      Attachments

        Activity

          People

            Unassigned Unassigned
            lburja Lucian Burja
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: