MediaType.parseMediaTypes now accepts null and ""

This commit is contained in:
Arjen Poutsma
2009-04-21 13:41:15 +00:00
parent 6be62f30f1
commit dc90319279
2 changed files with 7 additions and 1 deletions

View File

@@ -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) {