You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2017/10/09 10:42:21 UTC
[05/25] ignite git commit: IGNITE-6307 If getAll() fails with NPE,
onHeap entry is not removed, for local cache
IGNITE-6307 If getAll() fails with NPE, onHeap entry is not removed, for local cache
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e74163a9
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e74163a9
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e74163a9
Branch: refs/heads/ignite-3478
Commit: e74163a99870bd50b24ea6799b7566dc37682f74
Parents: b2a0295
Author: Nikolay Izhikov <NI...@gmail.com>
Authored: Wed Oct 4 19:31:17 2017 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Wed Oct 4 19:31:17 2017 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheAdapter.java | 16 +++++++
.../cache/GridCacheAbstractFullApiSelfTest.java | 45 +++++++++++++++++++-
2 files changed, 59 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e74163a9/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 6d9f0d3..8c5d6f2 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
@@ -1853,6 +1853,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
if (tx == null || tx.implicit()) {
Map<KeyCacheObject, EntryGetResult> misses = null;
+ Set<GridCacheEntryEx> newLocalEntries = null;
+
final AffinityTopologyVersion topVer = tx == null ? ctx.affinity().affinityTopologyVersion() :
tx.topologyVersion();
@@ -1925,6 +1927,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
}
if (!skipEntry) {
+ boolean isNewLocalEntry = this.map.getEntry(ctx, key) == null;
+
entry = entryEx(key);
if (entry == null) {
@@ -1934,6 +1938,13 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
break;
}
+ if (isNewLocalEntry) {
+ if (newLocalEntries == null)
+ newLocalEntries = new HashSet<>();
+
+ newLocalEntries.add(entry);
+ }
+
if (storeEnabled) {
res = entry.innerGetAndReserveForLoad(updateMetrics,
evt,
@@ -2128,6 +2139,11 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
ctx.evicts().touch(peekEx(key0), topVer);
}
+ if (newLocalEntries != null) {
+ for (GridCacheEntryEx entry : newLocalEntries)
+ removeEntry(entry);
+ }
+
return new GridFinishedFuture<>(e);
}
catch (IgniteCheckedException e) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/e74163a9/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 bf27e26..e6c9589 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
@@ -919,13 +919,54 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
/**
* @throws Exception In case of error.
*/
- public void testGetAllWithNulls() throws Exception {
+ public void testGetAllWithLastNull() throws Exception {
final IgniteCache<String, Integer> cache = jcache();
- final Set<String> c = new HashSet<>();
+ final Set<String> c = new LinkedHashSet<>();
+
+ c.add("key1");
+ c.add(null);
+
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ cache.getAll(c);
+
+ return null;
+ }
+ }, NullPointerException.class, null);
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testGetAllWithFirstNull() throws Exception {
+ final IgniteCache<String, Integer> cache = jcache();
+
+ final Set<String> c = new LinkedHashSet<>();
+
+ c.add(null);
+ c.add("key1");
+
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ cache.getAll(c);
+
+ return null;
+ }
+ }, NullPointerException.class, null);
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testGetAllWithInTheMiddle() throws Exception {
+ final IgniteCache<String, Integer> cache = jcache();
+
+ final Set<String> c = new LinkedHashSet<>();
c.add("key1");
c.add(null);
+ c.add("key2");
GridTestUtils.assertThrows(log, new Callable<Void>() {
@Override public Void call() throws Exception {