This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
FYI: Patch: java.net.*Socket
- From: Michael Koch <konqueror at gmx dot de>
- To: java-patches at gcc dot gnu dot org
- Date: Tue, 9 Dec 2003 17:54:41 +0100
- Subject: FYI: Patch: java.net.*Socket
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi list,
I commited the attached patch to clean up the close() methods of the
socket classes in java.net.
Michael
- --
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
iD8DBQE/1f5RWSOgCCdjSDsRAr4hAJ4k2GHY7E01vOtk5s0Tc49x5zWmdgCgjn5I
ER4ifs/nUpYd758eGa65Sf0=
=yKCe
-----END PGP SIGNATURE-----
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.2432
diff -u -b -B -r1.2432 ChangeLog
--- ChangeLog 9 Dec 2003 15:34:06 -0000 1.2432
+++ ChangeLog 9 Dec 2003 15:37:52 -0000
@@ -1,5 +1,14 @@
2003-12-09 Michael Koch <konqueror@gmx.de>
+ * java/net/DatagramSocket.java
+ (close): Directly return if socket is closed.
+ * java/net/ServerSocket.java
+ (close): Directly return if socket is closed.
+ * java/net/Socket.java
+ (close): Directly return if socket is closed.
+
+2003-12-09 Michael Koch <konqueror@gmx.de>
+
* gnu/java/nio/SelectorImpl.java
(implSelect): Throws IOException.
(select): Likewise.
Index: java/net/DatagramSocket.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/DatagramSocket.java,v
retrieving revision 1.34
diff -u -b -B -r1.34 DatagramSocket.java
--- java/net/DatagramSocket.java 2 Dec 2003 15:23:23 -0000 1.34
+++ java/net/DatagramSocket.java 9 Dec 2003 15:37:52 -0000
@@ -216,8 +216,9 @@
*/
public void close()
{
- if (!isClosed())
- {
+ if (isClosed())
+ return;
+
try
{
getImpl().close();
@@ -241,7 +242,6 @@
catch (IOException e)
{
// Do nothing.
- }
}
}
Index: java/net/ServerSocket.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/ServerSocket.java,v
retrieving revision 1.31
diff -u -b -B -r1.31 ServerSocket.java
--- java/net/ServerSocket.java 2 Dec 2003 15:23:23 -0000 1.31
+++ java/net/ServerSocket.java 9 Dec 2003 15:37:52 -0000
@@ -353,15 +353,15 @@
*/
public void close () throws IOException
{
- if (!isClosed())
- {
+ if (isClosed())
+ return;
+
impl.close();
impl = null;
bound = false;
if (getChannel() != null)
getChannel().close();
- }
}
/**
Index: java/net/Socket.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/Socket.java,v
retrieving revision 1.32
diff -u -b -B -r1.32 Socket.java
--- java/net/Socket.java 2 Dec 2003 15:23:23 -0000 1.32
+++ java/net/Socket.java 9 Dec 2003 15:37:52 -0000
@@ -1003,7 +1003,7 @@
public synchronized void close () throws IOException
{
if (isClosed())
- throw new SocketException("socket is closed");
+ return;
getImpl().close();
impl = null;