]
Stian Thorgersen commented on JBAS-9365:
----------------------------------------
Also created JBNAME-53, but wasn't sure where I should post this bug
InitialContext#lookup does not timeout on cached context
--------------------------------------------------------
Key: JBAS-9365
URL:
https://issues.jboss.org/browse/JBAS-9365
Project: JBoss Application Server
Issue Type: Bug
Security Level: Public(Everyone can see)
Reporter: Stian Thorgersen
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.
{code}
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");
{code}
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.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: