incubator-ftpserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r523744 - in /incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/listener/mina: FtpResponseEncoder.java FtpServerProtocolCodecFactory.java MinaFtpProtocolHandler.java
Date Thu, 29 Mar 2007 15:25:41 GMT
Author: ngn
Date: Thu Mar 29 08:25:40 2007
New Revision: 523744

URL: http://svn.apache.org/viewvc?view=rev&rev=523744
Log:
Fix for bug where multiple commands arrive at the decoder at the same time (FTPSERVER-81).
Will also fix bug where partial command would arrive due to network latency.
Optimized the encoder slightly by allocating the buffer size we really need.

Modified:
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/listener/mina/FtpResponseEncoder.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/listener/mina/FtpServerProtocolCodecFactory.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/listener/mina/MinaFtpProtocolHandler.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?view=diff&rev=523744&r1=523743&r2=523744
==============================================================================
--- 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
Thu Mar 29 08:25:40 2007
@@ -39,11 +39,11 @@
     public void encode( IoSession session, Object message,
             ProtocolEncoderOutput out ) throws Exception
     {
-        FtpReply ftpResponse = (FtpReply) message;
+        String value = message.toString();
         
-        ByteBuffer buf = ByteBuffer.allocate( 256 );
+        ByteBuffer buf = ByteBuffer.allocate( value.length() ).setAutoExpand( true );
 
-        buf.putString( ftpResponse.toString(), ENCODER );
+        buf.putString( value, ENCODER );
         
         buf.flip();
         out.write(buf);

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/listener/mina/FtpServerProtocolCodecFactory.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/listener/mina/FtpServerProtocolCodecFactory.java?view=diff&rev=523744&r1=523743&r2=523744
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/listener/mina/FtpServerProtocolCodecFactory.java
(original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/listener/mina/FtpServerProtocolCodecFactory.java
Thu Mar 29 08:25:40 2007
@@ -19,17 +19,20 @@
  */
 package org.apache.ftpserver.listener.mina;
 
+import java.nio.charset.Charset;
+
 import org.apache.mina.filter.codec.ProtocolCodecFactory;
 import org.apache.mina.filter.codec.ProtocolDecoder;
 import org.apache.mina.filter.codec.ProtocolEncoder;
+import org.apache.mina.filter.codec.textline.TextLineDecoder;
 
 /**
  * Factory for creating decoders and encoders
  */
 public class FtpServerProtocolCodecFactory implements ProtocolCodecFactory
 {
-    private FtpRequestDecoder decoder = new FtpRequestDecoder();
-    private FtpResponseEncoder encoder = new FtpResponseEncoder();
+    private ProtocolDecoder decoder = new TextLineDecoder(Charset.forName("UTF-8"));
+    private ProtocolEncoder encoder = new FtpResponseEncoder();
 
     public ProtocolDecoder getDecoder() throws Exception {
         return decoder;

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/listener/mina/MinaFtpProtocolHandler.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/listener/mina/MinaFtpProtocolHandler.java?view=diff&rev=523744&r1=523743&r2=523744
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/listener/mina/MinaFtpProtocolHandler.java
(original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/listener/mina/MinaFtpProtocolHandler.java
Thu Mar 29 08:25:40 2007
@@ -21,6 +21,7 @@
 
 import java.io.IOException;
 
+import org.apache.ftpserver.FtpRequestImpl;
 import org.apache.ftpserver.FtpSessionImpl;
 import org.apache.ftpserver.ftplet.FtpException;
 import org.apache.ftpserver.ftplet.FtpRequest;
@@ -83,7 +84,8 @@
     
     public void messageReceived( IoSession session, Object message ) throws IOException,
FtpException
     {
-        FtpRequest request = (FtpRequest) message;
+        // Incoming messages are decoded into strings
+        FtpRequest request = new FtpRequestImpl(message.toString());
 
 
         ConnectionObserver observer = (ConnectionObserver) session.getAttribute("observer");



Mime
View raw message