@Override
  public void downgradeLastEdge() {
    Preconditions.checkState(!endsInInode(),
        "Cannot downgrade last edge when lock list %s ends in an inode", this);
    Preconditions.checkState(!mLocks.isEmpty(),
        "Cannot downgrade last edge when the lock list is empty");
    Preconditions.checkState(endsInWriteLock(),
        "Cannot downgrade last edge when lock list %s is not write locked", this);

    if (!endsInMultipleWriteLocks()) {
      Edge lastEdge = lastEdge();
      RWLockResource newLock = mInodeLockManager.lockEdge(lastEdge, LockMode.READ, mUseTryLock);
      removeLastLock();
      addEdgeLock(lastEdge, LockMode.READ, newLock);
    }
  }
@Test
  public void downgradeLastEdge() {
    mLockList.lockRootEdge(LockMode.WRITE);
    mLockList.downgradeLastEdge();
    assertEquals(LockMode.READ, mLockList.getLockMode());

    mLockList.lockInode(mRootDir, LockMode.READ);
    mLockList.lockEdge(mRootDir, mDirA.getName(), LockMode.WRITE);
    mLockList.downgradeLastEdge();
    assertEquals(LockMode.READ, mLockList.getLockMode());

    checkOnlyNodesReadLocked(mRootDir);
    checkOnlyNodesWriteLocked();
    checkOnlyIncomingEdgesReadLocked(mRootDir, mDirA);
    checkOnlyIncomingEdgesWriteLocked();
  }