commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1071106 - /commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTP.java
Date Tue, 15 Feb 2011 23:34:54 GMT
Author: sebb
Date: Tue Feb 15 23:34:53 2011
New Revision: 1071106

URL: http://svn.apache.org/viewvc?rev=1071106&view=rev
Log:
Tidy: check for valid control session before building command to use it

Modified:
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTP.java

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTP.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTP.java?rev=1071106&r1=1071105&r2=1071106&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTP.java (original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTP.java Tue Feb 15
23:34:53 2011
@@ -454,7 +454,9 @@ public class FTP extends SocketClient
      ***/
     public int sendCommand(String command, String args) throws IOException
     {
-        String message;
+        if (_controlOutput_ == null) {
+            throw new IOException("Connection is not open");
+        }
 
         final StringBuilder __commandBuffer = new StringBuilder();
 
@@ -467,12 +469,9 @@ public class FTP extends SocketClient
         }
         __commandBuffer.append(SocketClient.NETASCII_EOL);
 
-        if (_controlOutput_ == null){
-            throw new IOException("Connection is not open");
-        }
-
+        String message = __commandBuffer.toString();
         try{
-            _controlOutput_.write(message = __commandBuffer.toString());
+            _controlOutput_.write(message);
             _controlOutput_.flush();
         }
         catch (SocketException e)
@@ -487,7 +486,6 @@ public class FTP extends SocketClient
             }
         }
 
-
         if (_commandSupport_.getListenerCount() > 0)
             _commandSupport_.fireCommandSent(command, message);
 



Mime
View raw message