From 71308b18d891e707c801959f5fe92460b3bde69b Mon Sep 17 00:00:00 2001 From: Dmitriy Govorukhin Date: Fri, 16 Nov 2018 02:15:18 +0300 Subject: [PATCH 1/3] IGNITE-10290 Fix missed prepareForCache in localGet operation Signed-off-by: Dmitriy Govorukhin --- .../cache/distributed/dht/GridPartitionedGetFuture.java | 6 ++++-- .../distributed/dht/GridPartitionedSingleGetFuture.java | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) 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 2fcd6778d462a..f43c225190033 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 @@ -539,9 +539,11 @@ private boolean localGet(AffinityTopologyVersion topVer, KeyCacheObject key, int GridCacheVersion ver = null; if (readNoEntry) { + KeyCacheObject key0 = (KeyCacheObject)cctx.cacheObjects().prepareForCache(key, cctx); + CacheDataRow row = cctx.mvccEnabled() ? - cctx.offheap().mvccRead(cctx, key, mvccSnapshot()) : - cctx.offheap().read(cctx, key); + cctx.offheap().mvccRead(cctx, key0, mvccSnapshot()) : + cctx.offheap().read(cctx, key0); if (row != null) { long expireTime = row.expireTime(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java index 4d0e129d61f50..f04e1f2769843 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java @@ -399,9 +399,11 @@ private boolean localGet(AffinityTopologyVersion topVer, int part) { boolean skipEntry = readNoEntry; if (readNoEntry) { + KeyCacheObject key0 = (KeyCacheObject)cctx.cacheObjects().prepareForCache(key, cctx); + CacheDataRow row = mvccSnapshot != null ? - cctx.offheap().mvccRead(cctx, key, mvccSnapshot) : - cctx.offheap().read(cctx, key); + cctx.offheap().mvccRead(cctx, key0, mvccSnapshot) : + cctx.offheap().read(cctx, key0); if (row != null) { long expireTime = row.expireTime(); From cd6e52840080a838e3ee2930fe43fa3b829a31a4 Mon Sep 17 00:00:00 2001 From: Dmitriy Govorukhin Date: Fri, 23 Nov 2018 17:15:03 +0300 Subject: [PATCH 2/3] IGNITE-10290 fix import Signed-off-by: Dmitriy Govorukhin --- .../platform/client/cache/ClientCacheNodePartitionsRequest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheNodePartitionsRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheNodePartitionsRequest.java index 377d26fae039a..5e33860604c92 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheNodePartitionsRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheNodePartitionsRequest.java @@ -24,7 +24,6 @@ import org.apache.ignite.cache.affinity.Affinity; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.internal.managers.discovery.GridDiscoveryManager; -import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.odbc.ClientConnectableNodePartitions; import org.apache.ignite.internal.processors.odbc.ClientListenerProcessor; import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; From 5474c935c05d6f459e30d89c23285997fa70da26 Mon Sep 17 00:00:00 2001 From: Dmitriy Govorukhin Date: Sat, 5 Jan 2019 14:01:02 +0300 Subject: [PATCH 3/3] IGNITE-10290 add test Signed-off-by: Dmitriy Govorukhin --- .../cache/CacheLocalGetSerializationTest.java | 68 +++++++++++++++++++ .../testsuites/IgniteBasicTestSuite.java | 3 + 2 files changed, 71 insertions(+) create mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheLocalGetSerializationTest.java diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheLocalGetSerializationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheLocalGetSerializationTest.java new file mode 100644 index 0000000000000..bfcc41345574b --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheLocalGetSerializationTest.java @@ -0,0 +1,68 @@ +/* + * 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; + +import java.util.Map; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * + */ +@RunWith(JUnit4.class) +public class CacheLocalGetSerializationTest extends GridCommonAbstractTest { + /** + * Check correct Map.Entry serialization key on local get/put operation. + * https://issues.apache.org/jira/browse/IGNITE-10290 + * + * @throws Exception If failed. + */ + @Test + public void test() throws Exception { + Ignite ig = startGrid(); + + IgniteCache, Long> cache = ig.getOrCreateCache(DEFAULT_CACHE_NAME); + + // Try use Map.Entry as key in destributed map. + Map.Entry key = new Map.Entry() { + @Override public Integer getKey() { + return 123; + } + + @Override public Integer getValue() { + return 123; + } + + @Override public Integer setValue(Integer value) { + throw new UnsupportedOperationException(); + } + }; + + cache.put(key, Long.MAX_VALUE); + + Long val = cache.get(key); + + Assert.assertNotNull(val); + Assert.assertEquals(Long.MAX_VALUE, (long)val); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java index 276dbc5e6b801..369a0b5288ba6 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java @@ -47,6 +47,7 @@ import org.apache.ignite.internal.managers.IgniteDiagnosticMessagesTest; import org.apache.ignite.internal.processors.affinity.GridAffinityProcessorMemoryLeakTest; import org.apache.ignite.internal.processors.affinity.GridAffinityProcessorRendezvousSelfTest; +import org.apache.ignite.internal.processors.cache.CacheLocalGetSerializationTest; import org.apache.ignite.internal.processors.cache.CacheRebalanceConfigValidationTest; import org.apache.ignite.internal.processors.cache.GridLocalIgniteSerializationTest; import org.apache.ignite.internal.processors.cache.GridProjectionForCachesOnDaemonNodeSelfTest; @@ -219,6 +220,8 @@ public static TestSuite suite(@Nullable final Set ignoredTests) { suite.addTest(new JUnit4TestAdapter(ListeningTestLoggerTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheLocalGetSerializationTest.class)); + return suite; } }