File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
main/java/org/springframework/util
test/java/org/springframework/util Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change 11/*
2- * Copyright 2002-2015 the original author or authors.
2+ * Copyright 2002-2016 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -220,6 +220,9 @@ public static MimeType parseMimeType(String mimeType) {
220220 throw new InvalidMimeTypeException (mimeType , "'mimeType' must not be empty" );
221221 }
222222 String [] parts = StringUtils .tokenizeToStringArray (mimeType , ";" );
223+ if (parts .length == 0 ) {
224+ throw new InvalidMimeTypeException (mimeType , "'mimeType' must not be empty" );
225+ }
223226
224227 String fullType = parts [0 ].trim ();
225228 // java.net.HttpURLConnection returns a *; q=.2 Accept header
Original file line number Diff line number Diff line change @@ -189,6 +189,11 @@ public void parseMimeTypeIllegalSubtype() {
189189 MimeTypeUtils .parseMimeType ("audio/basic)" );
190190 }
191191
192+ @ Test (expected = InvalidMimeTypeException .class )
193+ public void parseMimeTypeMissingTypeAndSubtype () throws Exception {
194+ MimeTypeUtils .parseMimeType (" ;a=b" );
195+ }
196+
192197 @ Test (expected = InvalidMimeTypeException .class )
193198 public void parseMimeTypeEmptyParameterAttribute () {
194199 MimeTypeUtils .parseMimeType ("audio/*;=value" );
@@ -263,13 +268,13 @@ public void compareTo() {
263268
264269 assertTrue ("Invalid comparison result" , audioBasicLevel .compareTo (audio ) > 0 );
265270
266- List <MimeType > expected = new ArrayList <MimeType >();
271+ List <MimeType > expected = new ArrayList <>();
267272 expected .add (audio );
268273 expected .add (audioBasic );
269274 expected .add (audioBasicLevel );
270275 expected .add (audioWave );
271276
272- List <MimeType > result = new ArrayList <MimeType >(expected );
277+ List <MimeType > result = new ArrayList <>(expected );
273278 Random rnd = new Random ();
274279 // shuffle & sort 10 times
275280 for (int i = 0 ; i < 10 ; i ++) {
You can’t perform that action at this time.
0 commit comments