basho/riak-java-client — Issue #91: Deadlock during shutdown in container - pools
Author: paulbarry
Created: 2012-01-24 16:43:18+00:00
State: open

I'm using riak client from a thread inside Tomcat. Pool is created for a client from a PBClusterConfig
Tomcat fails to shut down gracefully with deadlock because the pools don't shut down.

I've made a fork that fixes it for me, but not sure if it's best way to solve. No easy way to get access to pools from high level client, so I added a shutdown method on client interface that shuts down the pools for cluster configs, and is NOP otherwise.
If you don't call shutdown() behaviour is exactly as before

````java

public void run()
{
PBClientConfig node1 = new PBClientConfig.Builder().withHost("n1").withPort(8087).build();
PBClusterConfig tempConf = new PBClusterConfig(16);
tempConf.addClient(node1);

if(true){
PBClientConfig node2 = PBClientConfig.Builder.from(node1).withHost("n2").withPort(8087).build();
tempConf.addClient(node2);
}

IRiakClient c=RiakFactory.newClient(tempConf);

while(running){
sleep(1000);
c.ping();
....
}
c.shutdown();
````

I didn't push changes to the fork yet to understand if this acceptable way to solve