From commits-return-17132-apmail-commons-commits-archive=commons.apache.org@commons.apache.org Fri Apr 01 01:49:06 2011 Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 17764 invoked from network); 1 Apr 2011 01:49:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 1 Apr 2011 01:49:06 -0000 Received: (qmail 8004 invoked by uid 500); 1 Apr 2011 01:49:06 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 7953 invoked by uid 500); 1 Apr 2011 01:49:06 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 7946 invoked by uid 99); 1 Apr 2011 01:49:06 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Apr 2011 01:49:06 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Apr 2011 01:49:02 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 768A82388A19; Fri, 1 Apr 2011 01:48:41 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1087543 - in /commons/proper/net/trunk/src: changes/changes.xml main/java/org/apache/commons/net/telnet/Telnet.java main/java/org/apache/commons/net/telnet/TelnetClient.java Date: Fri, 01 Apr 2011 01:48:41 -0000 To: commits@commons.apache.org From: sebb@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110401014841.768A82388A19@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: sebb Date: Fri Apr 1 01:48:41 2011 New Revision: 1087543 URL: http://svn.apache.org/viewvc?rev=1087543&view=rev Log: NET-219 Should Telnet class Exception blocks write to System.err? Catch blocks removed, and throws clauses added to allow caller to more easily detect and recover. Modified: commons/proper/net/trunk/src/changes/changes.xml commons/proper/net/trunk/src/main/java/org/apache/commons/net/telnet/Telnet.java commons/proper/net/trunk/src/main/java/org/apache/commons/net/telnet/TelnetClient.java Modified: commons/proper/net/trunk/src/changes/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/changes/changes.xml?rev=1087543&r1=1087542&r2=1087543&view=diff ============================================================================== --- commons/proper/net/trunk/src/changes/changes.xml (original) +++ commons/proper/net/trunk/src/changes/changes.xml Fri Apr 1 01:48:41 2011 @@ -57,6 +57,10 @@ The type attribute can be add,u + + Should Telnet class Exception blocks write to System.err? + Catch blocks removed, and throws clauses added to allow caller to more easily detect and recover. + FTPSClient does not handle AUTH or ADAT and only partially handles PBSZ. FTPSCommand should be deprecated. Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/telnet/Telnet.java URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/telnet/Telnet.java?rev=1087543&r1=1087542&r2=1087543&view=diff ============================================================================== --- commons/proper/net/trunk/src/main/java/org/apache/commons/net/telnet/Telnet.java (original) +++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/telnet/Telnet.java Fri Apr 1 01:48:41 2011 @@ -264,8 +264,9 @@ class Telnet extends SocketClient * Sets the state of the option. *

* @param option - option code to be set. + * @throws IOException ***/ - void _setWill(int option) + void _setWill(int option) throws IOException { _options[option] |= _WILL_MASK; @@ -281,16 +282,7 @@ class Telnet extends SocketClient if (subneg != null) { - try - { - _sendSubnegotiation(subneg); - } - catch (IOException e) - { - System.err.println( - "Exception in option subnegotiation" - + e.getMessage()); - } + _sendSubnegotiation(subneg); } } } @@ -301,8 +293,9 @@ class Telnet extends SocketClient * Sets the state of the option. *

