Repository: incubator-ignite Updated Branches: refs/heads/sprint-1 029e96b28 -> c6e4f4507
ignite-91 Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/27827c82 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/27827c82 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/27827c82 Branch: refs/heads/sprint-1 Commit: 27827c8217545686e8c5132e0f29dd1aecc19f3b Parents: 9996140 Author: sboikov <sboi...@gridgain.com> Authored: Wed Jan 28 18:09:48 2015 +0300 Committer: sboikov <sboi...@gridgain.com> Committed: Wed Jan 28 18:09:48 2015 +0300 ---------------------------------------------------------------------- .../processors/cache/GridCacheAdapter.java | 26 +++++++++++++------- .../dht/GridPartitionedGetFuture.java | 11 +++++++-- .../dht/atomic/GridDhtAtomicCache.java | 21 ++++++++++++++++ .../dht/atomic/GridNearAtomicUpdateFuture.java | 17 +++++++++++-- .../dht/colocated/GridDhtColocatedCache.java | 3 +++ .../distributed/near/GridNearGetFuture.java | 11 +++++++-- .../local/atomic/GridLocalAtomicCache.java | 12 ++++++--- .../cache/GridCacheAbstractFullApiSelfTest.java | 12 ++++++--- 8 files changed, 91 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/27827c82/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 14ddae1..4f401c0 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 @@ -1681,12 +1681,14 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, } /** {@inheritDoc} */ - @Override public void evictAll(@Nullable Collection<? extends K> keys) { + @Override public void evictAll(Collection<? extends K> keys) { evictAll(keys, (IgnitePredicate<CacheEntry<K, V>>[])null); } /** {@inheritDoc} */ @Nullable @Override public V get(K key) throws IgniteCheckedException { + A.notNull(key, "key"); + boolean statsEnabled = ctx.config().isStatisticsEnabled(); long start = statsEnabled ? System.nanoTime() : 0L; @@ -1704,6 +1706,8 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, /** {@inheritDoc} */ @Override public IgniteFuture<V> getAsync(final K key) { + A.notNull(key, "key"); + final boolean statsEnabled = ctx.config().isStatisticsEnabled(); final long start = statsEnabled ? System.nanoTime() : 0L; @@ -1725,6 +1729,8 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, /** {@inheritDoc} */ @Override public Map<K, V> getAll(@Nullable Collection<? extends K> keys) throws IgniteCheckedException { + A.notNull(keys, "keys"); + boolean statsEnabled = ctx.config().isStatisticsEnabled(); long start = statsEnabled ? System.nanoTime() : 0L; @@ -1742,6 +1748,8 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, /** {@inheritDoc} */ @Override public IgniteFuture<Map<K, V>> getAllAsync(@Nullable final Collection<? extends K> keys) { + A.notNull(keys, "keys"); + final boolean statsEnabled = ctx.config().isStatisticsEnabled(); final long start = statsEnabled ? System.nanoTime() : 0L; @@ -1879,9 +1887,8 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, Map<K, GridCacheVersion> misses = null; for (K key : keys) { - // Ignore null keys. if (key == null) - continue; + throw new NullPointerException("Null key."); while (true) { GridCacheEntryEx<K, V> entry; @@ -2206,14 +2213,12 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, ctx.denyOnLocalRead(); return ctx.wrapClone(asyncOp(new AsyncOp<V>(key) { - @Override - public IgniteFuture<V> op(IgniteTxLocalAdapter<K, V> tx) { + @Override public IgniteFuture<V> op(IgniteTxLocalAdapter<K, V> tx) { return tx.putAllAsync(ctx, F.t(key, val), true, entry, ttl, filter) .chain((IgniteClosure<IgniteFuture<GridCacheReturn<V>>, V>)RET2VAL); } - @Override - public String toString() { + @Override public String toString() { return "putAsync [key=" + key + ", val=" + val + ", filter=" + Arrays.toString(filter) + ']'; } })); @@ -2664,8 +2669,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, } /** {@inheritDoc} */ - @Nullable - @Override public V replace(final K key, final V val) throws IgniteCheckedException { + @Nullable @Override public V replace(final K key, final V val) throws IgniteCheckedException { A.notNull(key, "key", val, "val"); if (keyCheck) @@ -3098,6 +3102,8 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, /** {@inheritDoc} */ @Override public IgniteFuture<Boolean> removexAsync(K key, IgnitePredicate<CacheEntry<K, V>>... filter) { + A.notNull(key, "key"); + return removexAsync(key, null, filter); } @@ -4571,6 +4577,8 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, */ public void evictAll(Collection<? extends K> keys, @Nullable IgnitePredicate<CacheEntry<K, V>>... filter) { + A.notNull(keys, "keys"); + ctx.denyOnFlag(READ); if (F.isEmpty(keys)) http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/27827c82/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java index 23e487f..7227026 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java @@ -290,8 +290,15 @@ public class GridPartitionedGetFuture<K, V> extends GridCompoundIdentityFuture<M // Assign keys to primary nodes. for (K key : keys) { - if (key != null) - hasRmtNodes |= map(key, mappings, locVals, topVer, mapped); + if (key == null) { + NullPointerException err = new NullPointerException("Null key"); + + onDone(err); + + throw err; + } + + hasRmtNodes |= map(key, mappings, locVals, topVer, mapped); } if (isDone()) http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/27827c82/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java index c993397..e35c6d0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java @@ -309,6 +309,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { @SuppressWarnings("unchecked") @Override public IgniteFuture<V> putAsync(K key, V val, @Nullable GridCacheEntryEx<K, V> entry, long ttl, @Nullable IgnitePredicate<CacheEntry<K, V>>... filter) { + A.notNull(key, "key"); + return updateAllAsync0(F0.asMap(key, val), null, null, @@ -324,6 +326,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { @SuppressWarnings("unchecked") @Override public IgniteFuture<Boolean> putxAsync(K key, V val, @Nullable GridCacheEntryEx<K, V> entry, long ttl, @Nullable IgnitePredicate<CacheEntry<K, V>>... filter) { + A.notNull(key, "key"); + return updateAllAsync0(F0.asMap(key, val), null, null, @@ -342,6 +346,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { /** {@inheritDoc} */ @Override public IgniteFuture<V> putIfAbsentAsync(K key, V val) { + A.notNull(key, "key", val, "val"); + return putAsync(key, val, ctx.noPeekArray()); } @@ -352,6 +358,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { /** {@inheritDoc} */ @Override public IgniteFuture<Boolean> putxIfAbsentAsync(K key, V val) { + A.notNull(key, "key", val, "val"); + return putxAsync(key, val, ctx.noPeekArray()); } @@ -362,6 +370,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { /** {@inheritDoc} */ @Override public IgniteFuture<V> replaceAsync(K key, V val) { + A.notNull(key, "key", val, "val"); + return putAsync(key, val, ctx.hasPeekArray()); } @@ -372,6 +382,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { /** {@inheritDoc} */ @Override public IgniteFuture<Boolean> replacexAsync(K key, V val) { + A.notNull(key, "key", val, "val"); + return putxAsync(key, val, ctx.hasPeekArray()); } @@ -382,6 +394,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { /** {@inheritDoc} */ @Override public IgniteFuture<Boolean> replaceAsync(K key, V oldVal, V newVal) { + A.notNull(key, "key", oldVal, "oldVal", newVal, "newVal"); + return putxAsync(key, newVal, ctx.equalsPeekArray(oldVal)); } @@ -398,6 +412,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public IgniteFuture<GridCacheReturn<V>> removexAsync(K key, V val) { + A.notNull(key, "key", val, "val"); + return removeAllAsync0(F.asList(key), null, null, true, true, ctx.equalsPeekArray(val)); } @@ -492,6 +508,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { @SuppressWarnings("unchecked") @Override public IgniteFuture<Boolean> removexAsync(K key, @Nullable GridCacheEntryEx<K, V> entry, @Nullable IgnitePredicate<CacheEntry<K, V>>... filter) { + A.notNull(key, "key"); + return removeAllAsync0(Collections.singletonList(key), null, entry, false, false, filter); } @@ -874,6 +892,9 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { // Optimistically expect that all keys are available locally (avoid creation of get future). for (K key : keys) { + if (key == null) + throw new NullPointerException("Null key."); + GridCacheEntryEx<K, V> entry = null; while (true) { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/27827c82/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java index d55c001..6f6f03b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java @@ -626,8 +626,13 @@ public class GridNearAtomicUpdateFuture<K, V> extends GridFutureAdapter<Object> // Create mappings first, then send messages. for (K key : keys) { - if (key == null) - continue; + if (key == null) { + NullPointerException err = new NullPointerException("Null key."); + + onDone(err); + + throw err; + } Object val; long drTtl; @@ -639,6 +644,14 @@ public class GridNearAtomicUpdateFuture<K, V> extends GridFutureAdapter<Object> drTtl = -1; drExpireTime = -1; drVer = null; + + if (val == null) { + NullPointerException err = new NullPointerException("Null value."); + + onDone(err); + + throw err; + } } else if (drPutVals != null) { GridCacheDrInfo<V> drPutVal = drPutValsIt.next(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/27827c82/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java index ae582cc..668f6fe 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java @@ -265,6 +265,9 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte // Optimistically expect that all keys are available locally (avoid creation of get future). for (K key : keys) { + if (key == null) + throw new NullPointerException("Null key."); + GridCacheEntryEx<K, V> entry = null; while (true) { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/27827c82/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java index 5500ba3..7eb5013 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java @@ -295,8 +295,15 @@ public final class GridNearGetFuture<K, V> extends GridCompoundIdentityFuture<Ma // Assign keys to primary nodes. for (K key : keys) { - if (key != null) - savedVers = map(key, mappings, topVer, mapped, savedVers); + if (key == null) { + NullPointerException err = new NullPointerException("Null key."); + + onDone(err); + + throw err; + } + + savedVers = map(key, mappings, topVer, mapped, savedVers); } if (isDone()) http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/27827c82/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java index 2c4a774..2c360ba 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java @@ -259,7 +259,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> { /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public GridCacheReturn<V> replacex(K key, V oldVal, V newVal) throws IgniteCheckedException { - A.notNull(key, "key"); + A.notNull(key, "key", oldVal, "oldVal", newVal, "newVal"); ctx.denyOnLocalRead(); @@ -277,7 +277,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> { /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public GridCacheReturn<V> removex(K key, V val) throws IgniteCheckedException { - A.notNull(key, "key"); + A.notNull(key, "key", val, "val"); ctx.denyOnLocalRead(); @@ -295,7 +295,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> { /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public IgniteFuture<GridCacheReturn<V>> removexAsync(K key, V val) { - A.notNull(key, "key"); + A.notNull(key, "key", val, "val"); ctx.denyOnLocalRead(); @@ -305,7 +305,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> { /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public IgniteFuture<GridCacheReturn<V>> replacexAsync(K key, V oldVal, V newVal) { - A.notNull(key, "key"); + A.notNull(key, "key", oldVal, "oldVal", newVal, "newVal"); ctx.denyOnLocalRead(); @@ -500,6 +500,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> { throws IgniteCheckedException { ctx.denyOnFlag(LOCAL); + A.notNull(keys, "keys"); + String taskName = ctx.kernalContext().job().currentTaskName(); return getAllInternal(keys, @@ -526,6 +528,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> { ) { ctx.denyOnFlag(LOCAL); + A.notNull(keys, "keys"); + final boolean swapOrOffheap = ctx.isSwapOrOffheapEnabled(); final boolean storeEnabled = ctx.readThrough(); final boolean clone = ctx.hasFlag(CLONE); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/27827c82/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 e7b93bf..905f6b4 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 @@ -525,14 +525,20 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract * @throws Exception In case of error. */ public void testGetAllWithNulls() throws Exception { - GridCache<String, Integer> cache = cache(); + final GridCache<String, Integer> cache = cache(); - Collection<String> c = new LinkedList<>(); + final Collection<String> c = new LinkedList<>(); c.add("key1"); c.add(null); - cache.getAll(c); + GridTestUtils.assertThrows(log, new Callable<Void>() { + @Override public Void call() throws Exception { + cache.getAll(c); + + return null; + } + }, NullPointerException.class, null); } /**