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

java.net.ServerSocket::toString not invoking checkConnect

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8u161, 9, 10, 11, 12, 13
    • Fix Version/s: 13
    • Component/s: core-libs
    • Subcomponent:
    • Resolved In Build:
      b24

      Backports

        Description

        Java doc says:

        "If there is a security manager set, its checkConnect method is called with the local address and -1 as its arguments to see if the operation is allowed. If the operation is not allowed, an InetAddress representing the loopback address is returned as the implementation address."

        However, SecurityManager::checkConnect is never called when ServerSocket::toString() is used.

        ServerSocket::toString() just checks if a security manager is set and if yes it returns loopback address.

        E.g code to reproduce:

              ServerSocket serverSocket = new ServerSocket(0);
              System.setSecurityManager(new SecurityManager(){
                    @Override
                    public void checkConnect(String host, int port) {
                        System.out.println("This is never printed");
                    }
                });
                serverSocket.toString();

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  chegar Chris Hegarty
                  Reporter:
                  dsingh Durgesh Singh (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: