diff --git a/spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java b/spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java index 2a05265b09..7fad2a4b3d 100644 --- a/spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java +++ b/spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java @@ -399,6 +399,16 @@ public abstract class MimeTypeUtils { return new String(generateMultipartBoundary(), StandardCharsets.US_ASCII); } + /** + * Simple Least Recently Used cache, bounded by the maximum size given + * to the class constructor. + * This implementation is backed by a {@code ConcurrentHashMap} for storing + * the cached values and a {@code ConcurrentLinkedQueue} for ordering + * the keys and choosing the least recently used key when the cache is at + * full capacity. + * @param the type of the key used for caching + * @param the type of the cached values + */ static class ConcurrentLRUCache { private final int maxSize; @@ -418,7 +428,7 @@ public abstract class MimeTypeUtils { this.generator = generator; } - public V get(K key) { + V get(K key) { this.lock.readLock().lock(); try { if (this.queue.remove(key)) { diff --git a/spring-web/src/main/java/org/springframework/http/MediaType.java b/spring-web/src/main/java/org/springframework/http/MediaType.java index b00eabec6e..78db60611b 100644 --- a/spring-web/src/main/java/org/springframework/http/MediaType.java +++ b/spring-web/src/main/java/org/springframework/http/MediaType.java @@ -328,7 +328,7 @@ public class MediaType extends MimeType implements Serializable { APPLICATION_FORM_URLENCODED = new MediaType("application", "x-www-form-urlencoded"); APPLICATION_JSON = new MediaType("application", "json"); APPLICATION_JSON_UTF8 = new MediaType("application", "json", StandardCharsets.UTF_8); - APPLICATION_OCTET_STREAM = new MediaType("application", "octet-stream");; + APPLICATION_OCTET_STREAM = new MediaType("application", "octet-stream"); APPLICATION_PDF = new MediaType("application", "pdf"); APPLICATION_PROBLEM_JSON = new MediaType("application", "problem+json"); APPLICATION_PROBLEM_JSON_UTF8 = new MediaType("application", "problem", StandardCharsets.UTF_8);