- public void onComplete(Throwable failure, Object readResponse) throws Throwable {
- if(failure != null) {
- LOG.debug("Tx {} read operation failed: {}", getIdentifier(), failure);
- returnFuture.setException(new ReadFailedException(
- "Error reading data for path " + path, failure));
-
- } else {
- LOG.debug("Tx {} read operation succeeded", getIdentifier(), failure);
-
- if (readResponse instanceof ReadDataReply) {
- ReadDataReply reply = (ReadDataReply) readResponse;
- returnFuture.set(Optional.<NormalizedNode<?, ?>>fromNullable(reply.getNormalizedNode()));
-
- } else if (ReadDataReply.isSerializedType(readResponse)) {
- ReadDataReply reply = ReadDataReply.fromSerializable(readResponse);
- returnFuture.set(Optional.<NormalizedNode<?, ?>>fromNullable(reply.getNormalizedNode()));
-
- } else {
- returnFuture.setException(new ReadFailedException(
- "Invalid response reading data for path " + path));
- }
+ public void onComplete(final Throwable failure, final Object response) {
+ // We have previously acquired an operation, now release it, no matter what happened
+ if (permitToRelease) {
+ limiter.release();