Пример #1
0
 /**
  * If a context {@link #isCancelled()} then return the cause of the cancellation or {@code null}
  * if context was cancelled without a cause. If the context is not yet cancelled will always
  * return {@code null}.
  *
  * <p>The cancellation cause is provided for informational purposes only and implementations
  * should generally assume that it has already been handled and logged properly.
  */
 @Nullable
 public Throwable cancellationCause() {
   if (parent == null || !cascadesCancellation) {
     return null;
   } else {
     return parent.cancellationCause();
   }
 }
Пример #2
0
 @Override
 public void cancelled(Context context) {
   if (Context.this instanceof CancellableContext) {
     // Record cancellation with its cancellationCause.
     ((CancellableContext) Context.this).cancel(context.cancellationCause());
   } else {
     notifyAndClearListeners();
   }
 }