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

LocalRMIServerSocketFactory should protect against ServerSocket.accept().getInetAddress() being null

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 6u12
    • Fix Version/s: 6u12
    • Component/s: core-svc
    • Labels:
    • Subcomponent:
    • Introduced In Build:
      b01
    • Introduced In Version:
    • Resolved In Build:
      b02
    • CPU:
      x86
    • OS:
      solaris

      Backports

        Description

        Using Netbeans 6.5rc2 for Java EE, with GlassFish ur2v2, in which petstore is deployed.
        While pointing jvisualvm to the local GlassFish process (local attach) - I could sometimes see an exception in GlassFish log file.
        When running glassfish on 6u12 - I could see an NullPointerException in the glassfish log file - and jvisualvm was not able to display GlassFish threads (thread information are obtained through JMX)
        The problem occurs intermitently, and prevents jvisualvm to connect to the target application server using the attach API.

        The root cause of the problem seems to be that sometime, for some reason,
        the Socket created on the server (glassfish) side to handle incomminng
        JMX RMI connections has a null remote InetAddress:

        RMI TCP Accept-0: accept loop for ServerSocket[addr=0.0.0.0/0.0.0.0,port=0,localport=53246] throws
        java.lang.NullPointerException
                at sun.management.jmxremote.LocalRMIServerSocketFactory$1.accept(LocalRMIServerSocketFactory.java:40)
                at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.executeAcceptLoop(TCPTransport.java:369)
                at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.run(TCPTransport.java:341)
                at java.lang.Thread.run(Thread.java:619)

        In the LocalRMIServerSocketFactory the remoteAddr variable returned by the forelast
        line in the code snippet below is null:

            public ServerSocket createServerSocket(int port)
               throws IOException {
                return new ServerSocket(port) {
                    @Override
                    public Socket accept() throws IOException {
                        Socket socket = super.accept();
                        InetAddress remoteAddr = socket.getInetAddress();
                        if (remoteAddr.isAnyLocalAddress()) {

        This problem occurred several times - but not always. If you restart the glassfish appserver it may go away - or remain.
        It looks as if the socket returned by accept() is not always fully initialized?

        Note: the code of the LocalRMIServerSocketFactory changed between 6u11 and 6u12.
        On 6u11 you get an IOException instead - saying that the remoteAddr is not a local address. It is difficult to assert that this happens because the remoteAddr is null, but I suspect as much, so this problem (ServerSocket.accept().getInetAddress()=null)
        is probably older.

        LocalRMIServerSocketFactory should give a better diagnostic and throw an IOException when this happens, rather than a NullPointerException.
        There's still the (unlikely) possibilty that the just accepted socket has already
        been closed - and in that case the exception should probably say so. Also LocalRMIServerSocketFactory should call isLoopbackAddress() rather than isAnyLocalAddress().

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                dfuchs Daniel Fuchs
                Reporter:
                dfuchs Daniel Fuchs
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: