jetcd icon indicating copy to clipboard operation
jetcd copied to clipboard

watcher.close() throw the EtcdException(InterruptedException)

Open jalenyang opened this issue 9 years ago • 3 comments

Jetcd will throw an EtcdException if you close an on going listened watcher. The InterruptedException exception caused by this.eventsQueue.take(); when you interrupted the thread. For this.eventsQueue.take(); , it is an exception if the thread is interrupted. But for Jetcd the expected behavior for the watcher.close() method is to get the thread interrupted. So why does Jetcd raise an EtcdException exception?

Caused by: java.lang.InterruptedException at java.util.concurrent.FutureTask.awaitDone(FutureTask.java:404) at java.util.concurrent.FutureTask.get(FutureTask.java:191) at com.coreos.jetcd.internal.impl.WatchImpl$WatcherImpl.listen(WatchImpl.java:449) ... 4 more

jalenyang avatar Jul 21 '17 07:07 jalenyang

@jalenyang are you expecting that the behavior of watcher.close() just simply close watcher and not throw any exception?

fanminshi avatar Jul 21 '17 17:07 fanminshi

@jalenyang kindly ping?

fanminshi avatar Jul 25 '17 17:07 fanminshi

@fanminshi yes, my opinion is watcher.close() just simply close watcher and not throw any exception. I checked your changes, but I think it is an InterruptedException instead of ExecutionException. So you should return a default WatchResponse when InterruptedException happen.

jalenyang avatar Aug 02 '17 00:08 jalenyang