commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r936348 - /commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTP.java
Date Wed, 21 Apr 2010 15:26:55 GMT
Author: sebb
Date: Wed Apr 21 15:26:55 2010
New Revision: 936348

URL: http://svn.apache.org/viewvc?rev=936348&view=rev
Log:
Protect against NPE

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

Modified: commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTP.java
URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTP.java?rev=936348&r1=936347&r2=936348&view=diff
==============================================================================
--- commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTP.java
(original)
+++ commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTP.java
Wed Apr 21 15:26:55 2010
@@ -215,7 +215,7 @@ public class FTP extends SocketClient
     public static final String DEFAULT_CONTROL_ENCODING = "ISO-8859-1";
     private static final String __modes = "AEILNTCFRPSBC";
 
-    private StringBuilder __commandBuffer = new StringBuilder();
+    private final StringBuilder __commandBuffer = new StringBuilder();
 
     protected int _replyCode;
     protected ArrayList<String> _replyLines;
@@ -468,8 +468,12 @@ public class FTP extends SocketClient
         }
         __commandBuffer.append(SocketClient.NETASCII_EOL);
 
+        if (_controlOutput_ == null){
+            throw new IOException("Connection is not open");
+        }
+
         try{
-        _controlOutput_.write(message = __commandBuffer.toString());
+            _controlOutput_.write(message = __commandBuffer.toString());
             _controlOutput_.flush();
         }
         catch (SocketException e)



Mime
View raw message