static Reference<File> createBlobStorageDirectory(
            Configuration configuration, @Nullable Reference<File> fallbackStorageDirectory)
            throws IOException {
        final String basePath = configuration.get(BlobServerOptions.STORAGE_DIRECTORY);

        File baseDir = null;
        if (StringUtils.isNullOrWhitespaceOnly(basePath)) {
            if (fallbackStorageDirectory != null) {
                baseDir = fallbackStorageDirectory.deref();

                if (baseDir.mkdirs() || baseDir.exists()) {
                    return fallbackStorageDirectory;
                }
            }
        } else {
            baseDir = new File(basePath);

            File storageDir;

            // NOTE: although we will be using UUIDs, there may be collisions
            int maxAttempts = 10;
            for (int attempt = 0; attempt < maxAttempts; attempt++) {
                storageDir = new File(baseDir, String.format("blobStore-%s", UUID.randomUUID()));

                // Create the storage dir if it doesn't exist. Only return it when the operation was
                // successful.
                if (storageDir.mkdirs()) {
                    return Reference.owned(storageDir);
                }
            }
        }

        if (baseDir != null) {
            throw new IOException(
                    "Could not create storage directory for BLOB store in '" + baseDir + "'.");
        } else {
            throw new IOException(
                    String.format(
                            "Could not create storage directory for BLOB store because no storage directory has "
                                    + "been specified under %s and no fallback storage directory provided.",
                            BlobServerOptions.STORAGE_DIRECTORY.key()));
        }
    }
@Test
    void testTaskManagerFallbackBlobStorageDirectory1() throws IOException {
        Configuration config = new Configuration();
        final File fallbackDirectory = TempDirUtils.newFile(tempDir, "foobar");

        File dir =
                BlobUtils.createBlobStorageDirectory(config, Reference.borrowed(fallbackDirectory))
                        .deref();
        assertThat(dir).isEqualTo(fallbackDirectory);
    }