#ignite-629: Clone on get.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/2062fecf Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/2062fecf Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/2062fecf Branch: refs/heads/ignite-gg-9950 Commit: 2062fecfa560fc474faa617f52d43af9b90fd46b Parents: 3381630 Author: ivasilinets <vasilinetc....@gmail.com> Authored: Sun Mar 29 22:43:51 2015 +0300 Committer: ivasilinets <vasilinetc....@gmail.com> Committed: Sun Mar 29 22:43:51 2015 +0300 ---------------------------------------------------------------------- .../datastructures/GridCacheAtomicReferenceImpl.java | 8 +++++++- .../datastructures/GridCacheAtomicStampedImpl.java | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2062fecf/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java index 4a4efdd..273ae35 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java @@ -18,6 +18,8 @@ package org.apache.ignite.internal.processors.datastructures; import org.apache.ignite.*; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.transactions.*; @@ -68,7 +70,11 @@ public final class GridCacheAtomicReferenceImpl<T> implements GridCacheAtomicRef /** Callable for {@link #get} operation */ private final Callable<T> getCall = new Callable<T>() { @Override public T call() throws Exception { - GridCacheAtomicReferenceValue<T> ref = atomicView.get(key); + boolean clone = ctx.cache().configuration().getCacheMode() == CacheMode.LOCAL && + ctx.cache().configuration().getAtomicityMode() == CacheAtomicityMode.ATOMIC; + + GridCacheAtomicReferenceValue<T> ref = clone ? X.cloneObject(atomicView.get(key), false, true) : + atomicView.get(key); if (ref == null) throw new IgniteCheckedException("Failed to find atomic reference with given name: " + name); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2062fecf/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicStampedImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicStampedImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicStampedImpl.java index 64f32fc..86b19af 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicStampedImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicStampedImpl.java @@ -18,6 +18,8 @@ package org.apache.ignite.internal.processors.datastructures; import org.apache.ignite.*; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.transactions.*; @@ -70,7 +72,11 @@ public final class GridCacheAtomicStampedImpl<T, S> implements GridCacheAtomicSt /** Callable for {@link #get()} operation */ private final Callable<IgniteBiTuple<T, S>> getCall = new Callable<IgniteBiTuple<T, S>>() { @Override public IgniteBiTuple<T, S> call() throws Exception { - GridCacheAtomicStampedValue<T, S> stmp = atomicView.get(key); + boolean clone = ctx.cache().configuration().getCacheMode() == CacheMode.LOCAL && + ctx.cache().configuration().getAtomicityMode() == CacheAtomicityMode.ATOMIC; + + GridCacheAtomicStampedValue<T, S> stmp = clone ? X.cloneObject(atomicView.get(key), false, true) : + atomicView.get(key); if (stmp == null) throw new IgniteCheckedException("Failed to find atomic stamped with given name: " + name);