Calls the TodoActivity's replicationComplete method on the main thread,
as the error() callback will probably come from a replicator worker
thread.
349102
@Subscribe
    public void error(ReplicationErrored re) {
        Log.e(LOG_TAG, "Replication error:", re.errorInfo);
        mHandler.post(new Runnable() {
            @Override
            public void run() {
                if (mListener != null) {
                    mListener.replicationError();
                }
            }
        });
    }
121454
public static void postTaskError(final TaskCompletionListener completionListener, final String errorMessage) {
        new Handler(Looper.getMainLooper()).post(new Runnable() {
            @Override
            public void run() {
                if (null != completionListener) {
                    completionListener.onError(errorMessage);
                }
            }
        });
    }
988773
public void onComplete(String response, boolean error, String errorMessage,
            final String stackTrace, String statusCode, int statusCodeInt) {
        cancelCancellable();
        reply(response, error, errorMessage, stackTrace, statusCode,
                statusCodeInt);
    }
695538
final void connectionErrorOccurred(final Exception exception, boolean callJCAListener) {

        final String methodName = "connectionErrorOccurred";
        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, methodName, new Object[] {exception, Boolean.valueOf(callJCAListener)});
        }

        /*
         * Only send the event if the server isn't shutting down anyway
         */

        if (!SibRaEngineComponent.isServerStopping()) {

            final ConnectionEvent event = new ConnectionEvent(this,
                    ConnectionEvent.CONNECTION_ERROR_OCCURRED, exception);

            // Copy list to protect against concurrent modification by listener
            final List copy;
            synchronized (_eventListeners) {
                copy = new ArrayList(_eventListeners);
            }

            // We will probably want to look into some how figuring out that the listener
            // that we have is the JCA one and not some other one that is registered as we
            // want to call those ones regardless of the flag. Today we only expect JCA listeners
            // to be registered
            if (callJCAListener)
            {
              for (final Iterator iterator = copy.iterator(); iterator.hasNext();) {
                final Object object = iterator.next();
                if (object instanceof ConnectionEventListener) {
                    ((ConnectionEventListener) object)
                            .connectionErrorOccurred(event);
                }
              }
            }

        }

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, methodName);
        }

    }
1363808
public final void listenInlineGenericError(AsyncWork<T, Exception> sp) {
		listenInline(new AsyncWorkListener<T,TError>() {
			@Override
			public void ready(T result) {
				sp.unblockSuccess(result);
			}
			
			@Override
			public void error(TError error) {
				sp.unblockError(error);
			}
			
			@Override
			public void cancelled(CancelException event) {
				sp.unblockCancel(event);
			}
		});
	}
1219337
public void onCompleted() {
    mSerializingExecutor.execute(() -> {
      Preconditions.checkState(mContext != null);
      try {
        completeRequest(mContext);
        replySuccess();
      } catch (Exception e) {
        LogUtils.warnWithException(LOG, "Exception occurred while completing write request {}.",
            mContext.getRequest(), e);
        Throwables.throwIfUnchecked(e);
        abort(new Error(AlluxioStatusException.fromCheckedException(e), true));
      }
    });
  }
503045
private void complete(T result, Throwable error) {
    synchronized (orderedFutures) {
      this.result = result;
      this.error = error;
      this.complete = true;
      if (error == null) {
        for (CompletableFuture<T> future : orderedFutures) {
          future.complete(result);
        }
      } else {
        for (CompletableFuture<T> future : orderedFutures) {
          future.completeExceptionally(error);
        }
      }
      orderedFutures.clear();
    }
  }
1046261
@Subscribe
    public void complete(ReplicationCompleted rc) {
        mHandler.post(new Runnable() {
            @Override
            public void run() {
                if (mListener != null) {
                    mListener.replicationComplete();
                }
            }
        });
    }
536909
final synchronized void invoke() {
        result = null;
        exception = null;
        try {
            result = call();
        } catch( Throwable e ) {
            exception = e;
        } finally {
        	done = true;
        }

        // let the calling thread know that we are done.
        notify();
    }
278848
@Override
  public void onError(final Exception error) {
    submitCompletion(new Runnable() {

      @Override
      public void run() {
        observer.onError(error);
      }

    });
  }
814750
@Override
	public T call() throws Exception {
		logger.debug("task '{}' starting", id);		
		try {
			// do the real work 
			return task.execute();
		} finally {
			// signal that the task is complete
			logger.debug("task '{}' is complete (queue size: {})", id, queue.size());
			queue.offer(id);			
		}
	}
187471
@Override
    public void executeEventCallback(Runnable callback) {
        if (!nodeEngine.isRunning()) {
            return;
        }
        try {
            eventExecutor.execute(callback);
        } catch (RejectedExecutionException e) {
            rejectedCount.inc();

            if (eventExecutor.isLive()) {
                logFailure("EventQueue overloaded! Failed to execute event callback: %s", callback);
            }
        }
    }
1231869
public static void invokeOnError(AsyncMethodCallback<?> callback, Throwable cause) {
        requireNonNull(callback, "callback");
        requireNonNull(cause, "cause");
        if (cause instanceof Exception) {
            callback.onError((Exception) cause);
        } else {
            callback.onError(new CompletionException(cause.toString(), cause));
        }
    }
1214493
public void cancel(Exception reason) {
        // IMPROVEMENT: need to rework how syncs on the future.complete() work. We really should be
        // syncing here, so we don't do the channel.cancel if the request is processing
        // future.complete() on another thread at the same time. Should just do a quick
        // sync, check the future.complete flag, then process only if !complete. That will
        // also mean we can remove a bunch of redundant checks for complete, but we need to check all
        // the paths carefully.
        if (this.channel == null) {
            return;
        }
        synchronized (this.completedSemaphore) {
            if (!this.completed) {
                try {
                    // this ends up calling future.completed()
                    this.channel.cancel(this, reason);
                } catch (Exception e) {
                    // Simply swallow the exception
                } // end try

            } else {
                if (this.channel.readFuture != null) {
                    this.channel.readFuture.setCancelInProgress(0);
                }
                if (this.channel.writeFuture != null) {
                    this.channel.writeFuture.setCancelInProgress(0);
                }
            }
        }
    }
999602
public synchronized final void completed(@CheckForNull Throwable error) {
        if (executor!=null) {
            executor.completedAsynchronous(error);
        } else {
            result = error == null ? NULL : error;
        }
    }
1212917
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
		// Stop view stopwatch
		stopStopwatch();

		// Remove location
		threadLocation.remove();
	}
316907
def _future_completed(future):
    
    exc = future.exception()
    if exc:
        log.debug("Failed to run task on executor", exc_info=exc)