예제 #1
0
    /** Confined to the eventScheduler. */
    private void tryEndReceive() {
      assert eventScheduler.isExecutingInThis();

      AsyncReport report1;
      AsyncReport report2;

      mainLock.lock();
      try {
        if (sessionReport == null || endReport == null || finished) {
          return;
        }

        finished = true;
        report1 = sessionReport;
        report2 = endReport;
      } finally {
        mainLock.unlock();
      }

      boolean wasCanceled = report1.isCanceled() || report2.isCanceled();
      Throwable ex1 = report1.getException();
      Throwable ex2 = report2.getException();

      Throwable exception;
      if (ex1 == null) {
        exception = ex2;
      } else if (ex2 == null) {
        exception = ex1;
      } else {
        exception = new DataTransferException();
        exception.addSuppressed(ex1);
        exception.addSuppressed(ex2);
      }

      AsyncReport report = AsyncReport.getReport(exception, wasCanceled);
      outputListener.onDoneReceive(report);
    }
예제 #2
0
 private void failSession(Object session, Throwable error) {
   submitEventTask(new SessionEndTask(session, AsyncReport.getReport(error, false)));
 }