Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,20 @@ public abstract class MimeTypeUtils {
TEXT_XML = new MimeType("text", "xml");
}

/***
* Whether need cache.
* <p>For example "multipart/form-data; boundary=----WebKitFormBoundarymKzwdDkWNDNzQFP0",
* this mimeType with random characters, wastes LRU cache space, resulting in severe performance degradation.
* @param mimeType the mime type
* @return whether need cache
*/
private static boolean ensureMimeTypeRequiredCache(String mimeType){
// TODO constant
if(mimeType.startsWith("multipart/form-data;"))
return false;
return true;
}


/**
* Parse the given String into a single {@code MimeType}.
Expand All @@ -193,7 +207,9 @@ public static MimeType parseMimeType(String mimeType) {
if (!StringUtils.hasLength(mimeType)) {
throw new InvalidMimeTypeException(mimeType, "'mimeType' must not be empty");
}
return cachedMimeTypes.get(mimeType);
if (ensureMimeTypeRequiredCache(mimeType))
return cachedMimeTypes.get(mimeType);
return parseMimeTypeInternal(mimeType);
}

private static MimeType parseMimeTypeInternal(String mimeType) {
Expand Down