Polish Stream#toList() consistent usage
In general, `Stream#toList()` is not a transparent replacement for `.collect(Collectors.toList()))`, as the former returns an immutable list. This commit reverts some of those changes, where the returned `List` instance was expected to be mutable. See gh-29203
This commit is contained in:
@@ -29,6 +29,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
@@ -279,7 +280,7 @@ public abstract class MimeTypeUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the comma-separated string into a list of {@code MimeType} objects.
|
||||
* Parse the comma-separated string into a mutable list of {@code MimeType} objects.
|
||||
* @param mimeTypes the string to parse
|
||||
* @return the list of mime types
|
||||
* @throws InvalidMimeTypeException if the string cannot be parsed
|
||||
@@ -291,7 +292,7 @@ public abstract class MimeTypeUtils {
|
||||
return tokenize(mimeTypes).stream()
|
||||
.filter(StringUtils::hasText)
|
||||
.map(MimeTypeUtils::parseMimeType)
|
||||
.toList();
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user