This is an automated email from the ASF dual-hosted git repository.

nizhikov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new dfa38542a98 IGNITE-23211 Fix AssertionError on IgniteCache#get (#11537)
dfa38542a98 is described below

commit dfa38542a98ed189282c7c4bcd9b05b66ee44bb5
Author: Nikolay <[email protected]>
AuthorDate: Tue Sep 17 16:05:52 2024 +0300

    IGNITE-23211 Fix AssertionError on IgniteCache#get (#11537)
---
 .../cache/distributed/near/GridNearTxLocal.java    | 28 ++++++------
 .../RemoveEntryProcessorTransactionTest.java       | 53 ++++++++++++++++++++++
 .../cache/GridCacheAbstractFullApiSelfTest.java    |  2 +-
 .../ignite/testsuites/IgniteCacheTestSuite.java    |  2 +
 4 files changed, 71 insertions(+), 14 deletions(-)

diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
index a3205a8a5a0..6798c08fc9e 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
@@ -2306,19 +2306,21 @@ public class GridNearTxLocal extends 
GridDhtTxLocalAdapter implements GridTimeou
                                     if (!F.isEmpty(txEntry.entryProcessors()))
                                         val = 
txEntry.applyEntryProcessors(val);
 
-                                    cacheCtx.addResult(map,
-                                        key,
-                                        val,
-                                        skipVals,
-                                        keepCacheObjects,
-                                        deserializeBinary,
-                                        false,
-                                        getRes,
-                                        readVer,
-                                        0,
-                                        0,
-                                        needVer,
-                                        
U.deploymentClassLoader(cctx.kernalContext(), deploymentLdrId));
+                                    if (val != null) {
+                                        cacheCtx.addResult(map,
+                                            key,
+                                            val,
+                                            skipVals,
+                                            keepCacheObjects,
+                                            deserializeBinary,
+                                            false,
+                                            getRes,
+                                            readVer,
+                                            0,
+                                            0,
+                                            needVer,
+                                            
U.deploymentClassLoader(cctx.kernalContext(), deploymentLdrId));
+                                    }
                                 }
                                 else
                                     missed.put(key, 
txEntry.cached().version());
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/RemoveEntryProcessorTransactionTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/RemoveEntryProcessorTransactionTest.java
new file mode 100644
index 00000000000..1b3ebfb1485
--- /dev/null
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/RemoveEntryProcessorTransactionTest.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal;
+
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import 
org.apache.ignite.internal.processors.cache.GridCacheAbstractFullApiSelfTest.RemoveAndReturnNullEntryProcessor;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+import org.junit.Test;
+
+/** */
+public class RemoveEntryProcessorTransactionTest extends 
GridCommonAbstractTest {
+    /** */
+    @Test
+    public void testDelete() throws Exception {
+        var c = startGrid(0).createCache(new CacheConfiguration<String, 
Integer>()
+            .setName(DEFAULT_CACHE_NAME)
+            .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)
+        );
+
+        for (TransactionConcurrency txConcurrency : 
TransactionConcurrency.values()) {
+            for (TransactionIsolation txIsolation : 
TransactionIsolation.values()) {
+                c.put("key", 1);
+
+                try (Transaction tx = 
grid(0).transactions().txStart(txConcurrency, txIsolation)) {
+                    c.invoke("key", new RemoveAndReturnNullEntryProcessor());
+
+                    assertNull(c.get("key"));
+                }
+
+            }
+        }
+
+    }
+}
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 0218587cd9e..8ae56fc07a4 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
@@ -6695,7 +6695,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
     /**
      *
      */
-    private static class RemoveAndReturnNullEntryProcessor implements
+    public static class RemoveAndReturnNullEntryProcessor implements
         EntryProcessor<String, Integer, Integer>, Serializable {
 
         /** {@inheritDoc} */
diff --git 
a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
 
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
index 868c442d5ed..e5c3c6b44a9 100755
--- 
a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@ -37,6 +37,7 @@ import 
org.apache.ignite.cache.store.jdbc.CacheJdbcPojoWriteBehindStoreWithCoale
 import 
org.apache.ignite.cache.store.jdbc.GridCacheJdbcBlobStoreMultithreadedSelfTest;
 import org.apache.ignite.cache.store.jdbc.GridCacheJdbcBlobStoreSelfTest;
 import org.apache.ignite.cache.store.jdbc.JdbcTypesDefaultTransformerTest;
+import org.apache.ignite.internal.RemoveEntryProcessorTransactionTest;
 import org.apache.ignite.internal.processors.cache.CacheAffinityCallSelfTest;
 import 
org.apache.ignite.internal.processors.cache.CacheAffinityKeyConfigurationMismatchTest;
 import 
org.apache.ignite.internal.processors.cache.CacheEntryProcessorCopySelfTest;
@@ -134,6 +135,7 @@ public class IgniteCacheTestSuite {
         GridTestUtils.addTestIfNeeded(suite, 
CacheEntryProcessorNonSerializableTest.class, ignoredTests);
         GridTestUtils.addTestIfNeeded(suite, 
CacheEntryProcessorExternalizableFailedTest.class, ignoredTests);
         GridTestUtils.addTestIfNeeded(suite, 
IgniteCacheEntryProcessorCallTest.class, ignoredTests);
+        GridTestUtils.addTestIfNeeded(suite, 
RemoveEntryProcessorTransactionTest.class, ignoredTests);
         GridTestUtils.addTestIfNeeded(suite, 
IgniteCacheTxNearEnabledInvokeTest.class, ignoredTests);
         GridTestUtils.addTestIfNeeded(suite, 
IgniteCrossCacheTxStoreSelfTest.class, ignoredTests);
         GridTestUtils.addTestIfNeeded(suite, 
IgniteCacheEntryProcessorSequentialCallTest.class, ignoredTests);

Reply via email to