On Mar 17, 2008, at 3:03, Massimo Marazza wrote:
Thank you very much for your reply. Do you think you will make a fix?
Unfortunately, I don't see how it's possible for this bug to actually
happen on a working JVM. Assuming we're all talking about the same bug:
http://code.google.com/p/spymemcached/issues/detail?id=10
The log is showing an unhandled exception coming out of a try block
that catches Exception (and I've confirmed that the exception descends
from java.lang.Exception). I can't catch it anymore than I already
am, so I may need a bit more help in reproduction.
In particular, I haven't been able to run anything under windows
(I've got a VM with XP, but I don't have any idea how to use it).
I've tried this workaround in the singleton that creates the
MemcachedClient object
public synchronized static MemcachedClient getIstance(String
hostcache) throws Exception{
if (memcachedClient == null) {
try { memcachedClient = new
MemcachedClient(AddrUtil.getAddresses(hostcache));
} catch(Exception e) { e.printStackTrace(); }
}else{
if (!memcachedClient.isAlive()){
try { memcachedClient = new
MemcachedClient(AddrUtil.getAddresses(hostcache));
} catch(Exception e) {e.printStackTrace();}
}
return memcachedClient;
}
}
If the memcached server is down, when I try to get a MemcachedClient
object for the first time, a new MemcachedClient object is created.
Next times, when I try to get an istance, the MemcachedClient is
alive so the thread is running trying to connect to memcached
server. When the memcached server
goes up, the thread connects to server.
Do you think it could be a good workaround?
It may be. I can't guarantee it'll clean up resources since there's
not a proper shutdown sequence there. It also swallows errors in two
places. If you just took out the try and catch blocks, it'd be safer.
--
Dustin Sallings