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

java.net.ServerSocket::toString not invoking checkConnect

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P3
    • Resolution: Approved
    • Fix Version/s: 13
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      behavioral
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      Minor clarification that specifies existing behavior.
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

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

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: