Hello-

Recently I created and uploaded a patch for ZOOKEEPER-2511. This jira 
implements the AutoCloseable interface in ZooKeeper.java which would allow 
developers to use try-with-resources with zookeeper. I think this will help 
prevent our users from forgetting to close sessions.

Without repeating the contents of the JIRA discussion I had with Michael Han 
here, there is an issue which revolves around the close() method having “throws 
InterruptedException” in its signature despite never actually throwing that 
exception (I assume this is for API compatibility purposes). If close() throws 
an InterruptedException and AutoCloseable is implemented there can be some 
undefined behavior (and the java compiler will output a warning).

Since we never actually throw that exception, my solution was to ignore the 
compiler warning and leave an explanation in a comment.

Please take a look here: https://issues.apache.org/jira/browse/ZOOKEEPER-2511 
<https://issues.apache.org/jira/browse/ZOOKEEPER-2511> and let me know if there 
is a better way to solve the problem.

Thanks,
Abe

Reply via email to