This is an automated email from the ASF dual-hosted git repository.

MartijnVisser pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/master by this push:
     new 3d6cd0727bc [FLINK-40886][runtime] Do not create the blob directories 
in the file count checks
3d6cd0727bc is described below

commit 3d6cd0727bcfb9941ad45d61ea11cfc4c88c02f7
Author: Robin Varghese <[email protected]>
AuthorDate: Fri Oct 23 10:38:42 2026 +0530

    [FLINK-40886][runtime] Do not create the blob directories in the file count 
checks
    
    checkFileCountForJob and checkFileCountForApplication got the job or 
application
    directory via getStorageLocation, which creates it. When a test checks the 
count while
    the PermanentBlobCache cleanup task is deleting that directory, creating it 
can fail with
    a FileAlreadyExistsException, as in 
BlobLibraryCacheManagerTest#verifyApplicationCleanup
    and BlobCacheCleanupTest#verifyJobCleanup. Build the directory path without 
creating it.
    
    Generated-by: Claude Code 2.1.299 (Claude Opus 5.5)
---
 .../flink/runtime/blob/TestingBlobHelpers.java     | 43 ++++++++++++----------
 1 file changed, 24 insertions(+), 19 deletions(-)

diff --git 
a/flink-runtime/src/test/java/org/apache/flink/runtime/blob/TestingBlobHelpers.java
 
b/flink-runtime/src/test/java/org/apache/flink/runtime/blob/TestingBlobHelpers.java
index df4be740a71..a071473492b 100644
--- 
a/flink-runtime/src/test/java/org/apache/flink/runtime/blob/TestingBlobHelpers.java
+++ 
b/flink-runtime/src/test/java/org/apache/flink/runtime/blob/TestingBlobHelpers.java
@@ -155,6 +155,22 @@ public final class TestingBlobHelpers {
         return numFiles;
     }
 
+    /**
+     * Returns the storage directory of the given blob service.
+     *
+     * <p>The file count checks build the job and application directory paths 
from it instead of
+     * using {@code getStorageLocation}, which creates the directory: a 
cleanup task may be deleting
+     * the directory at the same time, and creating it then can fail with a 
{@link
+     * java.nio.file.FileAlreadyExistsException}.
+     */
+    private static File getStorageDir(PermanentBlobService blobService) {
+        if (blobService instanceof BlobServer) {
+            return ((BlobServer) blobService).getStorageDir();
+        } else {
+            return ((PermanentBlobCache) blobService).getStorageDir();
+        }
+    }
+
     /**
      * Checks how many of the files given by blob keys are accessible.
      *
@@ -165,14 +181,10 @@ public final class TestingBlobHelpers {
     public static void checkFileCountForJob(
             int expectedCount, JobID jobId, PermanentBlobService blobService) 
throws IOException {
 
-        final File jobDir;
-        if (blobService instanceof BlobServer) {
-            BlobServer server = (BlobServer) blobService;
-            jobDir = server.getStorageLocation(jobId, new 
PermanentBlobKey()).getParentFile();
-        } else {
-            PermanentBlobCache cache = (PermanentBlobCache) blobService;
-            jobDir = cache.getStorageLocation(jobId, new 
PermanentBlobKey()).getParentFile();
-        }
+        final File jobDir =
+                new File(
+                        BlobUtils.getStorageLocationPath(
+                                getStorageDir(blobService).getAbsolutePath(), 
jobId));
         File[] blobsForJob = jobDir.listFiles();
         if (blobsForJob == null) {
             if (expectedCount != 0) {
@@ -196,17 +208,10 @@ public final class TestingBlobHelpers {
             int expectedCount, ApplicationID applicationId, 
PermanentBlobService blobService)
             throws IOException {
 
-        final File applicationDir;
-        if (blobService instanceof BlobServer) {
-            BlobServer server = (BlobServer) blobService;
-            applicationDir =
-                    server.getStorageLocation(applicationId, new 
PermanentBlobKey())
-                            .getParentFile();
-        } else {
-            PermanentBlobCache cache = (PermanentBlobCache) blobService;
-            applicationDir =
-                    cache.getStorageLocation(applicationId, new 
PermanentBlobKey()).getParentFile();
-        }
+        final File applicationDir =
+                new File(
+                        BlobUtils.getStorageLocationPath(
+                                getStorageDir(blobService).getAbsolutePath(), 
applicationId));
         File[] blobsForApplication = applicationDir.listFiles();
         if (blobsForApplication == null) {
             if (expectedCount != 0) {

Reply via email to