Skip to content

Commit d38c1e0

Browse files
Ignore exceptions when deleting caches in bind cache tests
See gh-40760
1 parent bdc6508 commit d38c1e0

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

Diff for: spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImageIntegrationTests.java

+11-2
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,17 @@ void buildsImageWithBindCaches() throws IOException {
317317
Path launchCachePath = Paths.get(tempDir, "junit-image-cache-" + projectName + "-launch");
318318
assertThat(buildCachePath).exists().isDirectory();
319319
assertThat(launchCachePath).exists().isDirectory();
320-
FileSystemUtils.deleteRecursively(buildCachePath);
321-
FileSystemUtils.deleteRecursively(launchCachePath);
320+
cleanupCache(buildCachePath);
321+
cleanupCache(launchCachePath);
322+
}
323+
324+
private static void cleanupCache(Path buildCachePath) {
325+
try {
326+
FileSystemUtils.deleteRecursively(buildCachePath);
327+
}
328+
catch (Exception ex) {
329+
// ignore
330+
}
322331
}
323332

324333
@TestTemplate

Diff for: spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/BuildImageTests.java

+11-2
Original file line numberDiff line numberDiff line change
@@ -419,11 +419,20 @@ void whenBuildImageIsInvokedWithBindCaches(MavenBuild mavenBuild) {
419419
Path launchCachePath = Paths.get(tempDir, "junit-image-cache-" + testBuildId + "-launch");
420420
assertThat(buildCachePath).exists().isDirectory();
421421
assertThat(launchCachePath).exists().isDirectory();
422-
FileSystemUtils.deleteRecursively(buildCachePath);
423-
FileSystemUtils.deleteRecursively(launchCachePath);
422+
cleanupCache(buildCachePath);
423+
cleanupCache(launchCachePath);
424424
});
425425
}
426426

427+
private static void cleanupCache(Path buildCachePath) {
428+
try {
429+
FileSystemUtils.deleteRecursively(buildCachePath);
430+
}
431+
catch (Exception ex) {
432+
// ignore
433+
}
434+
}
435+
427436
@TestTemplate
428437
void whenBuildImageIsInvokedWithCreatedDate(MavenBuild mavenBuild) {
429438
String testBuildId = randomString();

0 commit comments

Comments
 (0)