commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1086575 - /commons/proper/net/trunk/src/main/java/org/apache/commons/net/pop3/POP3.java
Date Tue, 29 Mar 2011 13:21:05 GMT
Author: sebb
Date: Tue Mar 29 13:21:04 2011
New Revision: 1086575

URL: http://svn.apache.org/viewvc?rev=1086575&view=rev
Log:
Prevent NPE if method called before connection is complete,

Modified:
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/pop3/POP3.java

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/pop3/POP3.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/pop3/POP3.java?rev=1086575&r1=1086574&r2=1086575&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/pop3/POP3.java (original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/pop3/POP3.java Tue Mar 29
13:21:04 2011
@@ -215,6 +215,9 @@ public class POP3 extends SocketClient
      ***/
     public int sendCommand(String command, String args) throws IOException
     {
+        if (__writer == null) {
+            throw new IllegalStateException("Socket is not connected");
+        }
         StringBuilder __commandBuffer = new StringBuilder();
         __commandBuffer.append(command);
 
@@ -225,8 +228,8 @@ public class POP3 extends SocketClient
         }
         __commandBuffer.append(SocketClient.NETASCII_EOL);
 
-        String message;
-        __writer.write(message = __commandBuffer.toString());
+        String message = __commandBuffer.toString();
+        __writer.write(message);
         __writer.flush();
 
         fireCommandSent(command, message);



Mime
View raw message