2003-12-09 Michael Koch <konqueror@gmx.de>
authorMichael Koch <konqueror@gmx.de>
Tue, 9 Dec 2003 15:39:23 +0000 (15:39 +0000)
committerMichael Koch <mkoch@gcc.gnu.org>
Tue, 9 Dec 2003 15:39:23 +0000 (15:39 +0000)
* 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.

From-SVN: r74470

libjava/ChangeLog
libjava/java/net/DatagramSocket.java
libjava/java/net/ServerSocket.java
libjava/java/net/Socket.java

index ca99ae1cdbffad60bab9e089c3aea535faf44232..03afb656e10a0f2807a0feb8d34f8eda5b5186ef 100644 (file)
@@ -1,3 +1,12 @@
+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
index e3edfcd6c39ec62daa5889332e558e82c4d74e73..c9c0f5d0f03ddd33d7ee0e0196872d04c7098cbc 100644 (file)
@@ -216,32 +216,32 @@ public class DatagramSocket
    */
   public void close()
   {
-    if (!isClosed())
+    if (isClosed())
+      return;
+    
+    try
       {
-       try
-         {
-           getImpl().close();
-         }
-       catch (SocketException e)
-         {
-           // Ignore this case, just close the socket in finally clause.
-         }
-       finally
-         {
-           remoteAddress = null;
-           remotePort = -1;
-           impl = null;
-         }
+       getImpl().close();
+      }
+    catch (SocketException e)
+      {
+       // Ignore this case, just close the socket in finally clause.
+      }
+    finally
+      {
+       remoteAddress = null;
+       remotePort = -1;
+       impl = null;
+      }
 
-       try
-         {
-           if (getChannel() != null)
-             getChannel().close();
-         }
-       catch (IOException e)
-         {
-           // Do nothing.
-         }
+    try
+      {
+       if (getChannel() != null)
+         getChannel().close();
+      }
+    catch (IOException e)
+      {
+       // Do nothing.
       }
   }
 
index 4e7f58a7cfcf17ea09486097d0e3f5ed8d2c04aa..a691d20849853744e4b560696ca0e50594aae87f 100644 (file)
@@ -353,15 +353,15 @@ public class ServerSocket
    */
   public void close () throws IOException
   {
-    if (!isClosed())
-      {
-       impl.close();
-       impl = null;
-       bound = false;
+    if (isClosed())
+      return;
+    
+    impl.close();
+    impl = null;
+    bound = false;
 
-       if (getChannel() != null)
-         getChannel().close();
-      }
+    if (getChannel() != null)
+      getChannel().close();
   }
 
   /**
index a0f831c17015374540e1fa624a9cf9a5b94e0364..9322e929ec38b6755990f805e5371282244ddda4 100644 (file)
@@ -1003,7 +1003,7 @@ public class Socket
   public synchronized void close ()  throws IOException
   {
     if (isClosed())
-      throw new SocketException("socket is closed");
+      return;
     
     getImpl().close();
     impl = null;