commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r942955 - /commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/telnet/Telnet.java
Date Tue, 11 May 2010 00:05:11 GMT
Author: sebb
Date: Tue May 11 00:05:11 2010
New Revision: 942955

URL: http://svn.apache.org/viewvc?rev=942955&view=rev
Log:
NET-264 Telnet spyStream NullPointerException

Modified:
    commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/telnet/Telnet.java

Modified: commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/telnet/Telnet.java
URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/telnet/Telnet.java?rev=942955&r1=942954&r2=942955&view=diff
==============================================================================
--- commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/telnet/Telnet.java
(original)
+++ commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/telnet/Telnet.java
Tue May 11 00:05:11 2010
@@ -125,7 +125,7 @@ class Telnet extends SocketClient
     /***
      * The stream on which to spy
      ***/
-    private OutputStream spyStream = null;
+    private volatile OutputStream spyStream = null;
 
     /***
      * The notification handler
@@ -1248,18 +1248,19 @@ class Telnet extends SocketClient
      ***/
     void _spyRead(int ch)
     {
-        if (spyStream != null)
+        OutputStream spy = spyStream;
+        if (spy != null)
         {
             try
             {
                 if (ch != '\r')
                 {
-                    spyStream.write(ch);
+                    spy.write(ch);
                     if (ch == '\n')
                     {
-                        spyStream.write('\r');
+                        spy.write('\r');
                     }
-                    spyStream.flush();
+                    spy.flush();
                 }
             }
             catch (IOException e)
@@ -1279,12 +1280,13 @@ class Telnet extends SocketClient
         if (!(_stateIsDo(TelnetOption.ECHO)
             && _requestedDo(TelnetOption.ECHO)))
         {
-            if (spyStream != null)
+            OutputStream spy = spyStream;
+            if (spy != null)
             {
                 try
                 {
-                    spyStream.write(ch);
-                    spyStream.flush();
+                    spy.write(ch);
+                    spy.flush();
                 }
                 catch (IOException e)
                 {



Mime
View raw message