case READY:
throw new IllegalStateException("Attempted to preCommit in stage " + ready.stage);
default:
- throw new IllegalStateException("Unhandled commit stage " + ready.stage);
+ throwUnhandledCommitStage(ready);
}
}
case READY:
throw new IllegalStateException("Attempted to doCommit in stage " + ready.stage);
default:
- throw new IllegalStateException("Unhandled commit stage " + ready.stage);
+ throwUnhandledCommitStage(ready);
}
}
case PRE_COMMIT_PENDING:
throw new IllegalStateException("Attempted to canCommit in stage " + ready.stage);
default:
- throw new IllegalStateException("Unhandled commit stage " + ready.stage);
+ throwUnhandledCommitStage(ready);
}
}
});
break;
default:
- throw new IllegalStateException("Unhandled commit stage " + ready.stage);
+ throwUnhandledCommitStage(ready);
}
}
private ExistsTransactionSuccess handleExistsTransaction(final ExistsTransactionRequest request)
throws RequestException {
- final Optional<NormalizedNode<?, ?>> data = checkOpen().getSnapshot().readNode(request.getPath());
+ final Optional<NormalizedNode<?, ?>> data = Optional.fromJavaUtil(checkOpen().getSnapshot().readNode(
+ request.getPath()));
return recordSuccess(request.getSequence(), new ExistsTransactionSuccess(getIdentifier(), request.getSequence(),
data.isPresent()));
}
private ReadTransactionSuccess handleReadTransaction(final ReadTransactionRequest request)
throws RequestException {
- final Optional<NormalizedNode<?, ?>> data = checkOpen().getSnapshot().readNode(request.getPath());
+ final Optional<NormalizedNode<?, ?>> data = Optional.fromJavaUtil(checkOpen().getSnapshot().readNode(
+ request.getPath()));
return recordSuccess(request.getSequence(), new ReadTransactionSuccess(getIdentifier(), request.getSequence(),
data));
}
}
}
- private @Nullable TransactionSuccess<?> handleModifyTransaction(final ModifyTransactionRequest request,
+ @Nullable
+ private TransactionSuccess<?> handleModifyTransaction(final ModifyTransactionRequest request,
final RequestEnvelope envelope, final long now) throws RequestException {
// We need to examine the persistence protocol first to see if this is an idempotent request. If there is no
// protocol, there is nothing for us to do.
state);
return ((Sealed) state).sealedModification;
}
+
+ private static void throwUnhandledCommitStage(final Ready ready) {
+ throw new IllegalStateException("Unhandled commit stage " + ready.stage);
+ }
}