# IGNITE-54-55 Bug fixes.

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

Branch: refs/heads/ignite-188
Commit: 052b4362663fc189a07e602f7aaec3e0a9809f0e
Parents: c0571b8
Author: sevdokimov <sevdoki...@gridgain.com>
Authored: Thu Feb 5 17:51:55 2015 +0300
Committer: sevdokimov <sevdoki...@gridgain.com>
Committed: Thu Feb 5 17:51:55 2015 +0300

----------------------------------------------------------------------
 .../GridDistributedCacheAdapter.java            | 33 +++++++++++++-------
 1 file changed, 21 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/052b4362/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java
index 71e7157..937438c 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java
@@ -211,24 +211,33 @@ public abstract class GridDistributedCacheAdapter<K, V> 
extends GridCacheAdapter
 
             final GridCacheContext<K, V> ctx = cacheAdapter.context();
 
-            if (ctx.affinity().affinityTopologyVersion() != topVer)
-                return null; // Ignore this remove request because remove 
request will be sent again.
+            ctx.affinity().affinityReadyFuture(topVer).get();
 
-            if (cacheAdapter instanceof GridNearCacheAdapter)
-                cacheAdapter = ((GridNearCacheAdapter<K, 
V>)cacheAdapter).dht();
+            ctx.gate().enter();
 
-            GridDhtCacheAdapter<K, V> dht = (GridDhtCacheAdapter<K, 
V>)cacheAdapter;
+            try {
+                if (ctx.affinity().affinityTopologyVersion() != topVer)
+                    return null; // Ignore this remove request because remove 
request will be sent again.
 
-            IgniteDataLoader<K, V> dataLdr = ignite.dataLoader(cacheName);
+                GridDhtCacheAdapter<K, V> dht;
 
-            for (GridDhtLocalPartition<K, V> locPart : 
dht.topology().currentLocalPartitions()) {
-                if (!locPart.isEmpty() && locPart.primary(topVer)) {
-                    for (GridDhtCacheEntry<K, V> o : locPart.entries())
-                        dataLdr.removeData(o.key());
+                if (cacheAdapter instanceof GridNearCacheAdapter)
+                    dht = ((GridNearCacheAdapter<K, V>)cacheAdapter).dht();
+                else
+                    dht = (GridDhtCacheAdapter<K, V>)cacheAdapter;
+
+                try (IgniteDataLoader<K, V> dataLdr = 
ignite.dataLoader(cacheName)) {
+                    for (GridDhtLocalPartition<K, V> locPart : 
dht.topology().currentLocalPartitions()) {
+                        if (!locPart.isEmpty() && locPart.primary(topVer)) {
+                            for (GridDhtCacheEntry<K, V> o : locPart.entries())
+                                dataLdr.removeData(o.key());
+                        }
+                    }
                 }
             }
-
-            dataLdr.close();
+            finally {
+                ctx.gate().leave();
+            }
 
             return null;
         }

Reply via email to