You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2011/02/16 00:34:54 UTC

svn commit: r1071106 - /commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTP.java

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);