Summary
Add a minor clarification to the java.net.ServerSocket::toString
method to specify that SecurityManager::checkConnect
is only invoked
when the socket is bound.
Problem
The java.net.ServerSocket::toString
method specifies that
SecurityManager::checkConnect
is invoked to determine if the calling
context has permission to include the local address in the String
representation.
If the server socket is not bound, then it does not yet have a local
address. An implementation should not be required, in fact cannot,
invoke checkConnect
on an unbound socket, since the local address has
not yet been assigned.
Solution
Add a minor clarification that SecurityManager::checkConnect
is only
invoked when the socket is bound.
Specification
/**
* Returns the implementation address and implementation port of
* this socket as a {@code String}.
* <p>
- * If there is a security manager set, its {@code checkConnect} method is
+ * If there is a security manager set, and this socket is
+ * {@linkplain #isBound bound}, its {@code checkConnect} method is
* called with the local address and {@code -1} as its arguments to see
* if the operation is allowed. If the operation is not allowed,
* an {@code InetAddress} representing the
* {@link InetAddress#getLoopbackAddress loopback} address is returned as
* the implementation address.
*
* @return a string representation of this socket.
*/
public String toString()
- csr of
-
JDK-8224730 java.net.ServerSocket::toString not invoking checkConnect
- Resolved