LinkedCaseInsensitiveMap properly overrides HashMap.clone()

Issue: SPR-14509
(cherry picked from commit dd65f7a)
This commit is contained in:
Juergen Hoeller
2016-07-25 12:08:55 +02:00
parent 82f2983cd4
commit 64595597f3
2 changed files with 31 additions and 1 deletions

View File

@@ -36,7 +36,7 @@ import java.util.Map;
@SuppressWarnings("serial")
public class LinkedCaseInsensitiveMap<V> extends LinkedHashMap<String, V> {
private final Map<String, String> caseInsensitiveKeys;
private Map<String, String> caseInsensitiveKeys;
private final Locale locale;
@@ -151,6 +151,14 @@ public class LinkedCaseInsensitiveMap<V> extends LinkedHashMap<String, V> {
super.clear();
}
@Override
@SuppressWarnings("unchecked")
public Object clone() {
LinkedCaseInsensitiveMap<V> copy = (LinkedCaseInsensitiveMap<V>) super.clone();
copy.caseInsensitiveKeys = new HashMap<String, String>(this.caseInsensitiveKeys);
return copy;
}
/**
* Convert the given key to a case-insensitive key.