Issue Details (XML | Word | Printable)

Key: JAMES-585
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Noel J. Bergman
Reporter: Noel J. Bergman
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
JAMES Server

SMTP Server may leak temporary ($[JAMES}/temp/*.m64) files

Created: 02/Aug/06 05:30 PM   Updated: 21/Nov/07 08:31 AM
Return to search
Component/s: SMTPServer
Affects Version/s: 2.3.0
Fix Version/s: 2.3.0

Time Tracking:
Not Specified

Resolution Date: 04/Aug/06 01:05 PM


 Description  « Hide
If there is an exception during message processing, before the message is posted to the spooler, the temporary files may not be cleaned up. This appears to be due to an unintended and implied reliance on finalize() to dispose the temporary files.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #428097 Wed Aug 02 19:18:42 UTC 2006 noel Fix for JAMES-585. Explicit cleanup for temporary files when exceptions occur.
Files Changed
MODIFY /james/server/trunk/src/java/org/apache/james/smtpserver/core/DataCmdHandler.java
MODIFY /james/server/branches/v2.3/src/java/org/apache/james/smtpserver/DataCmdHandler.java
MODIFY /james/server/branches/v2.3/src/java/org/apache/james/smtpserver/SMTPHandler.java
MODIFY /james/server/trunk/src/java/org/apache/james/smtpserver/SMTPHandler.java

Repository Revision Date User Message
ASF #428228 Thu Aug 03 04:23:48 UTC 2006 noel JAMES-585. Copy FileCleaner from Commons I/O, to help track and cleanup temporary files.
Files Changed
ADD /james/server/branches/v2.3/src/java/org/apache/james/util/io/FileCleaner.java (from /jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/FileCleaner.java)

Repository Revision Date User Message
ASF #428237 Thu Aug 03 04:53:49 UTC 2006 noel JAMES-585. This change consists of the following changes:

  1) RemoteManagerHander.java
     Added two UNDOCUMENTED commands:
       1) SHOWTRACKERS - Call the FileCleaner to display
          a list of files that it is tracking to delete.
       2) GC - Force a JVM garbage collection, which will
          normally cause the FileCleaner to delete files
          whose marker object (MimeMessageInputStreamSource
          in our case) is not currently reachable.

  2) MimeMessageInputStreamSource.java
     Three changes:
       1) Register all temporary files with FileCleaner.
       2) At Stefano's suggestion, revert change to use
          SharedFileInputStream,
       3) Comment out finalize(), which is replaced by
          using FileCleaner. The mere presence of the
          finalize() method can actually cause problems.

  3) FileCleaner
     Two changes from what I copied from Commons I/O:
       1) Add some instrumentation to let us inspect the
          state of the tracker collection.
       2) Print (to System.err, normally redirected to
          ${JAMES}/temp/phoenix.console) an error if
          we cannot delete the file when asked.
     In both cases, a stack trace is used to let us see
     how the file was allocated, just to make sure that
     we're not missing something about the behavior.

So far, with these changes I am no longer seeing any leaks. A few times, there were some files still around, but forcing a GC cleaned them up. The instrumentation was added to help investigate this behavior.
Files Changed
MODIFY /james/server/branches/v2.3/src/java/org/apache/james/util/io/FileCleaner.java
MODIFY /james/server/branches/v2.3/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java
MODIFY /james/server/branches/v2.3/src/java/org/apache/james/core/MimeMessageInputStreamSource.java

Repository Revision Date User Message
ASF #428404 Thu Aug 03 13:55:57 UTC 2006 noel JAMES-585. Remove the temporary file immediately if there is an IOException creating it, rather than cleaning up later.
Files Changed
MODIFY /james/server/branches/v2.3/src/java/org/apache/james/core/MimeMessageInputStreamSource.java

Repository Revision Date User Message
ASF #428480 Thu Aug 03 19:09:21 UTC 2006 noel 1) Revert RemoteManagerHandler.java to RC1 state. This should be identical to r382444 for this file. It removes the temporary debugging commands SHOWTRACKERS and GC.

2) Remove the use of FileCleaner from, and restore the use of SharedFileInputStream to, MimeMessageInputStreamSource, but keep the recent improvements in exception handling, and keep finalize() commented out.

3) Remove FileCleaner.java entirely.

See JAMES-585
Files Changed
DEL /james/server/branches/v2.3/src/java/org/apache/james/util/io/FileCleaner.java
MODIFY /james/server/branches/v2.3/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java
MODIFY /james/server/branches/v2.3/src/java/org/apache/james/core/MimeMessageInputStreamSource.java