@Test
  public void testPartialRename() throws Exception {

    final CountOperations countOperations = new CountOperations();
    // Create a couple of mock regions where we count the operations
    // that happen to them. We will then use this to abort the rename
    // in the middle.
    ConcurrentHashMap spyFileAndChunkRegion =
        mock(ConcurrentHashMap.class, new SpyWrapper(countOperations, fileAndChunkRegion));


    system = new FileSystem(spyFileAndChunkRegion, fileSystemStats);

    String name = "file";
    File file = system.createFile(name);

    ByteArrayOutputStream expected = new ByteArrayOutputStream();

    // Make sure the file has a lot of chunks
    for (int i = 0; i < 10; i++) {
      expected.write(writeRandomBytes(file));
    }

    String name2 = "file2";
    countOperations.reset();

    system.renameFile(name, name2);

    // Right now the number of operations is 4.. except if run through a debugger...
    assertTrue(4 <= countOperations.count);

    // This number of operations during a rename actually needs to get to the "putIfAbsent" for the
    // Assertion to be correct. Right now the number of operations is actually 3 so the limit needs
    // to be 3...
    countOperations.after((int) Math.ceil(countOperations.count / 2.0 + 1), () -> {
      throw new CacheClosedException();
    });
    String name3 = "file3";
    countOperations.reset();

    try {
      system.renameFile(name2, name3);
      fail("should have seen an error");
    } catch (CacheClosedException ignored) {

    }

    system = new FileSystem(fileAndChunkRegion, fileSystemStats);

    // This is not the ideal behavior. We are left
    // with two duplicate files. However, we will still
    // verify that neither file is corrupted.
    assertEquals(2, system.listFileNames().size());
    File sourceFile = system.getFile(name2);
    File destFile = system.getFile(name3);

    byte[] expectedBytes = expected.toByteArray();

    assertContents(expectedBytes, sourceFile);
    assertContents(expectedBytes, destFile);
  }
Test what happens a file rename is aborted in the middle due to the a cache closed exception.
The next member that uses those files should be able to clean up after the partial rename.
geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/filesystem/FileSystemJUnitTest.java