james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r982586 - in /james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver: DataLineJamesMessageHookHandler.java JamesDataCmdHandler.java SMTPConstants.java netty/SMTPChannelUpstreamHandler.java
Date Thu, 05 Aug 2010 12:47:40 GMT
Author: norman
Date: Thu Aug  5 12:47:40 2010
New Revision: 982586

URL: http://svn.apache.org/viewvc?rev=982586&view=rev
Log:
Remove some possible leak for temporary files

Modified:
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/JamesDataCmdHandler.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SMTPConstants.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/netty/SMTPChannelUpstreamHandler.java

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java?rev=982586&r1=982585&r2=982586&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java
(original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java
Thu Aug  5 12:47:40 2010
@@ -100,9 +100,10 @@ public final class DataLineJamesMessageH
      */
     public void onLine(SMTPSession session, byte[] line, LineHandler<SMTPSession> next)
{
         MimeMessageInputStreamSource mmiss = (MimeMessageInputStreamSource) session.getState().get(SMTPConstants.DATA_MIMEMESSAGE_STREAMSOURCE);
-        OutputStream out = (OutputStream)  session.getState().get(SMTPConstants.DATA_MIMEMESSAGE_OUTPUTSTREAM);
 
         try {
+            OutputStream out = mmiss.getWritableOutputStream();
+
             // 46 is "."
             // Stream terminated
             if (line.length == 3 && line[0] == 46) {
@@ -151,6 +152,8 @@ public final class DataLineJamesMessageH
             }
             out.flush();
         } catch (IOException e) {
+            LifecycleUtil.dispose(mmiss);
+
             SMTPResponse response;
             response = new SMTPResponse(SMTPRetCode.LOCAL_ERROR,DSNStatus.getStatus(DSNStatus.TRANSIENT,
                             DSNStatus.UNDEFINED_STATUS) + " Error processing message: " +
e.getMessage());
@@ -159,7 +162,7 @@ public final class DataLineJamesMessageH
                     "Unknown error occurred while processing DATA.", e);
             session.writeResponse(response);
             return;
-        }
+        }  
     }
 
 	/**

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/JamesDataCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/JamesDataCmdHandler.java?rev=982586&r1=982585&r2=982586&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/JamesDataCmdHandler.java
(original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/JamesDataCmdHandler.java
Thu Aug  5 12:47:40 2010
@@ -18,8 +18,6 @@
  ****************************************************************/
 package org.apache.james.smtpserver;
 
-import java.io.IOException;
-import java.io.OutputStream;
 
 import javax.annotation.Resource;
 import javax.mail.MessagingException;
@@ -69,14 +67,7 @@ public class JamesDataCmdHandler extends
     protected SMTPResponse doDATA(SMTPSession session, String argument) {
         try {
             MimeMessageInputStreamSource mmiss = new MimeMessageInputStreamSource(mailServer.getId());
-            OutputStream out = mmiss.getWritableOutputStream();
-
             session.getState().put(SMTPConstants.DATA_MIMEMESSAGE_STREAMSOURCE, mmiss);
-            session.getState().put(SMTPConstants.DATA_MIMEMESSAGE_OUTPUTSTREAM, out);
-
-        } catch (IOException e) {
-            session.getLogger().warn("Error creating temporary outputstream for incoming
data",e);
-            return new SMTPResponse(SMTPRetCode.LOCAL_ERROR, "Unexpected error preparing
to receive DATA.");
         } catch (MessagingException e) {
             session.getLogger().warn("Error creating mimemessagesource for incoming data",e);
             return new SMTPResponse(SMTPRetCode.LOCAL_ERROR, "Unexpected error preparing
to receive DATA.");

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SMTPConstants.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SMTPConstants.java?rev=982586&r1=982585&r2=982586&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SMTPConstants.java
(original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SMTPConstants.java
Thu Aug  5 12:47:40 2010
@@ -26,10 +26,7 @@ package org.apache.james.smtpserver;
  */
 public interface SMTPConstants {
 
-    public static final String DATA_MIMEMESSAGE_STREAMSOURCE = "org.apache.james.core.DataCmdHandler.DATA_MIMEMESSAGE_STREAMSOURCE";
-
-    public static final String DATA_MIMEMESSAGE_OUTPUTSTREAM = "org.apache.james.core.DataCmdHandler.DATA_MIMEMESSAGE_OUTPUTSTREAM";
-    
+    public static final String DATA_MIMEMESSAGE_STREAMSOURCE = "org.apache.james.core.DataCmdHandler.DATA_MIMEMESSAGE_STREAMSOURCE";
   
     public static final String MAIL = "MAIL";
 
 }

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/netty/SMTPChannelUpstreamHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/netty/SMTPChannelUpstreamHandler.java?rev=982586&r1=982585&r2=982586&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/netty/SMTPChannelUpstreamHandler.java
(original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/netty/SMTPChannelUpstreamHandler.java
Thu Aug  5 12:47:40 2010
@@ -104,7 +104,6 @@ public class SMTPChannelUpstreamHandler 
         if (smtpSession != null) {
             LifecycleUtil.dispose(smtpSession.getState().get(SMTPConstants.MAIL));
             LifecycleUtil.dispose(smtpSession.getState().get(SMTPConstants.DATA_MIMEMESSAGE_STREAMSOURCE));
-            LifecycleUtil.dispose(smtpSession.getState().get(SMTPConstants.DATA_MIMEMESSAGE_OUTPUTSTREAM));
         }
         
         super.cleanup(channel);



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message