incubator-ftpserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r609773 - in /incubator/ftpserver/trunk/core/src: main/java/org/apache/ftpserver/ main/java/org/apache/ftpserver/command/ main/java/org/apache/ftpserver/interfaces/ test/java/org/apache/ftpserver/clienttests/ test/java/org/apache/ftpserver/...
Date Mon, 07 Jan 2008 20:25:01 GMT
Author: ngn
Date: Mon Jan  7 12:24:55 2008
New Revision: 609773

URL: http://svn.apache.org/viewvc?rev=609773&view=rev
Log:
Fixing some broken unit tests, getting close to a successful MINA 2 migration

Modified:
    incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/FtpHandler.java
    incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/FtpStatisticsImpl.java
    incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/IODataConnectionFactory.java
    incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/OPTS.java
    incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/PASV.java
    incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/QUIT.java
    incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/SITE.java
    incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/interfaces/FtpIoSession.java
    incubator/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/clienttests/FeatTest.java
    incubator/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/SSLTestTemplate.java

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/FtpHandler.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/FtpHandler.java?rev=609773&r1=609772&r2=609773&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/FtpHandler.java (original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/FtpHandler.java Mon
Jan  7 12:24:55 2008
@@ -59,7 +59,7 @@
     public void exceptionCaught( IoSession session, Throwable cause ) throws Exception
     {
         cause.printStackTrace();
-        session.closeOnFlush();
+        session.closeOnFlush().awaitUninterruptibly(10000);
     }
 
     @Override

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/FtpStatisticsImpl.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/FtpStatisticsImpl.java?rev=609773&r1=609772&r2=609773&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/FtpStatisticsImpl.java
(original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/FtpStatisticsImpl.java
Mon Jan  7 12:24:55 2008
@@ -365,34 +365,42 @@
      * User logout
      */
     public void setLogout(FtpIoSession session) {
-        --currLogins;
         User user = session.getUser();
+        
+        if(user == null) {
+        	return;
+        }
+
+        --currLogins;
+        
         if( "anonymous".equals(user.getName()) ) {
             --currAnonLogins;
         }
         
         synchronized(user){
           Hashtable<String, Integer> statisticsTable = userLoginTable.get(user.getName());
-          Integer loginNumber = statisticsTable.get(LOGIN_NUMBER);
-          statisticsTable.put(LOGIN_NUMBER, new Integer(loginNumber.intValue() - 1));
           
+          if(statisticsTable != null) {
+	          Integer loginNumber = statisticsTable.get(LOGIN_NUMBER);
+	          statisticsTable.put(LOGIN_NUMBER, new Integer(loginNumber.intValue() - 1));
           
-          if(session.getRemoteAddress() instanceof InetSocketAddress) {
-        	  String address = ((InetSocketAddress)session.getRemoteAddress()).getAddress().getHostAddress();
-
-        	  Integer loginNumberPerIP = statisticsTable.get(address);
-        	  
-        	  if(loginNumberPerIP != null){
-        		  //this should always be true
-        		  if(loginNumberPerIP.intValue() <= 1){
-        			  //the last login from this ip, remove this ip address
-        			  statisticsTable.remove(address);
-        		  } else{
-        			  //this ip has other logins, reduce the number
-        			  statisticsTable.put(address, new Integer(loginNumberPerIP.intValue() - 1));
-        		  }
-        	  } 
-          }
+	          if(session.getRemoteAddress() instanceof InetSocketAddress) {
+	        	  String address = ((InetSocketAddress)session.getRemoteAddress()).getAddress().getHostAddress();
+	
+	        	  Integer loginNumberPerIP = statisticsTable.get(address);
+	        	  
+	        	  if(loginNumberPerIP != null){
+	        		  //this should always be true
+	        		  if(loginNumberPerIP.intValue() <= 1){
+	        			  //the last login from this ip, remove this ip address
+	        			  statisticsTable.remove(address);
+	        		  } else{
+	        			  //this ip has other logins, reduce the number
+	        			  statisticsTable.put(address, new Integer(loginNumberPerIP.intValue() - 1));
+	        		  }
+	        	  } 
+	          }
+          }          
           
         }
         

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/IODataConnectionFactory.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/IODataConnectionFactory.java?rev=609773&r1=609772&r2=609773&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/IODataConnectionFactory.java
(original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/IODataConnectionFactory.java
Mon Jan  7 12:24:55 2008
@@ -152,11 +152,11 @@
         try {
             DataConnectionConfig dataCfg = session.getListener().getDataConnectionConfig();
             address = dataCfg.getPassiveAddress();
-            System.out.println("!!!!!!!!!!!!!" + address);
+
             if(address == null) {
                 address = serverControlAddress;
             }
-            System.out.println("!!!!!!!!!!!!!" + address);
+
             if(secure) {
                 Ssl ssl = dataCfg.getSSL();
                 if(ssl == null) {

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/OPTS.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/OPTS.java?rev=609773&r1=609772&r2=609773&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/OPTS.java (original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/OPTS.java Mon
Jan  7 12:24:55 2008
@@ -76,7 +76,7 @@
         Command command = (Command)COMMAND_MAP.get( optsRequest );
         try {
             if(command != null) {
-                command.execute(null, null, request);
+                command.execute(session, context, request);
             }
             else {
                 session.resetState();

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/PASV.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/PASV.java?rev=609773&r1=609772&r2=609773&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/PASV.java (original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/PASV.java Mon
Jan  7 12:24:55 2008
@@ -75,10 +75,6 @@
                 servAddr = dataConAddress.getAddress();
             }
             
-            System.out.println("############" + dataConAddress);
-            System.out.println("############" + dataConAddress.getAddress());
-            System.out.println("############" + servAddr);
-            
             // send connection info to client
             InetSocketAddress externalDataConAddress = new InetSocketAddress(servAddr, dataConAddress.getPort());
             

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/QUIT.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/QUIT.java?rev=609773&r1=609772&r2=609773&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/QUIT.java (original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/QUIT.java Mon
Jan  7 12:24:55 2008
@@ -44,7 +44,9 @@
                         FtpRequest request) throws IOException {
         session.resetState();
         session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_221_CLOSING_CONTROL_CONNECTION,
"QUIT", null));
-		session.closeOnFlush();
+		
+        session.closeOnFlush().awaitUninterruptibly(10000);
+        
     }
 
 }

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/SITE.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/SITE.java?rev=609773&r1=609772&r2=609773&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/SITE.java (original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/SITE.java Mon
Jan  7 12:24:55 2008
@@ -92,7 +92,7 @@
         Command command = (Command)COMMAND_MAP.get( siteRequest );
         try {
             if(command != null) {
-                command.execute(null, null, request);
+                command.execute(session, context, request);
             }
             else {
                 session.resetState();

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/interfaces/FtpIoSession.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/interfaces/FtpIoSession.java?rev=609773&r1=609772&r2=609773&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/interfaces/FtpIoSession.java
(original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/interfaces/FtpIoSession.java
Mon Jan  7 12:24:55 2008
@@ -331,7 +331,7 @@
      * Is logged-in
      */
     public boolean isLoggedIn() {
-        return containsAttribute(ATTRIBUTE_LOGIN_TIME);
+        return containsAttribute(ATTRIBUTE_USER);
     }
 
 	public Listener getListener() {
@@ -390,6 +390,7 @@
 	}
 
 	public void setLogin(FileSystemView fsview) {
+		setAttribute(ATTRIBUTE_LOGIN_TIME, new Date());
 		setAttribute(ATTRIBUTE_FILE_SYSTEM, fsview);
 	}
 

Modified: incubator/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/clienttests/FeatTest.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/clienttests/FeatTest.java?rev=609773&r1=609772&r2=609773&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/clienttests/FeatTest.java
(original)
+++ incubator/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/clienttests/FeatTest.java
Mon Jan  7 12:24:55 2008
@@ -27,7 +27,7 @@
 
     public void test() throws Exception {
         client.sendCommand("FEAT");
-        String[] featReplies = client.getReplyStrings();
+        String[] featReplies = client.getReplyString().split("\r\n");
         
         for(int i = 0; i<featReplies.length; i++) {
             if(i == 0) {

Modified: incubator/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/SSLTestTemplate.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/SSLTestTemplate.java?rev=609773&r1=609772&r2=609773&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/SSLTestTemplate.java
(original)
+++ incubator/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/ssl/SSLTestTemplate.java
Mon Jan  7 12:24:55 2008
@@ -234,7 +234,6 @@
                 lastException = e;
             }
             
-            System.out.println("Retrying!");
             Thread.sleep(500);
             attempts++;
         }



Mime
View raw message