incubator-ftpserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r588620 - /incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/listener/mina/FtpResponseEncoder.java
Date Fri, 26 Oct 2007 12:16:11 GMT
Author: ngn
Date: Fri Oct 26 05:16:10 2007
New Revision: 588620

URL: http://svn.apache.org/viewvc?rev=588620&view=rev
Log:
Fix for closing connections before a reply has been sent (FTPSERVER-112). Patch by Rico Neubauer.

Modified:
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/listener/mina/FtpResponseEncoder.java

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/listener/mina/FtpResponseEncoder.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/listener/mina/FtpResponseEncoder.java?rev=588620&r1=588619&r2=588620&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/listener/mina/FtpResponseEncoder.java
(original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/listener/mina/FtpResponseEncoder.java
Fri Oct 26 05:16:10 2007
@@ -22,9 +22,11 @@
 import java.nio.charset.Charset;
 import java.nio.charset.CharsetEncoder;
 
+import org.apache.ftpserver.ftplet.FtpException;
 import org.apache.ftpserver.ftplet.FtpReply;
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.IoSession;
+import org.apache.mina.common.WriteFuture;
 import org.apache.mina.filter.codec.ProtocolEncoderAdapter;
 import org.apache.mina.filter.codec.ProtocolEncoderOutput;
 import org.apache.mina.filter.codec.demux.MessageEncoder;
@@ -47,5 +49,12 @@
         
         buf.flip();
         out.write(buf);
+        
+        // 2007-10-26 - flushing the response, it is important to receive replies like 421
- service unavailable, see https://issues.apache.org/jira/browse/FTPSERVER-112
+        WriteFuture future = out.flush();
+        future.join(5000);
+        if (!future.isWritten()) {
+        	throw new FtpException("The response could not be sent for 5 seconds");
+        }
     }
 }



Mime
View raw message