- // Sequence has already been checked
- abstract @Nullable TransactionSuccess<?> handleRequest(TransactionRequest<?> request,
- RequestEnvelope envelope, long now) throws RequestException;
+ // Request order has already been checked by caller and replaySequence()
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ final @Nullable TransactionSuccess<?> handleRequest(final TransactionRequest<?> request,
+ final RequestEnvelope envelope, final long now) throws RequestException {
+ if (previousFailure != null) {
+ LOG.debug("{}: Rejecting request {} due to previous failure", persistenceId(), request, previousFailure);
+ throw previousFailure;
+ }
+
+ try {
+ return doHandleRequest(request, envelope, now);
+ } catch (RuntimeException e) {
+ /*
+ * The request failed to process, we should not attempt to ever apply it again. Furthermore we cannot
+ * accept any further requests from this connection, simply because the transaction state is undefined.
+ */
+ LOG.debug("{}: Request {} failed to process", persistenceId(), request, e);
+ previousFailure = new RuntimeRequestException("Request " + request + " failed to process", e);
+ throw previousFailure;
+ }
+ }
+
+ abstract @Nullable TransactionSuccess<?> doHandleRequest(TransactionRequest<?> request, RequestEnvelope envelope,
+ long now) throws RequestException;