diff --git a/spring-core/src/main/java/org/springframework/util/LinkedCaseInsensitiveMap.java b/spring-core/src/main/java/org/springframework/util/LinkedCaseInsensitiveMap.java index bf12dabf92..cb319718df 100644 --- a/spring-core/src/main/java/org/springframework/util/LinkedCaseInsensitiveMap.java +++ b/spring-core/src/main/java/org/springframework/util/LinkedCaseInsensitiveMap.java @@ -55,10 +55,13 @@ public class LinkedCaseInsensitiveMap implements Map, Serializable private final Locale locale; + @Nullable private transient Set keySet; + @Nullable private transient Collection values; + @Nullable private transient Set> entrySet; @@ -320,6 +323,7 @@ public class LinkedCaseInsensitiveMap implements Map, Serializable return false; } + @Nullable private String removeCaseInsensitiveKey(String key) { return this.caseInsensitiveKeys.remove(convertKey(key)); } @@ -329,12 +333,10 @@ public class LinkedCaseInsensitiveMap implements Map, Serializable private final Set delegate; - KeySet(Set delegate) { this.delegate = delegate; } - @Override public int size() { return this.delegate.size(); @@ -369,7 +371,6 @@ public class LinkedCaseInsensitiveMap implements Map, Serializable public void forEach(Consumer action) { this.delegate.forEach(action); } - } @@ -377,12 +378,10 @@ public class LinkedCaseInsensitiveMap implements Map, Serializable private final Collection delegate; - Values(Collection delegate) { this.delegate = delegate; } - @Override public int size() { return this.delegate.size(); @@ -412,7 +411,6 @@ public class LinkedCaseInsensitiveMap implements Map, Serializable public void forEach(Consumer action) { this.delegate.forEach(action); } - } @@ -420,12 +418,10 @@ public class LinkedCaseInsensitiveMap implements Map, Serializable private final Set> delegate; - public EntrySet(Set> delegate) { this.delegate = delegate; } - @Override public int size() { return this.delegate.size(); @@ -441,7 +437,6 @@ public class LinkedCaseInsensitiveMap implements Map, Serializable return new EntrySetIterator(); } - @Override @SuppressWarnings("unchecked") public boolean remove(Object o) { @@ -452,7 +447,6 @@ public class LinkedCaseInsensitiveMap implements Map, Serializable return false; } - @Override public void clear() { this.delegate.clear(); @@ -468,7 +462,6 @@ public class LinkedCaseInsensitiveMap implements Map, Serializable public void forEach(Consumer> action) { this.delegate.forEach(action); } - } @@ -476,6 +469,7 @@ public class LinkedCaseInsensitiveMap implements Map, Serializable private final Iterator> delegate; + @Nullable private Entry last; public EntryIterator() { @@ -494,12 +488,11 @@ public class LinkedCaseInsensitiveMap implements Map, Serializable public void remove() { this.delegate.remove(); - if(this.last != null) { + if (this.last != null) { removeCaseInsensitiveKey(this.last.getKey()); this.last = null; } } - } @@ -509,7 +502,6 @@ public class LinkedCaseInsensitiveMap implements Map, Serializable public String next() { return nextEntry().getKey(); } - } @@ -519,7 +511,6 @@ public class LinkedCaseInsensitiveMap implements Map, Serializable public V next() { return nextEntry().getValue(); } - } @@ -529,7 +520,6 @@ public class LinkedCaseInsensitiveMap implements Map, Serializable public Entry next() { return nextEntry(); } - } }