7175464: entrySetView field is never updated in NavigableSubMap
authormduigou
Thu, 29 Nov 2012 14:07:47 -0800
changeset 14685 07f3bb681bfc
parent 14684 dc1a2233ac21
child 14686 fb59583d33b2
7175464: entrySetView field is never updated in NavigableSubMap Summary: The method entrySet() in AscendingSubMap and DescendingSubMap failed to cache the entrySetView. Reviewed-by: alanb, psandoz
jdk/src/share/classes/java/util/TreeMap.java
--- a/jdk/src/share/classes/java/util/TreeMap.java	Thu Nov 29 17:03:52 2012 +0000
+++ b/jdk/src/share/classes/java/util/TreeMap.java	Thu Nov 29 14:07:47 2012 -0800
@@ -1759,7 +1759,7 @@
 
         public Set<Map.Entry<K,V>> entrySet() {
             EntrySetView es = entrySetView;
-            return (es != null) ? es : new AscendingEntrySetView();
+            return (es != null) ? es : (entrySetView = new AscendingEntrySetView());
         }
 
         TreeMap.Entry<K,V> subLowest()       { return absLowest(); }
@@ -1840,7 +1840,7 @@
 
         public Set<Map.Entry<K,V>> entrySet() {
             EntrySetView es = entrySetView;
-            return (es != null) ? es : new DescendingEntrySetView();
+            return (es != null) ? es : (entrySetView = new DescendingEntrySetView());
         }
 
         TreeMap.Entry<K,V> subLowest()       { return absHighest(); }