Commons Email
  1. Commons Email
  2. EMAIL-120

attach(DataSource xx) doesn't close inputstream

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2
    • Fix Version/s: 1.3
    • Labels:
      None
    • Environment:

      Windows 7, 64 bit

      Description

      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

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            mike bell
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development