Skip to content

Commit

Permalink
IGNITE-23211 Fix AssertionError on IgniteCache#get (#11537)
Browse files Browse the repository at this point in the history
  • Loading branch information
nizhikov authored Sep 17, 2024
1 parent a24c4ed commit dfa3854
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2306,19 +2306,21 @@ private <K, V> Collection<KeyCacheObject> enlistRead(
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());
Expand Down
Original file line number Diff line number Diff line change
@@ -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"));
}

}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6695,7 +6695,7 @@ private static class PrintIteratorStateTask extends TestIgniteIdxCallable<Void>
/**
*
*/
private static class RemoveAndReturnNullEntryProcessor implements
public static class RemoveAndReturnNullEntryProcessor implements
EntryProcessor<String, Integer, Integer>, Serializable {

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
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;
Expand Down Expand Up @@ -134,6 +135,7 @@ public static List<Class<?>> suite(Collection<Class> ignoredTests) {
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);
Expand Down

0 comments on commit dfa3854

Please sign in to comment.