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.
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.