ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yzhda...@apache.org
Subject [19/50] incubator-ignite git commit: Sprint-2 - Fixed linked hash map iterator bug found in IGNITE-264.
Date Fri, 27 Mar 2015 13:43:00 GMT
Sprint-2 - Fixed linked hash map iterator bug found in IGNITE-264.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/23ea8789
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/23ea8789
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/23ea8789

Branch: refs/heads/gg-9869
Commit: 23ea87896063c5776aae0cf2499f402000b1630b
Parents: e60f86a
Author: Alexey Goncharuk <agoncharuk@gridgain.com>
Authored: Thu Mar 26 19:17:41 2015 -0700
Committer: Alexey Goncharuk <agoncharuk@gridgain.com>
Committed: Thu Mar 26 19:17:41 2015 -0700

----------------------------------------------------------------------
 .../java/org/jsr166/ConcurrentLinkedHashMap.java   |  9 +++++++++
 .../utils/GridConcurrentLinkedHashMapSelfTest.java | 17 +++++++++++++++++
 2 files changed, 26 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/23ea8789/modules/core/src/main/java/org/jsr166/ConcurrentLinkedHashMap.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/jsr166/ConcurrentLinkedHashMap.java b/modules/core/src/main/java/org/jsr166/ConcurrentLinkedHashMap.java
index 2eb27a1..1de7cc1 100644
--- a/modules/core/src/main/java/org/jsr166/ConcurrentLinkedHashMap.java
+++ b/modules/core/src/main/java/org/jsr166/ConcurrentLinkedHashMap.java
@@ -695,6 +695,15 @@ public class ConcurrentLinkedHashMap<K, V> extends AbstractMap<K,
V> implements
                     if (!onlyIfAbsent) {
                         e.val = val;
 
+                        ConcurrentLinkedDeque8.Node node = e.node;
+
+                        if (node != null) {
+                            HashEntry<K, V> qEntry = (HashEntry<K, V>)node.item();
+
+                            if (qEntry != null && qEntry != e)
+                                qEntry.val = val;
+                        }
+
                         modified = true;
                     }
                 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/23ea8789/modules/core/src/test/java/org/apache/ignite/lang/utils/GridConcurrentLinkedHashMapSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/lang/utils/GridConcurrentLinkedHashMapSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/lang/utils/GridConcurrentLinkedHashMapSelfTest.java
index b583cf8..ffc9e05 100644
--- a/modules/core/src/test/java/org/apache/ignite/lang/utils/GridConcurrentLinkedHashMapSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/lang/utils/GridConcurrentLinkedHashMapSelfTest.java
@@ -176,6 +176,23 @@ public class GridConcurrentLinkedHashMapSelfTest extends GridCommonAbstractTest
     }
 
     /**
+     * @throws Exception If failed.
+     */
+    public void testRehash() throws Exception {
+        Map<Integer, Date> map = new ConcurrentLinkedHashMap<>(10);
+
+        for (int i = 0; i < 100; i++)
+            // Will initiate rehash in the middle.
+            map.put(i, new Date(0));
+
+        for (int i = 0; i < 100; i++)
+            map.put(i, new Date(1));
+
+        for (Date date : map.values())
+            assertEquals(1L, date.getTime());
+    }
+
+    /**
      *
      */
     public void testDescendingMethods() {


Mime
View raw message