Do not cache multipart MIME types in cache

Prior to this commmit, "mutipart/*" MIME types would be cached by the
`MimeTypeUtils` LRU cache. Since those MIME types are likely to have
random boundaries in them, they can waste space in the LRU cache.
This is not improving things since we're parsing them anyway.

This commit skips the caching step for all "multipart" MIME types.

Fixes gh-24767
This commit is contained in:
Brian Clozel 2020-03-24 10:50:10 +01:00
parent 1cd0e720f7
commit d97eabba2f
1 changed files with 4 additions and 0 deletions

View File

@ -193,6 +193,10 @@ public abstract class MimeTypeUtils {
if (!StringUtils.hasLength(mimeType)) {
throw new InvalidMimeTypeException(mimeType, "'mimeType' must not be empty");
}
// do not cache multipart mime types with random boundaries
if (mimeType.startsWith("multipart")) {
return parseMimeTypeInternal(mimeType);
}
return cachedMimeTypes.get(mimeType);
}