[jboss-jira] [JBoss JIRA] Created: (JBREM-1188) Socket transport doesn't set "timeout" to default value

Ron Sigal (JIRA) jira-events at lists.jboss.org
Fri Feb 19 12:13:10 EST 2010


Socket transport doesn't set "timeout" to default value
-------------------------------------------------------

                 Key: JBREM-1188
                 URL: https://jira.jboss.org/jira/browse/JBREM-1188
             Project: JBoss Remoting
          Issue Type: Bug
      Security Level: Public (Everyone can see)
    Affects Versions: 2.5.2.SP2 (Flounder), 2.2.3.SP1
            Reporter: Ron Sigal
            Assignee: Ron Sigal
             Fix For: 2.2.3.SP2, 2.5.2.SP3 (Flounder)


>From Jaikiran Pai:

Bug, bug, bug  ;)

There's some Java initialization trick going on with that piece of code (only relevant code has been pasted below):

public class SocketClientInvoker extends MicroSocketClientInvoker
{

  /**
   * Default value for socket timeout is 30 minutes.
   */
  public static final int SO_TIMEOUT_DEFAULT = 1800000;

  protected int timeout = SO_TIMEOUT_DEFAULT;
  ...

  public SocketClientInvoker(InvokerLocator locator)
  {
     this(locator, null);
  }

  public SocketClientInvoker(InvokerLocator locator, Map configuration)
  {
     super(locator, configuration);
     configureParameters();
  }

  protected ServerAddress createServerAddress(InetAddress addr, int port)
  {
     return new ServerAddress(addr.getHostAddress(), port, enableTcpNoDelay, timeout, maxPoolSize);
  }
...
}


public class MicroSocketClientInvoker ...
{

  public MicroSocketClientInvoker(InvokerLocator locator, Map configuration)
  {
     ...

     try
     {
        setup();
     }
     ...

     log.debug(this + " constructed");
  }

  protected void setup() throws Exception
  {
     ...
        address = createServerAddress(addr, port);
     }
...
}

1) SocketClientInvoker extends MicroSocketClientInvoker
2) When someone constructs SocketClientInvoker through it's constructor, JVM first constructs MicroSocketClientInvoker.
3) This includes MicroSocketClientInvoker's object field initialization and then the code execution in MicroSocketClientInvoker's constructor.
4) MicroSocketClientInvoker's constructor invokes setup() on itself which then invokes the (overridden) createServerAddress() on SocketClientInvoker
5) Note that, at this point the object field initialization of SocketClientInvoker has *not* yet been done. So the

protected int timeout = SO_TIMEOUT_DEFAULT;

in SocketClientInvoker hasn't yet been executed. Effectively, when SocketClientInvoker.createServerAddress() is invoked, the timeout value is 0. As a result, SocketClientInvoker.createServerAddress() ends up creating a ServerAddress with timeout = 0 (infinite timeout).
(Rest of the flow is irrelevant, but let's just outline it here for the sake of completeness)
6) After completion of SocketClientInvoker.createServerAddress() method invoked in step#4, the MicroSocketClientInvoker.setup too completes and ultimately the code execution in the MicroSocketClientInvoker's constructor too is completed.
7) After step#6, the object field initialization of SocketClientInvoker starts and it's at this point where the timeout field value gets set to 1800000, but by now it's too late.

And here are the logs (only a part of the entire log file) from remoting which prove that the timeout is being set to 0:

2010-02-19 16:32:29,104 DEBUG [org.jboss.remoting.Client] Client[16278782:3j001-51zxod-g5uvg99p-1-g5uvg99q-2].connect(null)
2010-02-19 16:32:29,104 TRACE [org.jboss.remoting.Client] Client[16278782:3j001-51zxod-g5uvg99p-1-g5uvg99q-2]: metadata = null
2010-02-19 16:32:29,172 DEBUG [org.jboss.remoting.transport.socket.MicroSocketClientInvoker] SocketClientInvoker[879860, socket://localhost.localdomain:3873] constructed
2010-02-19 16:32:29,172 DEBUG [org.jboss.remoting.MicroRemoteClientInvoker] SocketClientInvoker[879860, socket://localhost.localdomain:3873] connecting
2010-02-19 16:32:29,173 DEBUG [org.jboss.remoting.transport.socket.MicroSocketClientInvoker] Creating semaphore with size 50
2010-02-19 16:32:29,173 TRACE [org.jboss.remoting.transport.socket.MicroSocketClientInvoker] SocketClientInvoker[879860, socket://localhost.localdomain:3873] added new pool ([]) as ServerAddress[127.0.0.1:3873, NO enableTcpNoDelay timeout 0 ms, maxPoolSize=50]
....
2010-02-19 16:32:29,185 TRACE [org.jboss.remoting.transport.socket.MicroSocketClientInvoker] SocketClientInvoker[879860, socket://localhost.localdomain:3873] retryCount: 0
2010-02-19 16:32:29,185 TRACE [org.jboss.remoting.transport.socket.MicroSocketClientInvoker] SocketClientInvoker[879860, socket://localhost.localdomain:3873] obtained semaphore: 49
2010-02-19 16:32:29,185 TRACE [org.jboss.remoting.transport.socket.MicroSocketClientInvoker] SocketClientInvoker[879860, socket://localhost.localdomain:3873] creating socket
2010-02-19 16:32:29,186 TRACE [org.jboss.remoting.transport.socket.MicroSocketClientInvoker] SocketClientInvoker[879860, socket://localhost.localdomain:3873] created socket: Socket[addr=/127.0.0.1,port=3873,localport=39135]
2010-02-19 16:32:29,187 TRACE [org.jboss.remoting.transport.socket.SocketWrapper] constructing org.jboss.remoting.transport.socket.ClientSocketWrapper instance for Socket[addr=/127.0.0.1,port=3873,localport=39135], using timeout 0
2010-02-19 16:32:29,187 TRACE [org.jboss.remoting.transport.socket.SocketWrapper] ClientSocketWrapper[Socket[addr=/127.0.0.1,port=3873,localport=39135].6c5482] setting timeout to 0
...

regards,
-Jaikiran


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list