src/share/classes/java/util/TreeMap.java

Print this page
rev 6093 : 7175464: entrySetView field is never updated in NavigableSubMap
Summary: The method entrySet() in AscendingSubMap and DescendingSubMap failed to cache the entrySetView.
Reviewed-by: duke

*** 1757,1767 **** } } public Set<Map.Entry<K,V>> entrySet() { EntrySetView es = entrySetView; ! return (es != null) ? es : new AscendingEntrySetView(); } TreeMap.Entry<K,V> subLowest() { return absLowest(); } TreeMap.Entry<K,V> subHighest() { return absHighest(); } TreeMap.Entry<K,V> subCeiling(K key) { return absCeiling(key); } --- 1757,1767 ---- } } public Set<Map.Entry<K,V>> entrySet() { EntrySetView es = entrySetView; ! return (es != null) ? es : (entrySetView = new AscendingEntrySetView()); } TreeMap.Entry<K,V> subLowest() { return absLowest(); } TreeMap.Entry<K,V> subHighest() { return absHighest(); } TreeMap.Entry<K,V> subCeiling(K key) { return absCeiling(key); }
*** 1838,1848 **** } } public Set<Map.Entry<K,V>> entrySet() { EntrySetView es = entrySetView; ! return (es != null) ? es : new DescendingEntrySetView(); } TreeMap.Entry<K,V> subLowest() { return absHighest(); } TreeMap.Entry<K,V> subHighest() { return absLowest(); } TreeMap.Entry<K,V> subCeiling(K key) { return absFloor(key); } --- 1838,1848 ---- } } public Set<Map.Entry<K,V>> entrySet() { EntrySetView es = entrySetView; ! return (es != null) ? es : (entrySetView = new DescendingEntrySetView()); } TreeMap.Entry<K,V> subLowest() { return absHighest(); } TreeMap.Entry<K,V> subHighest() { return absLowest(); } TreeMap.Entry<K,V> subCeiling(K key) { return absFloor(key); }