/** * Called when the outer {@link ResponseObserver} wants to prematurely cancel the stream. * * @see StreamController#cancel() */ private void onCancel() { StreamController localInnerController; synchronized (lock) { if (cancellationCause != null) { return; } // NOTE: BasicRetryingFuture will replace j.u.c.CancellationExceptions with it's own, // which will not have the current stacktrace, so a special wrapper has be used here. cancellationCause = new ServerStreamingAttemptException( new CancellationException("User cancelled stream"), resumptionStrategy.canResume(), seenSuccessSinceLastError); localInnerController = innerController; } if (localInnerController != null) { localInnerController.cancel(); } }
/** * Called when the outer {@link ResponseObserver} wants to prematurely cancel the stream. * * @see StreamController#cancel() */ private void onCancel() { StreamController localInnerController; synchronized (lock) { if (cancellationCause != null) { return; } // NOTE: BasicRetryingFuture will replace j.u.c.CancellationExceptions with it's own, // which will not have the current stacktrace, so a special wrapper has be used here. cancellationCause = new ServerStreamingAttemptException( new CancellationException("User cancelled stream"), resumptionStrategy.canResume(), seenSuccessSinceLastError); localInnerController = innerController; } if (localInnerController != null) { localInnerController.cancel(); } }
/** * Called when the current RPC fails. The error will be bubbled up to the outer {@link * RetryingFuture} via the {@link #innerAttemptFuture}. */ private void onAttemptError(Throwable throwable) { if (cancellationCause != null) { // Take special care to preserve the cancellation's stack trace. innerAttemptFuture.setException(cancellationCause); } else { // Wrap the original exception and provide more context for StreamingRetryAlgorithm. innerAttemptFuture.setException( new ServerStreamingAttemptException( throwable, resumptionStrategy.canResume(), seenSuccessSinceLastError)); } }
/** * Called when the current RPC fails. The error will be bubbled up to the outer {@link * RetryingFuture} via the {@link #innerAttemptFuture}. */ private void onAttemptError(Throwable throwable) { if (cancellationCause != null) { // Take special care to preserve the cancellation's stack trace. innerAttemptFuture.setException(cancellationCause); } else { // Wrap the original exception and provide more context for StreamingRetryAlgorithm. innerAttemptFuture.setException( new ServerStreamingAttemptException( throwable, resumptionStrategy.canResume(), seenSuccessSinceLastError)); } }