#ignite-758: add test for keep portable iterator.

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

Branch: refs/heads/ignite-gg-9702
Commit: 6224b7efd5b9f6ec50b4ce64b8ff7a3849e1fe04
Parents: a64810a
Author: ivasilinets <ivasilin...@gridgain.com>
Authored: Fri Apr 17 16:57:19 2015 +0300
Committer: ivasilinets <ivasilin...@gridgain.com>
Committed: Fri Apr 17 16:57:19 2015 +0300

----------------------------------------------------------------------
 .../internal/processors/cache/GridCacheAdapter.java | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6224b7ef/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 694f3d8..9bd5653 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -3670,12 +3670,13 @@ public abstract class GridCacheAdapter<K, V> implements 
IgniteInternalCache<K, V
     /**
      * @return JCache Iterator.
      */
-    private Iterator<Cache.Entry<K, V>> localIteratorHonorExpirePolicy() {
+    private Iterator<Cache.Entry<K, V>> localIteratorHonorExpirePolicy(final 
CacheOperationContext opCtx) {
         return F.iterator(iterator(),
             new IgniteClosure<Cache.Entry<K, V>, Cache.Entry<K, V>>() {
-                private IgniteCacheExpiryPolicy expiryPlc = 
ctx.cache().expiryPolicy(ctx.expiry());
+                private IgniteCacheExpiryPolicy expiryPlc = 
ctx.cache().expiryPolicy(opCtx.expiry());
 
                 @Override public Cache.Entry<K, V> apply(Cache.Entry<K, V> 
lazyEntry) {
+                    CacheOperationContext prev = ctx.gate().enter(opCtx);
                     try {
                         V val = localPeek(lazyEntry.getKey(), 
CachePeekModes.ONHEAP_ONLY, expiryPlc);
 
@@ -3684,6 +3685,9 @@ public abstract class GridCacheAdapter<K, V> implements 
IgniteInternalCache<K, V
                     catch (IgniteCheckedException e) {
                         throw CU.convertToCacheException(e);
                     }
+                    finally {
+                        ctx.gate().leave(prev);
+                    }
                 }
             }, false
         );
@@ -3695,12 +3699,12 @@ public abstract class GridCacheAdapter<K, V> implements 
IgniteInternalCache<K, V
     public Iterator<Cache.Entry<K, V>> igniteIterator() {
         GridCacheContext ctx0 = ctx.isNear() ? ctx.near().dht().context() : 
ctx;
 
-        if (!ctx0.isSwapOrOffheapEnabled() && 
ctx0.kernalContext().discovery().size() == 1)
-            return localIteratorHonorExpirePolicy();
-
         final CacheOperationContext opCtx = ctx.operationContextPerCall();
 
-        CacheQueryFuture<Map.Entry<K, V>> fut = 
ctx0.queries().createScanQuery(null, false)
+        if (!ctx0.isSwapOrOffheapEnabled() && 
ctx0.kernalContext().discovery().size() == 1)
+            return localIteratorHonorExpirePolicy(opCtx);
+
+        CacheQueryFuture<Map.Entry<K, V>> fut = 
ctx0.queries().createScanQuery(null, ctx.keepPortable())
             .keepAll(false)
             .execute();
 

Reply via email to