Browse Source

Polish

See gh-22340
pull/22350/head
Brian Clozel 6 years ago
parent
commit
1bf3b36ce8
  1. 12
      spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java
  2. 2
      spring-web/src/main/java/org/springframework/http/MediaType.java

12
spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java

@ -399,6 +399,16 @@ public abstract class MimeTypeUtils { @@ -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 <K> the type of the key used for caching
* @param <V> the type of the cached values
*/
static class ConcurrentLRUCache<K, V> {
private final int maxSize;
@ -418,7 +428,7 @@ public abstract class MimeTypeUtils { @@ -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)) {

2
spring-web/src/main/java/org/springframework/http/MediaType.java

@ -328,7 +328,7 @@ public class MediaType extends MimeType implements Serializable { @@ -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);

Loading…
Cancel
Save