You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Jason Mathews <gj...@users.sourceforge.net> on 2003/09/13 18:15:55 UTC
[net][patch] Added more robust SocketClient setup/cleanu
Added more robust setup and cleanup to UDP and SocketClient base classes
including Time and Daytime TCP & UDP clients to for example check if not
connected and either throw an IOexception or force a open connection
rather than throw a NullpointerException.
Like the java.net.Socket class close() should check if socket is null
rather than throw a NullpointerException.
Index: DatagramSocketClient.java
===================================================================
RCS file:
/home/cvspublic/jakarta-commons/net/src/java/org/apache/commons/net/DatagramSocketClient.java,v
retrieving revision 1.3
diff -r1.3 DatagramSocketClient.java
190,191d189
< * If you call this method when the client socket is not open,
< * a NullPointerException is thrown.
195,196c193,196
< _socket_.close();
< _socket_ = null;
---
> if (_socket_ != null) {
> _socket_.close();
> _socket_ = null;
> }
Index: DaytimeTCPClient.java
===================================================================
RCS file:
/home/cvspublic/jakarta-commons/net/src/java/org/apache/commons/net/DaytimeTCPClient.java,v
retrieving revision 1.3
diff -r1.3 DaytimeTCPClient.java
112a113,114
> if (!isConnected()) throw new IOException("not connected");
>
Index: DaytimeUDPClient.java
===================================================================
RCS file:
/home/cvspublic/jakarta-commons/net/src/java/org/apache/commons/net/DaytimeUDPClient.java,v
retrieving revision 1.3
diff -r1.3 DaytimeUDPClient.java
105a106,107
> if (!isOpen()) open();
>
Index: SocketClient.java
===================================================================
RCS file:
/home/cvspublic/jakarta-commons/net/src/java/org/apache/commons/net/SocketClient.java,v
retrieving revision 1.4
diff -r1.4 SocketClient.java
305,311c305,325
< _socket_.close();
< _input_.close();
< _output_.close();
< _socket_ = null;
< _input_ = null;
< _output_ = null;
< _isConnected_ = false;
---
> try {
> if (_input_ != null) {
> try {
> _input_.close();
> } catch (IOException ioe) {
> }
> _input_ = null;
> }
> if (_output_ != null) {
> try {
> _output_.close();
> } catch (IOException ioe) {
> }
> _output_ = null;
> }
> if (_socket_ != null)
> _socket_.close();
> } finally {
> _socket_ = null;
> _isConnected_ = false;
> }
313d326
<
Index: TimeTCPClient.java
===================================================================
RCS file:
/home/cvspublic/jakarta-commons/net/src/java/org/apache/commons/net/TimeTCPClient.java,v
retrieving revision 1.3
diff -r1.3 TimeTCPClient.java
117a118
> if (!isConnected()) throw new IOException("not connected");
Index: TimeUDPClient.java
===================================================================
RCS file:
/home/cvspublic/jakarta-commons/net/src/java/org/apache/commons/net/TimeUDPClient.java,v
retrieving revision 1.3
diff -r1.3 TimeUDPClient.java
118a119,120
> if (!isOpen()) open();
>
--
Jason Mathews <gj...@users.sourceforge.net>
The MITRE Corporation <http://www.mitre.org/>
Bedford, MA 01730-1407