File tree 2 files changed +3
-0
lines changed
spring-core/src/main/java/org/springframework/util
spring-web/src/main/java/org/springframework/http 2 files changed +3
-0
lines changed Original file line number Diff line number Diff line change @@ -167,6 +167,7 @@ public abstract class MimeTypeUtils {
167
167
private static volatile Random random ;
168
168
169
169
static {
170
+ // Not using "parseMimeType" to avoid static init cost
170
171
ALL = new MimeType ("*" , "*" );
171
172
APPLICATION_JSON = new MimeType ("application" , "json" );
172
173
APPLICATION_OCTET_STREAM = new MimeType ("application" , "octet-stream" );
Original file line number Diff line number Diff line change @@ -323,6 +323,7 @@ public class MediaType extends MimeType implements Serializable {
323
323
324
324
325
325
static {
326
+ // Not using "valueOf' to avoid static init cost
326
327
ALL = new MediaType ("*" , "*" );
327
328
APPLICATION_ATOM_XML = new MediaType ("application" , "atom+xml" );
328
329
APPLICATION_FORM_URLENCODED = new MediaType ("application" , "x-www-form-urlencoded" );
@@ -552,6 +553,7 @@ public static List<MediaType> parseMediaTypes(@Nullable String mediaTypes) {
552
553
if (!StringUtils .hasLength (mediaTypes )) {
553
554
return Collections .emptyList ();
554
555
}
556
+ // Avoid using java.util.stream.Stream in hot paths
555
557
List <String > tokenizedTypes = MimeTypeUtils .tokenize (mediaTypes );
556
558
List <MediaType > result = new ArrayList <>(tokenizedTypes .size ());
557
559
for (String type : tokenizedTypes ) {
You can’t perform that action at this time.
0 commit comments