NET-596 NullPointerException when disconnecting TelnetClient twice with JDK 7

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/net/trunk@1782091 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index c902431..837a64a 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -87,6 +87,9 @@
   The POP3Mail examples can now get password from console, stdin or an environment variable.
   
 ">
+            <action issue="NET-596" type="fix" dev="sebb" due-to="Vincent Bories-Azeau">
+            NullPointerException when disconnecting TelnetClient twice with JDK 7
+            </action>
             <action issue="NET-602" type="fix" dev="sebb" due-to="Ross Braithwaite">
             Failure to parse times from SYST_L8 systems that report as "WINDOWS Type: L8"
             </action>
diff --git a/src/main/java/org/apache/commons/net/telnet/TelnetClient.java b/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
index 053ec69..67f10e0 100644
--- a/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
+++ b/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
@@ -80,7 +80,11 @@
     }
     void _closeOutputStream() throws IOException
     {
-        _output_.close();
+        try {
+            _output_.close();            
+        } finally {
+            _output_ = null;
+        }
     }
 
     /***
@@ -125,6 +129,8 @@
                 __output.close();
             }
         } finally { // NET-594
+            __output = null;
+            __input = null;
             super.disconnect();
         }
     }