I have found that v2.3 is leaking temporary .m64 files.  Not always, but
often.  Why not always?  Because the current behavior implicitly relies upon
finalize to run.  I have made the following patch, which I propose to
include.

Please review.

If there are no objections, I will commit this later.  I now go to apply
similar changes to trunk, which I will commit in short order.

        --- Noel

Index: v2.3/src/java/org/apache/james/smtpserver/SMTPHandler.java
===================================================================
--- v2.3/src/java/org/apache/james/smtpserver/SMTPHandler.java  (revision
427862)
+++ v2.3/src/java/org/apache/james/smtpserver/SMTPHandler.java  (working
copy)
@@ -400,36 +400,37 @@

               //handle messages
               if(mode == MESSAGE_RECEIVED_MODE) {
-                  getLogger().debug("executing message handlers");
-                  List messageHandlers = handlerChain.getMessageHandlers();
-                  int count = messageHandlers.size();
-                  for(int i =0; i < count; i++) {
-
((MessageHandler)messageHandlers.get(i)).onMessage(this);
-                      //if the response is received, stop processing of
command handlers
-                      if(mode == MESSAGE_ABORT_MODE) {
-                          break;
+                  try {
+                      getLogger().debug("executing message handlers");
+                      List messageHandlers =
handlerChain.getMessageHandlers();
+                      int count = messageHandlers.size();
+                      for(int i =0; i < count; i++) {
+
((MessageHandler)messageHandlers.get(i)).onMessage(this);
+                          //if the response is received, stop processing of
command handlers
+                          if(mode == MESSAGE_ABORT_MODE) {
+                              break;
+                          }
                       }
-                  }
-              }
-
-              //do the clean up
-              if(mail != null) {
-                  if (mail instanceof Disposable) {
-                      ((Disposable) mail).dispose();
-                  }
+                  } finally {
+                      //do the clean up
+                      if(mail != null) {
+                          if (mail instanceof Disposable) {
+                              ((Disposable) mail).dispose();
+                          }

-                  // remember the ehlo mode
-                  Object currentHeloMode = state.get(CURRENT_HELO_MODE);
+                          // remember the ehlo mode
+                          Object currentHeloMode =
state.get(CURRENT_HELO_MODE);

-                  mail = null;
-                  resetState();
+                          mail = null;
+                          resetState();

-                  // start again with the old helo mode
-                  if (currentHeloMode != null) {
-                      state.put(CURRENT_HELO_MODE,currentHeloMode);
+                          // start again with the old helo mode
+                          if (currentHeloMode != null) {
+                              state.put(CURRENT_HELO_MODE,currentHeloMode);
+                          }
+                      }
                   }
               }
-
             }
             theWatchdog.stop();
             getLogger().debug("Closing socket.");
Index: v2.3/src/java/org/apache/james/smtpserver/DataCmdHandler.java
===================================================================
--- v2.3/src/java/org/apache/james/smtpserver/DataCmdHandler.java
(revision 427862)
+++ v2.3/src/java/org/apache/james/smtpserver/DataCmdHandler.java
(working copy)
@@ -278,6 +278,23 @@
                 mail.setAttribute(SMTP_AUTH_USER_ATTRIBUTE_NAME,
session.getUser());
             }
             session.setMail(mail);
+        } catch (MessagingException me) {
+            // if we get here, it means that we received a
+            // MessagingException, which would happen BEFORE we call
+            // session.setMail, so the mail object is still strictly
+            // local to us, and we really should clean it up before
+            // re-throwing the MessagingException for our call chain
+            // to process.
+            //
+            // So why has this worked at all so far?  Initial
+            // conjecture is that it has depended upon finalize to
+            // call dispose.  Not in the MailImpl, which doesn't have
+            // one, but even further down in the
MimeMessageInputStreamSource.
+
+            if (mail != null) {
+                mail.dispose();
+            }
+            throw me;
         } finally {
             if (recipientCollection != null) {
                 recipientCollection.clear();



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to