You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2011/04/01 03:48:41 UTC
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
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 <action> type attribute can be add,u
<body>
<release version="3.0" date="TBA" description="TBA">
+ <action issue="NET-219" dev="sebb" type="update">
+ 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.
+ </action>
<action issue="NET-397" dev="sebb" type="update" due-to="Bogdan Drozdowski" due-to-email="bogdandr # op . pl">
FTPSClient does not handle AUTH or ADAT and only partially handles PBSZ. FTPSCommand should be deprecated.
</action>
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.
* <p>
* @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.
* <p>
* @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.
* <p>
* @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.
* <p>
* @throws InvalidTelnetOptionException
+ * @throws IOException
***/
@Override
public void deleteOptionHandler(int optcode)
- throws InvalidTelnetOptionException
+ throws InvalidTelnetOptionException, IOException
{
super.deleteOptionHandler(optcode);
}