ignite-2833 Need call 'touch' for cache entry if it was obtained using 'entryEx'.
(cherry picked from commit 17c2fc0) Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e3f13455 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e3f13455 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e3f13455 Branch: refs/heads/ignite-comm-balance Commit: e3f13455d4273e615727d0410783e3719db98f76 Parents: d595345 Author: sboikov <[email protected]> Authored: Wed Sep 28 12:56:17 2016 +0300 Committer: sboikov <[email protected]> Committed: Wed Sep 28 15:43:13 2016 +0300 ---------------------------------------------------------------------- .../processors/cache/GridCacheTtlManager.java | 32 +++++++++++--------- .../cache/GridCacheAbstractFullApiSelfTest.java | 2 +- 2 files changed, 18 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/e3f13455/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManager.java index 996544f..0f855fe 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManager.java @@ -129,26 +129,28 @@ public class GridCacheTtlManager extends GridCacheManagerAdapter { if (log.isTraceEnabled()) log.trace("Trying to remove expired entry from cache: " + e); - boolean touch = false; + boolean touch = e.ctx.isSwapOrOffheapEnabled(); - GridCacheEntryEx entry = e.ctx.cache().entryEx(e.key); + GridCacheEntryEx entry = touch ? e.ctx.cache().entryEx(e.key) : e.ctx.cache().peekEx(e.key); - while (true) { - try { - if (entry.onTtlExpired(obsoleteVer)) - touch = false; + if (entry != null) { + while (true) { + try { + if (entry.onTtlExpired(obsoleteVer)) + touch = false; - break; - } - catch (GridCacheEntryRemovedException e0) { - entry = entry.context().cache().entryEx(entry.key()); + break; + } + catch (GridCacheEntryRemovedException e0) { + entry = entry.context().cache().entryEx(entry.key()); - touch = true; + touch = true; + } } - } - if (touch) - entry.context().evicts().touch(entry, null); + if (touch) + entry.context().evicts().touch(entry, null); + } } } @@ -216,7 +218,7 @@ public class GridCacheTtlManager extends GridCacheManagerAdapter { private final GridCacheContext ctx; /** Cache Object Key */ - private final CacheObject key; + private final KeyCacheObject key; /** * @param entry Cache entry to create wrapper for. http://git-wip-us.apache.org/repos/asf/ignite/blob/e3f13455/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java index a31c82e..e7daf2b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java @@ -4057,7 +4057,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract // Peek will actually remove entry from cache. assertNull(cache.localPeek(key)); - assert cache.localSize() == 0; + assertEquals(0, cache.localSize()); // Clear readers, if any. cache.remove(key);
