killme2008 / xmemcached

High performance, easy to use multithreaded memcached client in java.
http://fnil.net/xmemcached
Apache License 2.0
757 stars 281 forks source link

addServer() not blocking and causes uncaught exception with Healing enabled #138

Open drahgon55 opened 1 year ago

drahgon55 commented 1 year ago

addServer() is non-blocking. According to the documentation it is supposed to block until a successful or failed connection. The documentation also says that a IOException should be thrown if the client cannot connect. Instead addServer() seems to try to connect on a separate thread and allow the calling thread to immediately continue. In the case of no memcached server being available and healing set to true. addServer() not thrown an immediate IOException and instead returns normally a memcachedClient instance. A background thread keeps trying to connect until retries are exhausted and then an IOException is thrown in that separate thread cause crashing my app unexpectedly.

I had to write some logic to handle this unexpected behavior using the stateListeners.

I think either the logic should be fixed to match the docs or the docs should be edited to match the behavior and possibly some examples added on how to handle memcached server not available when addServer() is called.