From fb2908867073a273334f67c93923b30b6aea4a2d Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 8 May 2019 17:52:28 +0200 Subject: [PATCH] Revise LinkedCaseInsensitiveMap's lazy key/value/entry collections Closes gh-22926 --- .../util/LinkedCaseInsensitiveMap.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) 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 cb319718df..5cdd9f1243 100644 --- a/spring-core/src/main/java/org/springframework/util/LinkedCaseInsensitiveMap.java +++ b/spring-core/src/main/java/org/springframework/util/LinkedCaseInsensitiveMap.java @@ -56,13 +56,13 @@ public class LinkedCaseInsensitiveMap implements Map, Serializable private final Locale locale; @Nullable - private transient Set keySet; + private transient volatile Set keySet; @Nullable - private transient Collection values; + private transient volatile Collection values; @Nullable - private transient Set> entrySet; + private transient volatile Set> entrySet; /** @@ -465,7 +465,7 @@ public class LinkedCaseInsensitiveMap implements Map, Serializable } - private class EntryIterator { + private abstract class EntryIterator implements Iterator { private final Iterator> delegate; @@ -476,16 +476,18 @@ public class LinkedCaseInsensitiveMap implements Map, Serializable this.delegate = targetMap.entrySet().iterator(); } - public Entry nextEntry() { + protected Entry nextEntry() { Entry entry = this.delegate.next(); this.last = entry; return entry; } + @Override public boolean hasNext() { return this.delegate.hasNext(); } + @Override public void remove() { this.delegate.remove(); if (this.last != null) { @@ -496,7 +498,7 @@ public class LinkedCaseInsensitiveMap implements Map, Serializable } - private class KeySetIterator extends EntryIterator implements Iterator { + private class KeySetIterator extends EntryIterator { @Override public String next() { @@ -505,7 +507,7 @@ public class LinkedCaseInsensitiveMap implements Map, Serializable } - private class ValuesIterator extends EntryIterator implements Iterator { + private class ValuesIterator extends EntryIterator { @Override public V next() { @@ -514,7 +516,7 @@ public class LinkedCaseInsensitiveMap implements Map, Serializable } - private class EntrySetIterator extends EntryIterator implements Iterator> { + private class EntrySetIterator extends EntryIterator> { @Override public Entry next() {