Uploaded image for project: 'Application Server 3  4  5 and 6'
  1. Application Server 3 4 5 and 6
  2. JBAS-9365

InitialContext#lookup does not timeout on cached context

    XMLWordPrintable

Details

    • Bug
    • Resolution: Obsolete
    • Major
    • None
    • None
    • None
    • None

    Description

      I've got an issue where InitialContext#lookup will hang forever doing a lookup if there is a problem with the network. I appreciate this is the default settings of the TCP sockets to wait forever, so I've tried to configure the timeout using 'jnp.timeout' and 'jnp.sotimeout'. If the network is disconnected prior to the first attempt to do a lookup it times out as expected (I assume this is 'jnp.timeout' which configures the timeout to create the connection). However, if the network is disconnected after one ore more successful lookups have been performed it waits forever. I assume this is there 'jnp.sotimeout' should have kicked in, but doesn't seem to.

      Hashtable<String, String> env = new Hashtable<String, String>();
      env.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
      env.put("java.naming.provider.url", "jnp://10.9.1.11:1099");
      env.put("java.naming.factory.url.pkgs", "org.jboss.naming");
      env.put("jnp.socketFactor", "org.jnp.interfaces.TimedSocketFactory");
      env.put("jnp.timeout", "1000");
      env.put("jnp.sotimeout", "1000");
       
      InitialContext ctx = new InitialContext(env);
       
      ctx.lookup("something");
       
      // disconnect network here
       
      ctx.lookup("something");
      

      In the above example if I disconnect the network before the first lookup it times out as expected, but if I disconnect the network between the first lookup and the second lookup it waits forever. I've tried to wrap it in a thread, that is then interrupted after a timeout, but that doesn't work.

      Looking at the source code from JBoss Naming it seems that 'jnp.timeout' and 'jnp.sotimeout' is only used to retrieve the NamingServer_Stub, once that is retrieved and cached I can't see that they are being used any longer. I believe this would result in the problem I'm seeing as NamingServer_Stub#lookup would not have a socket timeout associated with the RMI call.

      Attachments

        Activity

          People

            Unassigned Unassigned
            sthorger@redhat.com Stian Thorgersen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: