@Override
  public void close() throws UnavailableException {
    // JournalContext is closed before block deletion context so that file system master changes
    // are written before block master changes. If a failure occurs between deleting an inode and
    // remove its blocks, it's better to have an orphaned block than an inode with a missing block.
    closeQuietly(mJournalContext);
    closeQuietly(mBlockDeletionContext);

    if (mThrown != null) {
      Throwables.propagateIfPossible(mThrown, UnavailableException.class);
      throw new RuntimeException(mThrown);
    }
  }
@Test
  public void throwTwoRuntimeExceptions() throws Throwable {
    Exception bdcException = new IllegalStateException("block deletion context exception");
    Exception jcException = new IllegalArgumentException("journal context exception");
    doThrow(bdcException).when(mMockBDC).close();
    doThrow(jcException).when(mMockJC).close();
    try {
      mRpcContext.close();
      fail("Expected an exception to be thrown");
    } catch (RuntimeException e) {
      assertEquals(jcException, e);
      // journal context is closed first, so the block deletion context exception should be
      // suppressed.
      assertEquals(bdcException, e.getSuppressed()[0]);
    }
  }