Skip to content

Commit

Permalink
Do not cache multipart MIME types in cache
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bclozel committed Mar 24, 2020
1 parent 1cd0e72 commit d97eabb
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ public static MimeType parseMimeType(String mimeType) {
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);
}

Expand Down

0 comments on commit d97eabb

Please sign in to comment.