public static void deleteApplicationFiles(final String applicationFilesDir) {
        if (!StringUtils.isNullOrWhitespaceOnly(applicationFilesDir)) {
            final org.apache.flink.core.fs.Path path =
                    new org.apache.flink.core.fs.Path(applicationFilesDir);
            try {
                final org.apache.flink.core.fs.FileSystem fileSystem = path.getFileSystem();
                if (!fileSystem.delete(path, true)) {
                    LOG.error(
                            "Deleting yarn application files under {} was unsuccessful.",
                            applicationFilesDir);
                }
            } catch (final IOException e) {
                LOG.error(
                        "Could not properly delete yarn application files directory {}.",
                        applicationFilesDir,
                        e);
            }
        } else {
            LOG.debug(
                    "No yarn application files directory set. Therefore, cannot clean up the data.");
        }
    }
@Test
    void testDeleteApplicationFiles(@TempDir Path tempDir) throws Exception {
        final Path applicationFilesDir = Files.createTempDirectory(tempDir, ".flink");
        Files.createTempFile(applicationFilesDir, "flink", ".jar");
        try (Stream<Path> files = Files.list(tempDir)) {
            assertThat(files).hasSize(1);
        }
        try (Stream<Path> files = Files.list(applicationFilesDir)) {
            assertThat(files).hasSize(1);
        }

        Utils.deleteApplicationFiles(applicationFilesDir.toString());
        try (Stream<Path> files = Files.list(tempDir.toFile().toPath())) {
            assertThat(files).isEmpty();
        }
    }