From d38c1e06b33ba0e4d7c3ae5a96ef188e4313a1fe Mon Sep 17 00:00:00 2001 From: Scott Frederick Date: Thu, 16 May 2024 22:19:04 -0500 Subject: [PATCH] Ignore exceptions when deleting caches in bind cache tests See gh-40760 --- .../bundling/BootBuildImageIntegrationTests.java | 13 +++++++++++-- .../springframework/boot/maven/BuildImageTests.java | 13 +++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImageIntegrationTests.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImageIntegrationTests.java index b20924ad7d6..9202d349b15 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImageIntegrationTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImageIntegrationTests.java @@ -317,8 +317,17 @@ class BootBuildImageIntegrationTests { Path launchCachePath = Paths.get(tempDir, "junit-image-cache-" + projectName + "-launch"); assertThat(buildCachePath).exists().isDirectory(); assertThat(launchCachePath).exists().isDirectory(); - FileSystemUtils.deleteRecursively(buildCachePath); - FileSystemUtils.deleteRecursively(launchCachePath); + cleanupCache(buildCachePath); + cleanupCache(launchCachePath); + } + + private static void cleanupCache(Path buildCachePath) { + try { + FileSystemUtils.deleteRecursively(buildCachePath); + } + catch (Exception ex) { + // ignore + } } @TestTemplate diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/BuildImageTests.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/BuildImageTests.java index b4d0fffeb5b..ab33e71ed8f 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/BuildImageTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/BuildImageTests.java @@ -419,11 +419,20 @@ class BuildImageTests extends AbstractArchiveIntegrationTests { Path launchCachePath = Paths.get(tempDir, "junit-image-cache-" + testBuildId + "-launch"); assertThat(buildCachePath).exists().isDirectory(); assertThat(launchCachePath).exists().isDirectory(); - FileSystemUtils.deleteRecursively(buildCachePath); - FileSystemUtils.deleteRecursively(launchCachePath); + cleanupCache(buildCachePath); + cleanupCache(launchCachePath); }); } + private static void cleanupCache(Path buildCachePath) { + try { + FileSystemUtils.deleteRecursively(buildCachePath); + } + catch (Exception ex) { + // ignore + } + } + @TestTemplate void whenBuildImageIsInvokedWithCreatedDate(MavenBuild mavenBuild) { String testBuildId = randomString();