Use AutoClosables with try-with-resources

Closes gh-33538
This commit is contained in:
Moritz Halbritter
2022-12-16 15:43:15 +01:00
parent 725337f976
commit f36e2ecb7b
16 changed files with 121 additions and 77 deletions

View File

@@ -585,8 +585,12 @@ abstract class AbstractBootArchiveIntegrationTests {
for (String layerName : layerNames) {
File layer = new File(root, layerName);
assertThat(layer).isDirectory();
extractedLayers.put(layerName, Files.walk(layer.toPath()).filter((path) -> path.toFile().isFile())
.map(layer.toPath()::relativize).map(Path::toString).map(StringUtils::cleanPath).toList());
List<String> files;
try (Stream<Path> pathStream = Files.walk(layer.toPath())) {
files = pathStream.filter((path) -> path.toFile().isFile()).map(layer.toPath()::relativize)
.map(Path::toString).map(StringUtils::cleanPath).toList();
}
extractedLayers.put(layerName, files);
}
return extractedLayers;
}