MediaType.parseMediaTypes now accepts null and ""

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@1038 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Arjen Poutsma
2009-04-21 13:41:15 +00:00
parent 4ed4544a88
commit 24c7108e76
2 changed files with 7 additions and 1 deletions
@@ -318,7 +318,9 @@ public class MediaType implements Comparable<MediaType> {
* @throws IllegalArgumentException if the string cannot be parsed
*/
public static List<MediaType> parseMediaTypes(String mediaTypes) {
Assert.hasLength(mediaTypes, "'mediaTypes' must not be empty");
if (!StringUtils.hasLength(mediaTypes)) {
return Collections.emptyList();
}
String[] tokens = mediaTypes.split(",\\s*");
List<MediaType> result = new ArrayList<MediaType>(tokens.length);
for (String token : tokens) {