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

java/rmi/transport/httpSocket/HttpSocketTest.java fails with java.net.BindException: Address already in use

    XMLWordPrintable

Details

    • x86_64
    • os_x

    Description

      This is due to race condition in
      registry = TestLibrary.createRegistryOnUnusedPort(); which invokes
          public static int getUnusedRandomPort()

      which is flawed as the allocated port can be reused by the OS.
      AND
      there's an OSX port allocation bug whereby the OS allocates an ephemeral port currently in use for a tcp4 socket to a ServerSocket on wildcard ip address which uses a tcp46 (INET6) socket

      This is a pervasive issue across on macosx


      command: main HttpSocketTest
      reason: User specified action: run main/othervm/policy=security.policy HttpSocketTest
      Mode: othervm [/othervm specified]
      elapsed time (seconds): 0.28
      ----------configuration:(0/0)----------
      ----------System.out:(0/0)----------
      ----------System.err:(73/4825)----------
      installing socket factory
      Starting registry
      TEST FAILED:
      Test failed with: Port already in use: 49157; nested exception is:
      java.net.BindException: Address already in use (Bind failed)
      java.rmi.server.ExportException: Port already in use: 49157; nested exception is:
      java.net.BindException: Address already in use (Bind failed)
      at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:346)
      at sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:254)
      at sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:412)
      at sun.rmi.transport.LiveRef.exportObject(LiveRef.java:147)
      at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:237)
      at sun.rmi.registry.RegistryImpl.setup(RegistryImpl.java:219)
      at sun.rmi.registry.RegistryImpl.<init>(RegistryImpl.java:204)
      at java.rmi.registry.LocateRegistry.createRegistry(LocateRegistry.java:203)
      at TestLibrary.createRegistryOnUnusedPort(TestLibrary.java:410)
      at HttpSocketTest.main(HttpSocketTest.java:80)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
      at java.lang.Thread.run(Thread.java:750)
      Caused by: java.net.BindException: Address already in use (Bind failed)
      at java.net.PlainSocketImpl.socketBind(Native Method)
      at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:513)
      at java.net.ServerSocket.bind(ServerSocket.java:375)
      at java.net.ServerSocket.<init>(ServerSocket.java:237)
      at java.net.ServerSocket.<init>(ServerSocket.java:128)
      at sun.rmi.transport.proxy.HttpAwareServerSocket.<init>(HttpAwareServerSocket.java:50)
      at sun.rmi.transport.proxy.RMIHttpToPortSocketFactory.createServerSocket(RMIHttpToPortSocketFactory.java:51)
      at sun.rmi.transport.tcp.TCPEndpoint.newServerSocket(TCPEndpoint.java:670)
      at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:335)
      ... 15 more
      TestFailedException: TEST FAILED: ; nested exception is:
      java.rmi.server.ExportException: Port already in use: 49157; nested exception is:
      java.net.BindException: Address already in use (Bind failed)
      java.rmi.server.ExportException: Port already in use: 49157; nested exception is:
      java.net.BindException: Address already in use (Bind failed)
      at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:346)
      at sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:254)
      at sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:412)
      at sun.rmi.transport.LiveRef.exportObject(LiveRef.java:147)
      at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:237)
      at sun.rmi.registry.RegistryImpl.setup(RegistryImpl.java:219)
      at sun.rmi.registry.RegistryImpl.<init>(RegistryImpl.java:204)
      at java.rmi.registry.LocateRegistry.createRegistry(LocateRegistry.java:203)
      at TestLibrary.createRegistryOnUnusedPort(TestLibrary.java:410)
      at HttpSocketTest.main(HttpSocketTest.java:80)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
      at java.lang.Thread.run(Thread.java:750)
      Caused by: java.net.BindException: Address already in use (Bind failed)
      at java.net.PlainSocketImpl.socketBind(Native Method)
      at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:513)
      at java.net.ServerSocket.bind(ServerSocket.java:375)
      at java.net.ServerSocket.<init>(ServerSocket.java:237)
      at java.net.ServerSocket.<init>(ServerSocket.java:128)
      at sun.rmi.transport.proxy.HttpAwareServerSocket.<init>(HttpAwareServerSocket.java:50)
      at sun.rmi.transport.proxy.RMIHttpToPortSocketFactory.createServerSocket(RMIHttpToPortSocketFactory.java:51)
      at sun.rmi.transport.tcp.TCPEndpoint.newServerSocket(TCPEndpoint.java:670)
      at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:335)
      ... 15 more

      JavaTest Message: Test threw exception: TestFailedException: TEST FAILED: ; nested exception is:
      java.rmi.server.ExportException: Port already in use: 49157; nested exception is:
      java.net.BindException: Address already in use (Bind failed)
      JavaTest Message: shutting down test

      STATUS:Failed.`main' threw exception: TestFailedException: TEST FAILED: ; nested exception is: java.rmi.server.ExportException: Port already in use: 49157; nested exception is: java.net.BindException: Address already in use (Bind failed)

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              msheppar Mark Sheppard
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: