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

tkalkirill 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 5a5c91cfc8e IGNITE-29197 Binary key deserialization masks the error 
when put follows invoke in a transaction (#13737)
5a5c91cfc8e is described below

commit 5a5c91cfc8ea41a9985e5e51724b5693a8b3dca5
Author: XianReallyHot-ZZH <[email protected]>
AuthorDate: Mon Nov 9 18:32:48 2026 +0800

    IGNITE-29197 Binary key deserialization masks the error when put follows 
invoke in a transaction (#13737)
---
 .../cache/distributed/near/GridNearTxLocal.java    |  4 +-
 .../IgniteBinaryTxPutAfterInvokeSelfTest.java      | 95 ++++++++++++++++++++++
 .../testsuites/IgniteBinaryObjectsTestSuite.java   |  5 +-
 3 files changed, 101 insertions(+), 3 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 ad3dbc70824..7394baa1376 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
@@ -1271,7 +1271,7 @@ public class GridNearTxLocal extends 
GridDhtTxLocalAdapter implements GridTimeou
                     if (!implicit && 
cctx.kernalContext().config().isCacheSanityCheckEnabled() &&
                         entry.lockedByThread(threadId, xidVer)) {
                         throw new IgniteCheckedException("Cannot access key 
within transaction if lock is " +
-                            "externally held [key=" + CU.value(cacheKey, 
cacheCtx, false) +
+                            "externally held [key=" + U.toStringSafe(cacheKey) 
+
                             ", entry=" + entry +
                             ", xidVer=" + xidVer +
                             ", threadId=" + threadId +
@@ -1506,7 +1506,7 @@ public class GridNearTxLocal extends 
GridDhtTxLocalAdapter implements GridTimeou
         else {
             if (entryProc == null && txEntry.op() == TRANSFORM)
                 throw new IgniteCheckedException("Failed to enlist write value 
for key (cannot have update value in " +
-                    "transaction after EntryProcessor is applied): " + 
CU.value(cacheKey, cacheCtx, false));
+                    "transaction after EntryProcessor is applied): " + 
U.toStringSafe(cacheKey));
 
             GridCacheEntryEx entry = txEntry.cached();
 
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/IgniteBinaryTxPutAfterInvokeSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/IgniteBinaryTxPutAfterInvokeSelfTest.java
new file mode 100644
index 00000000000..5d5bb1fe97a
--- /dev/null
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/IgniteBinaryTxPutAfterInvokeSelfTest.java
@@ -0,0 +1,95 @@
+/*
+ * 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.processors.cache.binary;
+
+import javax.cache.CacheException;
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryObjectBuilder;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.transactions.Transaction;
+import org.junit.Test;
+
+/**
+ * Tests that an error thrown on a cache update in a transaction, that follows 
an {@code EntryProcessor}
+ * invocation for the same key, is not masked by a key deserialization failure 
when the key is a binary
+ * object without a Java class.
+ */
+public class IgniteBinaryTxPutAfterInvokeSelfTest extends 
GridCommonAbstractTest {
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+
+        super.afterTest();
+    }
+
+    /**
+     * Ensures that a {@code put()} after an {@code invoke()} for a binary 
key, that has no Java class,
+     * fails with the "cannot have update value" error instead of the binary 
key deserialization error.
+     */
+    @Test
+    public void testPutAfterInvokeWithBinaryKeyWithoutJavaClass() throws 
Exception {
+        Ignite ignite = startGrid(0);
+
+        CacheConfiguration<Object, Object> ccfg = new 
CacheConfiguration<>(DEFAULT_CACHE_NAME)
+            .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
+
+        IgniteCache<Object, Object> cache = ignite.getOrCreateCache(ccfg);
+
+        BinaryObjectBuilder keyBuilder = 
ignite.binary().builder("org.apache.ignite.nonexistent.TestKeyType");
+
+        keyBuilder.setField("id", 42);
+
+        BinaryObject key = keyBuilder.build();
+
+        try (Transaction tx = ignite.transactions().txStart()) {
+            cache.withKeepBinary().invoke(key, new 
SetValueEntryProcessor<>(1));
+
+            GridTestUtils.assertThrows(log, () -> {
+                cache.withKeepBinary().put(key, 2);
+
+                return null;
+            }, CacheException.class, "cannot have update value in transaction 
after EntryProcessor is applied");
+        }
+    }
+
+    /** */
+    private static class SetValueEntryProcessor<K, V> implements 
EntryProcessor<K, V, Void> {
+        /** */
+        private final V val;
+
+        /** */
+        private SetValueEntryProcessor(V val) {
+            this.val = val;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Void process(MutableEntry<K, V> entry, Object... 
args) throws EntryProcessorException {
+            entry.setValue(val);
+
+            return null;
+        }
+    }
+}
diff --git 
a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
 
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
index bdc9230a585..2a59e7d953f 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
@@ -79,6 +79,7 @@ import 
org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryStoreBi
 import 
org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryStoreObjectsSelfTest;
 import 
org.apache.ignite.internal.processors.cache.binary.GridCacheClientNodeBinaryObjectMetadataMultinodeTest;
 import 
org.apache.ignite.internal.processors.cache.binary.GridCacheClientNodeBinaryObjectMetadataTest;
+import 
org.apache.ignite.internal.processors.cache.binary.IgniteBinaryTxPutAfterInvokeSelfTest;
 import 
org.apache.ignite.internal.processors.cache.binary.distributed.dht.GridCacheBinaryObjectsAtomicNearDisabledOnheapSelfTest;
 import 
org.apache.ignite.internal.processors.cache.binary.distributed.dht.GridCacheBinaryObjectsAtomicNearDisabledSelfTest;
 import 
org.apache.ignite.internal.processors.cache.binary.distributed.dht.GridCacheBinaryObjectsAtomicOnheapSelfTest;
@@ -186,7 +187,9 @@ import org.junit.runners.Suite;
     RawBinaryObjectExtractorTest.class,
     CrossObjectReferenceSerializationTest.class,
 
-    ThreadLocalAllocatorChunkShrinkTest.class
+    ThreadLocalAllocatorChunkShrinkTest.class,
+
+    IgniteBinaryTxPutAfterInvokeSelfTest.class,
 })
 public class IgniteBinaryObjectsTestSuite {
 }

Reply via email to