* @param option - option code to be set. + * @throws IOException ***/ - void _setDo(int option) + void _setDo(int option) throws IOException { _options[option] |= _DO_MASK; @@ -318,15 +311,7 @@ class Telnet extends SocketClient if (subneg != null) { - try - { - _sendSubnegotiation(subneg); - } - catch (IOException e) - { - System.err.println("Exception in option subnegotiation" - + e.getMessage()); - } + _sendSubnegotiation(subneg); } } } @@ -833,14 +818,7 @@ class Telnet extends SocketClient synchronized (aytMonitor) { aytFlag = true; - try - { - aytMonitor.notifyAll(); - } - catch (IllegalMonitorStateException e) - { - System.err.println("Exception notifying:" + e.getMessage()); - } + aytMonitor.notifyAll(); } } } @@ -879,30 +857,12 @@ class Telnet extends SocketClient { if (optionHandlers[ii].getInitLocal()) { - try - { - _requestWill(optionHandlers[ii].getOptionCode()); - } - catch (IOException e) - { - System.err.println( - "Exception while initializing option: " - + e.getMessage()); - } + _requestWill(optionHandlers[ii].getOptionCode()); } if (optionHandlers[ii].getInitRemote()) { - try - { - _requestDo(optionHandlers[ii].getOptionCode()); - } - catch (IOException e) - { - System.err.println( - "Exception while initializing option: " - + e.getMessage()); - } + _requestDo(optionHandlers[ii].getOptionCode()); } } } @@ -1109,24 +1069,15 @@ class Telnet extends SocketClient _output_.write(_COMMAND_AYT); _output_.flush(); } - - try + aytMonitor.wait(timeout); + if (aytFlag == false) { - aytMonitor.wait(timeout); - if (aytFlag == false) - { - retValue = false; - aytFlag = true; - } - else - { - retValue = true; - } + retValue = false; + aytFlag = true; } - catch (IllegalMonitorStateException e) + else { - System.err.println("Exception processing AYT:" - + e.getMessage()); + retValue = true; } } @@ -1141,9 +1092,10 @@ class Telnet extends SocketClient * * @param opthand - option handler to be registered. * @throws InvalidTelnetOptionException - The option code is invalid. + * @throws IOException **/ void addOptionHandler(TelnetOptionHandler opthand) - throws InvalidTelnetOptionException + throws InvalidTelnetOptionException, IOException { int optcode = opthand.getOptionCode(); if (TelnetOption.isValidOption(optcode)) @@ -1155,30 +1107,12 @@ class Telnet extends SocketClient { if (opthand.getInitLocal()) { - try - { - _requestWill(optcode); - } - catch (IOException e) - { - System.err.println( - "Exception while initializing option: " - + e.getMessage()); - } + _requestWill(optcode); } if (opthand.getInitRemote()) { - try - { - _requestDo(optcode); - } - catch (IOException e) - { - System.err.println( - "Exception while initializing option: " - + e.getMessage()); - } + _requestDo(optcode); } } } @@ -1200,9 +1134,10 @@ class Telnet extends SocketClient * * @param optcode - Code of the option to be unregistered. * @throws InvalidTelnetOptionException - The option code is invalid. + * @throws IOException **/ void deleteOptionHandler(int optcode) - throws InvalidTelnetOptionException + throws InvalidTelnetOptionException, IOException { if (TelnetOption.isValidOption(optcode)) { @@ -1218,30 +1153,12 @@ class Telnet extends SocketClient if (opthand.getWill()) { - try - { - _requestWont(optcode); - } - catch (IOException e) - { - System.err.println( - "Exception while turning off option: " - + e.getMessage()); - } + _requestWont(optcode); } if (opthand.getDo()) { - try - { - _requestDont(optcode); - } - catch (IOException e) - { - System.err.println( - "Exception while turning off option: " - + e.getMessage()); - } + _requestDont(optcode); } } } Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/telnet/TelnetClient.java URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/telnet/TelnetClient.java?rev=1087543&r1=1087542&r2=1087543&view=diff ============================================================================== --- commons/proper/net/trunk/src/main/java/org/apache/commons/net/telnet/TelnetClient.java (original) +++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/telnet/TelnetClient.java Fri Apr 1 01:48:41 2011 @@ -248,10 +248,11 @@ public class TelnetClient extends Telnet * @param opthand - option handler to be registered. *

* @throws InvalidTelnetOptionException + * @throws IOException ***/ @Override public void addOptionHandler(TelnetOptionHandler opthand) - throws InvalidTelnetOptionException + throws InvalidTelnetOptionException, IOException { super.addOptionHandler(opthand); } @@ -263,10 +264,11 @@ public class TelnetClient extends Telnet * @param optcode - Code of the option to be unregistered. *

* @throws InvalidTelnetOptionException + * @throws IOException ***/ @Override public void deleteOptionHandler(int optcode) - throws InvalidTelnetOptionException + throws InvalidTelnetOptionException, IOException { super.deleteOptionHandler(optcode); }