LinkedCaseInsensitiveMap properly overrides HashMap.clone()

Issue: SPR-14509
This commit is contained in:
Juergen Hoeller
2016-07-25 12:08:55 +02:00
parent 249b798059
commit dd65f7acfc
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<>(this.caseInsensitiveKeys);
return copy;
}
/**
* Convert the given key to a case-insensitive key.