diff options
author | bryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-08-07 06:30:16 +0000 |
---|---|---|
committer | bryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-08-07 06:30:16 +0000 |
commit | e69bedf32491c935a11ab7f83c4620b910731e3a (patch) | |
tree | ac19591df1828db5dd120609de724f7fb980f668 /libjava/java/net/ServerSocket.java | |
parent | efe3489e0099236b1722fdf7a58cb16eb2fa22e4 (diff) | |
download | ppe42-gcc-e69bedf32491c935a11ab7f83c4620b910731e3a.tar.gz ppe42-gcc-e69bedf32491c935a11ab7f83c4620b910731e3a.zip |
* java/net/Socket.java (Socket (SocketImpl)): Don't allow null
SocketImpl. Update Javadoc.
(bind): Call close() not impl.close() in event of exception.
(connect): Likewise.
Remove superfluous null checks throughout.
* java/net/ServerSocket.java (ServerSocket (int, int, InetAddress)):
Don't create an extra socket. Fix for PR libgcj/10868.
(bind): Clean up exception handling.
Remove superfluous null checks throughout.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@70219 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/net/ServerSocket.java')
-rw-r--r-- | libjava/java/net/ServerSocket.java | 55 |
1 files changed, 5 insertions, 50 deletions
diff --git a/libjava/java/net/ServerSocket.java b/libjava/java/net/ServerSocket.java index 699319e70b2..3614354f227 100644 --- a/libjava/java/net/ServerSocket.java +++ b/libjava/java/net/ServerSocket.java @@ -154,12 +154,6 @@ public class ServerSocket { this(); - if (impl == null) - throw new IOException("Cannot initialize Socket implementation"); - - // create socket - impl.create(true); - // bind/listen socket bind (new InetSocketAddress (bindAddr, port), backlog); } @@ -208,9 +202,6 @@ public class ServerSocket if (closed) throw new SocketException ("ServerSocket is closed"); - if (impl == null) - throw new IOException ("Cannot initialize Socket implementation"); - if (! (endpoint instanceof InetSocketAddress)) throw new IllegalArgumentException ("Address type not supported"); @@ -220,45 +211,24 @@ public class ServerSocket if (s != null) s.checkListen (tmp.getPort ()); - // bind to address/port try { - impl.bind (tmp.getAddress (), tmp.getPort ()); + impl.bind (tmp.getAddress (), tmp.getPort ()); + impl.listen(backlog); } catch (IOException exception) { - impl.close(); + close(); throw exception; } catch (RuntimeException exception) { - impl.close(); + close(); throw exception; } catch (Error error) { - impl.close(); - throw error; - } - - // listen on socket - try - { - impl.listen(backlog); - } - catch (IOException exception) - { - impl.close(); - throw exception; - } - catch (RuntimeException exception) - { - impl.close(); - throw exception; - } - catch (Error error) - { - impl.close(); + close(); throw error; } } @@ -320,9 +290,6 @@ public class ServerSocket */ public Socket accept () throws IOException { - if (impl == null) - throw new IOException ("Cannot initialize Socket implementation"); - SecurityManager sm = System.getSecurityManager (); if (sm != null) sm.checkListen (impl.getLocalPort ()); @@ -466,9 +433,6 @@ public class ServerSocket public void setReuseAddress (boolean on) throws SocketException { - if (impl == null) - throw new SocketException ("Cannot initialize Socket implementation"); - impl.setOption (SocketOptions.SO_REUSEADDR, new Boolean (on)); } @@ -482,9 +446,6 @@ public class ServerSocket public boolean getReuseAddress() throws SocketException { - if (impl == null) - throw new SocketException ("Cannot initialize Socket implementation"); - Object reuseaddr = impl.getOption (SocketOptions.SO_REUSEADDR); if (!(reuseaddr instanceof Boolean)) @@ -508,9 +469,6 @@ public class ServerSocket public void setReceiveBufferSize (int size) throws SocketException { - if (impl == null) - throw new SocketException ("Not connected"); - if (size <= 0) throw new IllegalArgumentException ("SO_RCVBUF value must be > 0"); @@ -531,9 +489,6 @@ public class ServerSocket public int getReceiveBufferSize () throws SocketException { - if (impl == null) - throw new SocketException ("Not connected"); - Object buf = impl.getOption (SocketOptions.SO_RCVBUF); if (!(buf instanceof Integer)) |