Repository: ignite Updated Branches: refs/heads/master 306f77868 -> 409a55226
IGNITE-8516 Not null constraint doesn't checked Signed-off-by: Anton Vinogradov <a...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/409a5522 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/409a5522 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/409a5522 Branch: refs/heads/master Commit: 409a55226a6f180293793d617f5eb65dd51aee69 Parents: 306f778 Author: sbt-garus-dg <garus....@gmail.com> Authored: Tue May 22 14:05:58 2018 +0300 Committer: Anton Vinogradov <a...@apache.org> Committed: Tue May 22 14:05:58 2018 +0300 ---------------------------------------------------------------------- .../dht/atomic/GridNearAtomicUpdateFuture.java | 6 +- .../query/IgniteSqlNotNullConstraintTest.java | 88 ++++++++++++-------- 2 files changed, 59 insertions(+), 35 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/409a5522/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 e516a99..78725d6 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 @@ -1105,8 +1105,12 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu KeyCacheObject cacheKey = cctx.toCacheKeyObject(key); - if (op != TRANSFORM) + if (op != TRANSFORM) { val = cctx.toCacheObject(val); + + if (op == CREATE || op == UPDATE) + cctx.validateKeyAndValue(cacheKey, (CacheObject)val); + } else val = EntryProcessorResourceInjectorProxy.wrap(cctx.kernalContext(), (EntryProcessor)val); http://git-wip-us.apache.org/repos/asf/ignite/blob/409a5522/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlNotNullConstraintTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlNotNullConstraintTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlNotNullConstraintTest.java index 7a62931..3a90c99 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlNotNullConstraintTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlNotNullConstraintTest.java @@ -389,25 +389,12 @@ public class IgniteSqlNotNullConstraintTest extends GridCommonAbstractTest { /** */ public void testAtomicOrImplicitTxPutAll() throws Exception { - executeWithAllCaches(new TestClosure() { - @Override public void run() throws Exception { - Throwable t = GridTestUtils.assertThrowsWithCause(new Callable<Object>() { - @Override public Object call() throws Exception { - cache.putAll(F.asMap(key1, okValue, key2, badValue)); - - return null; - } - }, IgniteSQLException.class); - - IgniteSQLException ex = X.cause(t, IgniteSQLException.class); - - assertNotNull(ex); - - assertTrue(ex.getMessage().contains(ERR_MSG)); + doAtomicOrImplicitTxPutAll(F.asMap(1, okValue, 5, badValue), 1); + } - assertEquals(isLocalAtomic() ? 1 : 0, cache.size()); - } - }); + /** */ + public void testAtomicOrImplicitTxPutAllForSingleValue() throws Exception { + doAtomicOrImplicitTxPutAll(F.asMap(5, badValue), 0); } /** */ @@ -604,23 +591,12 @@ public class IgniteSqlNotNullConstraintTest extends GridCommonAbstractTest { /** */ public void testTxPutAll() throws Exception { - executeWithAllTxCaches(new TestClosure() { - @Override public void run() throws Exception { - GridTestUtils.assertThrows(log, new Callable<Object>() { - @Override public Object call() throws Exception { - try (Transaction tx = ignite.transactions().txStart(concurrency, isolation)) { - cache.putAll(F.asMap(key1, okValue, key2, badValue)); - - tx.commit(); - } - - assertEquals(0, cache.size()); + doTxPutAll(F.asMap(1, okValue, 5, badValue)); + } - return null; - } - }, CacheException.class, ERR_MSG); - } - }); + /** */ + public void testTxPutAllForSingleValue() throws Exception { + doTxPutAll(F.asMap(5, badValue)); } /** */ @@ -1016,6 +992,50 @@ public class IgniteSqlNotNullConstraintTest extends GridCommonAbstractTest { } /** */ + private void doAtomicOrImplicitTxPutAll(final Map<Integer, Person> values, int expAtomicCacheSize) throws Exception { + executeWithAllCaches(new TestClosure() { + @Override public void run() throws Exception { + Throwable t = GridTestUtils.assertThrowsWithCause(new Callable<Object>() { + @Override public Object call() throws Exception { + cache.putAll(values); + + return null; + } + }, IgniteSQLException.class); + + IgniteSQLException ex = X.cause(t, IgniteSQLException.class); + + assertNotNull(ex); + + assertTrue(ex.getMessage().contains(ERR_MSG)); + + assertEquals(isLocalAtomic() ? expAtomicCacheSize : 0, cache.size()); + } + }); + } + + /** */ + private void doTxPutAll(Map<Integer, Person> values) throws Exception { + executeWithAllTxCaches(new TestClosure() { + @Override public void run() throws Exception { + GridTestUtils.assertThrows(log, new Callable<Object>() { + @Override public Object call() throws Exception { + try (Transaction tx = ignite.transactions().txStart(concurrency, isolation)) { + cache.putAll(values); + + tx.commit(); + } + + assertEquals(0, cache.size()); + + return null; + } + }, CacheException.class, ERR_MSG); + } + }); + } + + /** */ private void executeWithAllCaches(TestClosure clo) throws Exception { for (CacheConfiguration ccfg : cacheConfigurations()) executeForCache(ccfg, clo, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.READ_COMMITTED);