Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8224972

java.net.ServerSocket::toString not invoking checkConnect

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P3 P3
    • 13
    • core-libs
    • None
    • behavioral
    • minimal
    • Minor clarification that specifies existing behavior.
    • Java API
    • SE

      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()

            chegar Chris Hegarty
            dsingh Durgesh Singh (Inactive)
            Alan Bateman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: