Author: ngn
Date: Tue May 31 13:28:59 2011
New Revision: 1129664

URL: http://svn.apache.org/viewvc?rev=1129664&view=rev
Log:
Ensuring that STAT file listings will not return a file listing record on the 
last line of multi-line replies (FTPSERVER-414)

Modified:
    
mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/command/impl/STAT.java
    
mina/ftpserver/branches/1.0.x/core/src/main/resources/org/apache/ftpserver/message/FtpStatus.properties
    
mina/ftpserver/branches/1.0.x/core/src/test/java/org/apache/ftpserver/clienttests/StatTest.java

Modified: 
mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/command/impl/STAT.java
URL: 
http://svn.apache.org/viewvc/mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/command/impl/STAT.java?rev=1129664&r1=1129663&r2=1129664&view=diff
==============================================================================
--- 
mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/command/impl/STAT.java
 (original)
+++ 
mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/command/impl/STAT.java
 Tue May 31 13:28:59 2011
@@ -26,7 +26,6 @@ import org.apache.ftpserver.command.impl
 import org.apache.ftpserver.command.impl.listing.LISTFileFormater;
 import org.apache.ftpserver.command.impl.listing.ListArgument;
 import org.apache.ftpserver.command.impl.listing.ListArgumentParser;
-import org.apache.ftpserver.ftplet.DefaultFtpReply;
 import org.apache.ftpserver.ftplet.FtpException;
 import org.apache.ftpserver.ftplet.FtpFile;
 import org.apache.ftpserver.ftplet.FtpReply;
@@ -85,11 +84,10 @@ public class STAT extends AbstractComman
                        replyCode = FtpReply.REPLY_213_FILE_STATUS;
                 }
                 
-                session
-                .write(new DefaultFtpReply(
-                               replyCode,
+                session.write(LocalizedFtpReply.translate(session, request, 
context,
+                               replyCode, "STAT",
                         dirList));
-
+                
             } catch (FtpException e) {
                 session.write(LocalizedFtpReply
                         .translate(

Modified: 
mina/ftpserver/branches/1.0.x/core/src/main/resources/org/apache/ftpserver/message/FtpStatus.properties
URL: 
http://svn.apache.org/viewvc/mina/ftpserver/branches/1.0.x/core/src/main/resources/org/apache/ftpserver/message/FtpStatus.properties?rev=1129664&r1=1129663&r2=1129664&view=diff
==============================================================================
--- 
mina/ftpserver/branches/1.0.x/core/src/main/resources/org/apache/ftpserver/message/FtpStatus.properties
 (original)
+++ 
mina/ftpserver/branches/1.0.x/core/src/main/resources/org/apache/ftpserver/message/FtpStatus.properties
 Tue May 31 13:28:59 2011
@@ -232,7 +232,9 @@
 213.SIZE={output.msg}
 
 211.STAT=Apache FtpServer\nConnected to {server.ip}\nConnected from 
{client.ip}\nLogged in as {client.login.name}\nEnd of status.
-450.LIST=Non-existing file
+212.STAT=\n{output.msg}End of status.
+213.STAT=\n{output.msg}End of status.
+450.STAT=Non-existing file
 
 501.STOR=Syntax error in parameters or arguments.
 550.STOR.invalid={output.msg}\: Invalid path.

Modified: 
mina/ftpserver/branches/1.0.x/core/src/test/java/org/apache/ftpserver/clienttests/StatTest.java
URL: 
http://svn.apache.org/viewvc/mina/ftpserver/branches/1.0.x/core/src/test/java/org/apache/ftpserver/clienttests/StatTest.java?rev=1129664&r1=1129663&r2=1129664&view=diff
==============================================================================
--- 
mina/ftpserver/branches/1.0.x/core/src/test/java/org/apache/ftpserver/clienttests/StatTest.java
 (original)
+++ 
mina/ftpserver/branches/1.0.x/core/src/test/java/org/apache/ftpserver/clienttests/StatTest.java
 Tue May 31 13:28:59 2011
@@ -30,7 +30,7 @@ import java.util.regex.Pattern;
 */
 public class StatTest extends ClientTestTemplate {
 
-    private static final String PATTERN = 
"^21\\d[-\\s]-rw-------\\s\\s\\s1\\suser\\sgroup\\s{12}0\\s[A-Za-z0-9\\s]{6}\\s\\d\\d:\\d\\d\\stest\\d.txt$";
+    private static final String PATTERN = 
"^-rw-------\\s\\s\\s1\\suser\\sgroup\\s{12}0\\s[A-Za-z0-9\\s]{6}\\s\\d\\d:\\d\\d\\stest\\d.txt$";
     
     private static final File TEST_DIR = new File(ROOT_DIR, "test");
     private static final File TEST_FILE1 = new File(TEST_DIR, "test1.txt");
@@ -46,8 +46,8 @@ public class StatTest extends ClientTest
         assertEquals(212, client.stat(TEST_DIR.getName()));
         String[] reply = client.getReplyString().split("\r\n");
 
-        assertTrue(reply[0], Pattern.matches(PATTERN, reply[0]));
         assertTrue(reply[1], Pattern.matches(PATTERN, reply[1]));
+        assertTrue(reply[2], Pattern.matches(PATTERN, reply[2]));
     }
 
     public void testStatFile() throws Exception {
@@ -59,7 +59,7 @@ public class StatTest extends ClientTest
         assertEquals(213, client.stat(TEST_DIR.getName() + "/" + 
TEST_FILE1.getName()));
         String[] reply = client.getReplyString().split("\r\n");
 
-        assertTrue(reply[0], Pattern.matches(PATTERN, reply[0]));
+        assertTrue(reply[1], Pattern.matches(PATTERN, reply[1]));
     }
 
     public void testStat() throws Exception {


Reply via email to