public FileSystem get(Key key) {
    synchronized (mLock) {
      Value value = mCacheMap.get(key);
      FileSystem fs;
      if (value == null) {
        // On cache miss, create and insert a new FileSystem instance,
        fs = FileSystem.Factory.create(FileSystemContext.create(key.mSubject, key.mConf));
        mCacheMap.put(key, new Value(fs, 1));
      } else {
        fs = value.mFileSystem;
        value.mRefCount.getAndIncrement();
      }
      return new InstanceCachingFileSystem(fs, key);
    }
  }
@Test
  public void getTwiceThenClose() throws IOException {
    Key key1 = createTestFSKey("user1");
    FileSystem fs1 = mFileSystemCache.get(key1);
    FileSystem fs2 = mFileSystemCache.get(key1);
    fs1.close();
    FileSystem fs3 = mFileSystemCache.get(key1);
    assertSame(getDelegatedFileSystem(fs2), getDelegatedFileSystem(fs3));
    assertTrue(fs1.isClosed());
    assertFalse(fs2.isClosed());
    assertFalse(fs3.isClosed());
  }