Use Stream.toList instead of Stream.collect when possible
Update code to make use of `Stream.toList()` whenever possible. Closes gh-28177
This commit is contained in:
@@ -41,7 +41,6 @@ import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.jar.JarOutputStream;
|
||||
import java.util.jar.Manifest;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
@@ -577,9 +576,8 @@ 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).collect(Collectors.toList()));
|
||||
extractedLayers.put(layerName, Files.walk(layer.toPath()).filter((path) -> path.toFile().isFile())
|
||||
.map(layer.toPath()::relativize).map(Path::toString).map(StringUtils::cleanPath).toList());
|
||||
}
|
||||
return extractedLayers;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.jar.JarOutputStream;
|
||||
import java.util.jar.Manifest;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
@@ -720,7 +719,7 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
List<String> entryLines(JarFile jarFile, String entryName) throws IOException {
|
||||
try (BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(jarFile.getInputStream(jarFile.getEntry(entryName))))) {
|
||||
return reader.lines().collect(Collectors.toList());
|
||||
return reader.lines().toList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user