riemann-java-client icon indicating copy to clipboard operation
riemann-java-client copied to clipboard

Improper handling of thread interrupts while derefing a promise

Open aengelberg opened this issue 9 years ago • 0 comments

I'm experiencing issues in riemann-clojure-client that I believe can be traced to the following issues in the java client.

When derefing the promise while the thread gets interrupted, I get a NullPointerException. When derefing the promise with a timeout while the thread gets interrupted, the timeout value is returned. Most importantly, in either case, the thread interrupt gets swallowed and the Thread.interrupted() flag stays false, which prevents the calling thread from ever being able to stop. Actually, coincidentally the thread is stopping in the non-timeout case because of the NullPointerException.

I'm not sure if returning nil or the timeout value is intended behavior in the interrupt scenario, but I believe at the very least, both methods should call Thread.currentThread().interrupt() before returning, to allow the interrupted thread to at least see that it is interrupted and exit accordingly.

aengelberg avatar Oct 04 '16 17:10 aengelberg