Bug 22750 - Closing a socket nulls impl but getImpl() isn't checked for null
Summary: Closing a socket nulls impl but getImpl() isn't checked for null
Status: RESOLVED FIXED
Alias: None
Product: classpath
Classification: Unclassified
Component: classpath (show other bugs)
Version: unspecified
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-10 00:34 UTC by from-classpath
Modified: 2005-07-23 22:54 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description from-classpath 2004-06-10 00:34:18 UTC
java.net.Socket:

When a socket is closed impl is set to null. However, some methods use getImpl() without checking for isClosed() first. In particular:

- isConnected() will throw NullPointerException if called on a closed socket. Hence so will
   - getPort
   - getInetAddress
   - getRemoteSocketAddress
   - toString

- getLocalAddress() will throw NullPointerException if called on a closed socket.

- setReuseAddress() will throw NullPointerException if called on a closed socket.
Comment 1 from-classpath 2004-07-17 07:39:16 UTC
Fixed by the following patch:

2004-07-17  Michael Koch  <konqueror@gmx.de>

        * java/net/DatagramSocket.java
        (getLocalAddress): Check if socket is bound or not.
        * java/net/Socket.java
        (getLocalAddrss): Check if socket is bound or not.
        (getPort): Return -1 when not connected. Dont check getImpl() for
        null.
        (setReuseAddress): Check if socket is closed.
        (isConnected): Check if getImpl() returns null.