The ZooKeeperStateHandleStore#releaseAndTryRemove method executes parts of its logic synchronously (retrieving the state handle and unlocking the ZNode) and others asynchronously (removing the ZNode). Moreover, the method takes a parameter which is used to execute some logic in case of a successful removal. This was done in order to execute a potentially blocking state discard operation in a different thread.
I think this can be simplified by executing all logic in the same thread and running the callback after having called ZooKeeperStateHandleStore#releaseAndTryRemove. Moreover, if this operation needs to be not blocking one could use a different thread to call into this method.