Author: dfs Date: Thu Jan 19 17:22:14 2006 New Revision: 370687 URL: http://svn.apache.org/viewcvs?rev=370687&view=rev Log: Made controlInput and controlOutput protected in response to issue #38309.
Modified: jakarta/commons/proper/net/trunk/src/java/org/apache/commons/net/ftp/FTP.java Modified: jakarta/commons/proper/net/trunk/src/java/org/apache/commons/net/ftp/FTP.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/net/trunk/src/java/org/apache/commons/net/ftp/FTP.java?rev=370687&r1=370686&r2=370687&view=diff ============================================================================== --- jakarta/commons/proper/net/trunk/src/java/org/apache/commons/net/ftp/FTP.java (original) +++ jakarta/commons/proper/net/trunk/src/java/org/apache/commons/net/ftp/FTP.java Thu Jan 19 17:22:14 2006 @@ -224,14 +224,30 @@ private StringBuffer __commandBuffer; - BufferedReader _controlInput; - BufferedWriter _controlOutput; int _replyCode; Vector _replyLines; boolean _newReplyString; String _replyString; String _controlEncoding; + /** + * Wraps SocketClient._input_ to facilitate the writing of text + * to the FTP control connection. Do not access the control + * connection via SocketClient._input_. This member starts + * with a null value, is initialized in [EMAIL PROTECTED] #_connectAction_}, + * and set to null in [EMAIL PROTECTED] #disconnect}. + */ + protected BufferedReader _controlInput_; + + /** + * Wraps SocketClient._output_ to facilitate the reading of text + * from the FTP control connection. Do not access the control + * connection via SocketClient._output_. This member starts + * with a null value, is initialized in [EMAIL PROTECTED] #_connectAction_}, + * and set to null in [EMAIL PROTECTED] #disconnect}. + */ + protected BufferedWriter _controlOutput_; + /*** * A ProtocolCommandSupport object used to manage the registering of * ProtocolCommandListeners and te firing of ProtocolCommandEvents. @@ -261,7 +277,7 @@ _newReplyString = true; _replyLines.setSize(0); - String line = _controlInput.readLine(); + String line = _controlInput_.readLine(); if (line == null) throw new FTPConnectionClosedException( @@ -292,7 +308,7 @@ { do { - line = _controlInput.readLine(); + line = _controlInput_.readLine(); if (line == null) throw new FTPConnectionClosedException( @@ -322,14 +338,17 @@ "FTP response 421 received. Server closed connection."); } - // initiates control connections and gets initial reply + /** + * Initiates control connections and gets initial reply. + * Initializes [EMAIL PROTECTED] #_controlInput_} and [EMAIL PROTECTED] #_controlOutput_}. + */ protected void _connectAction_() throws IOException { super._connectAction_(); - _controlInput = + _controlInput_ = new BufferedReader(new InputStreamReader(getInputStream(), getControlEncoding())); - _controlOutput = + _controlOutput_ = new BufferedWriter(new OutputStreamWriter(getOutputStream(), getControlEncoding())); __getReply(); @@ -389,14 +408,15 @@ * some internal data so that the memory may be reclaimed by the * garbage collector. The reply text and code information from the * last command is voided so that the memory it used may be reclaimed. + * Also sets [EMAIL PROTECTED] #_controlInput_} and [EMAIL PROTECTED] #_controlOutput_} to null. * <p> * @exception IOException If an error occurs while disconnecting. ***/ public void disconnect() throws IOException { super.disconnect(); - _controlInput = null; - _controlOutput = null; + _controlInput_ = null; + _controlOutput_ = null; _replyLines.setSize(0); _newReplyString = false; _replyString = null; @@ -438,8 +458,8 @@ __commandBuffer.append(SocketClient.NETASCII_EOL); try{ - _controlOutput.write(message = __commandBuffer.toString()); - _controlOutput.flush(); + _controlOutput_.write(message = __commandBuffer.toString()); + _controlOutput_.flush(); } catch (SocketException e) { --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]