rkhachatryan commented on a change in pull request #18963:
URL: https://github.com/apache/flink/pull/18963#discussion_r818939316



##########
File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/state/filesystem/FileStateHandleTest.java
##########
@@ -57,27 +59,97 @@ public void testDisposeDeletesFile() throws Exception {
      */
     @Test
     public void testDisposeDoesNotDeleteParentDirectory() throws Exception {
-        File parentDir = tempFolder.newFolder();
-        assertTrue(parentDir.exists());
+        final Path p = new Path(TEST_SCHEME + "://path/with/parent");
+        final List<Path> pathsToDelete = new ArrayList<>();
 
-        File file = new File(parentDir, "test");
-        writeTestData(file);
-        assertTrue(file.exists());
+        initializeFileSystem(
+                (path, ignoredRecursionMarker) -> {
+                    pathsToDelete.add(path);
+                    return true;
+                });
 
-        FileStateHandle handle = new FileStateHandle(Path.fromLocalFile(file), 
file.length());
+        final FileStateHandle handle = new FileStateHandle(p, 42);
         handle.discardState();
-        assertFalse(file.exists());
-        assertTrue(parentDir.exists());
+        assertThat(pathsToDelete)
+                .as(
+                        "Only one delete call should have happened on the 
actual path but not the parent.")
+                .singleElement()
+                .isEqualTo(p);

Review comment:
       TBH, the older version seems more readable to me. It also doesn't need 
to be updated if `FileStateHandle` internals are changed.
   But I'm fine with this version as well.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to