changeset 5868:fb20a07d5b76 it2-bootstrap

Tweak GroupByOp to not reuse the same Map
author briangoetz
date Mon, 27 Aug 2012 16:07:43 -0400
parents a0aade7ea2c6
children e45e67f1f21f
files src/share/classes/java/util/streams/ops/GroupByOp.java
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/util/streams/ops/GroupByOp.java	Mon Aug 27 15:17:08 2012 -0400
+++ b/src/share/classes/java/util/streams/ops/GroupByOp.java	Mon Aug 27 16:07:43 2012 -0400
@@ -47,16 +47,18 @@
     @Override
     public StatefulSink<T, Map<K, Streamable<T>>> sink() {
         return new StatefulSink<T, Map<K, Streamable<T>>>() {
-            private final Map<K, StreamBuilder<T>> map = new HashMap<>();
+            private Map<K, StreamBuilder<T>> map;
 
             @Override
             public void begin(int size) {
-                map.clear();
+                map = new HashMap<>();
             }
 
             @Override
             public Map<K, Streamable<T>> end() {
-                return (Map) map;
+                Map<K, Streamable<T>> result = (Map) map;
+                map = null;
+                return result;
             }
 
             @Override