IGNITE-51 Fix review notes.

Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/b3be8e57
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/b3be8e57
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/b3be8e57

Branch: refs/heads/ignite-user-req
Commit: b3be8e57be18bf6775b88519b632706a40c1c352
Parents: e77688c
Author: nikolay_tikhonov <ntikho...@gridgain.com>
Authored: Thu Mar 5 14:32:20 2015 +0300
Committer: nikolay_tikhonov <ntikho...@gridgain.com>
Committed: Thu Mar 5 14:32:20 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/CacheInvokeEntry.java      | 26 +++++++++
 .../processors/cache/CacheLazyEntry.java        | 33 +++++++++++
 .../processors/cache/GridCacheMapEntry.java     | 61 +++++++++++++++-----
 .../dht/atomic/GridDhtAtomicCache.java          | 13 +++--
 .../local/atomic/GridLocalAtomicCache.java      | 24 ++++----
 .../cache/transactions/IgniteTxAdapter.java     |  9 ++-
 .../cache/transactions/IgniteTxEntry.java       |  7 ++-
 .../transactions/IgniteTxLocalAdapter.java      | 12 ++--
 .../GridCacheOnCopyFlagAbstractSelfTest.java    | 16 ++++-
 9 files changed, 158 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b3be8e57/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java
index b9e89d6..a49a67e 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java
@@ -31,6 +31,9 @@ public class CacheInvokeEntry<K, V> extends CacheLazyEntry<K, 
V> implements Muta
     /** */
     private Operation op = Operation.NONE;
 
+    /** */
+    private V originVal;
+
     /**
      * @param cctx Cache context.
      * @param keyObj Key cache object.
@@ -42,6 +45,20 @@ public class CacheInvokeEntry<K, V> extends 
CacheLazyEntry<K, V> implements Muta
         this.hadVal = valObj != null;
     }
 
+    /** 
+     * @param ctx Cache context.
+     * @param keyObject Key cache object.
+     * @param key Key value.
+     * @param valObj Value cache object.
+     * @param val Value.
+     */
+    public CacheInvokeEntry(GridCacheContext<K, V> ctx, KeyCacheObject 
keyObject, K key, CacheObject valObj,
+        V val) {
+        super(ctx, keyObject, key, valObj, val);
+
+        this.hadVal = valObj != null || val != null;
+    }
+
     /** {@inheritDoc} */
     @Override public boolean exists() {
         return val != null || valObj != null;
@@ -63,12 +80,21 @@ public class CacheInvokeEntry<K, V> extends 
CacheLazyEntry<K, V> implements Muta
         if (val == null)
             throw new NullPointerException();
 
+        this.originVal = val;
+
         this.val = val;
 
         op = hadVal ? Operation.UPDATE : Operation.CREATE;
     }
 
     /**
+     * @return Return origin value, before modification.
+     */
+    public V originVal() {
+        return originVal == null ? val : originVal;
+    }
+
+    /**
      * @return {@code True} if {@link #setValue} or {@link #remove was called}.
      */
     public boolean modified() {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b3be8e57/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java
index 07f38cb..34a6001 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java
@@ -66,6 +66,25 @@ public class CacheLazyEntry<K, V> implements Cache.Entry<K, 
V> {
         this.cctx = cctx;
     }
 
+    /**
+     * @param ctx Cache context.
+     * @param keyObject Key cache object.
+     * @param key Key value.
+     * @param valObj Cache object
+     * @param val Cache value.
+     */
+    public CacheLazyEntry(GridCacheContext<K, V> ctx, 
+        KeyCacheObject keyObject, 
+        K key, 
+        CacheObject valObj, 
+        V val) {
+        this.cctx = ctx;
+        this.keyObj = keyObject;
+        this.key = key;
+        this.valObj = valObj;
+        this.val = val;
+    }
+
     /** {@inheritDoc} */
     @Override public K getKey() {
         if (key == null)
@@ -82,6 +101,20 @@ public class CacheLazyEntry<K, V> implements Cache.Entry<K, 
V> {
         return val;
     }
 
+    /**
+     * @return Return value. This methods doesn't initialize value.
+     */
+    public V val() {
+        return val;
+    }
+
+    /**
+     * @return Return key. This methods doesn't initialize key.
+     */
+    public K key() {
+        return key;
+    }
+
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     @Override public <T> T unwrap(Class<T> cls) {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b3be8e57/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index 063abe0..9c118cd 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@ -966,7 +966,8 @@ public abstract class GridCacheMapEntry implements 
GridCacheEntryEx {
 
         boolean intercept = cctx.config().getInterceptor() != null;
 
-        Object val0;
+        Object val0 = null;
+        Object keyVal = null;
 
         synchronized (this) {
             checkObsolete();
@@ -995,9 +996,13 @@ public abstract class GridCacheMapEntry implements 
GridCacheEntryEx {
             if (intercept) {
                 val0 = CU.value(val, cctx, true);
 
+                CacheLazyEntry e = new CacheLazyEntry(cctx, key, old);
+
                 Object interceptorVal = 
cctx.config().getInterceptor().onBeforePut(new CacheLazyEntry(cctx, key, old),
                     val0);
 
+                keyVal = e.key();
+
                 if (interceptorVal == null)
                     return new GridCacheUpdateTxResult(false, 
(CacheObject)cctx.unwrapTemporary(old));
                 else if (interceptorVal != val0)
@@ -1078,7 +1083,7 @@ public abstract class GridCacheMapEntry implements 
GridCacheEntryEx {
             cctx.store().putToStore(tx, key, val, newVer);
 
         if (intercept)
-            cctx.config().getInterceptor().onAfterPut(new CacheLazyEntry(cctx, 
key, val));
+            cctx.config().getInterceptor().onAfterPut(new CacheLazyEntry(cctx, 
key, keyVal, val, val0));
 
         return valid ? new GridCacheUpdateTxResult(true, retval ? old : null) :
             new GridCacheUpdateTxResult(false, null);
@@ -1370,6 +1375,7 @@ public abstract class GridCacheMapEntry implements 
GridCacheEntryEx {
 
             CacheObject updated;
 
+            Object key0 = null;
             Object updated0 = null;
 
             // Calculate new value.
@@ -1389,10 +1395,17 @@ public abstract class GridCacheMapEntry implements 
GridCacheEntryEx {
                         updated0 = cctx.unwrapTemporary(entry.getValue());
 
                         updated = cctx.toCacheObject(updated0);
+
+                        old0 = entry.originVal();
                     }
-                    else
+                    else {
                         updated = old;
 
+                        old0 = entry.val();
+                    }
+
+                    key0 = entry.key();
+
                     invokeRes = computed != null ? new 
CacheInvokeResult<>(cctx.unwrapTemporary(computed)) : null;
                 }
                 catch (Exception e) {
@@ -1414,15 +1427,17 @@ public abstract class GridCacheMapEntry implements 
GridCacheEntryEx {
             op = updated == null ? GridCacheOperation.DELETE : 
GridCacheOperation.UPDATE;
 
             if (intercept) {
+                CacheLazyEntry e;
+
                 if (op == GridCacheOperation.UPDATE) {
                     updated0 = value(updated0, updated, false);
-                    old0 = value(old0, old, false);
 
-                    Object interceptorVal = cctx.config().getInterceptor()
-                        .onBeforePut(new CacheLazyEntry(cctx, key, old), 
updated0);
+                    e = new CacheLazyEntry(cctx, key, key0, old, old0);
+
+                    Object interceptorVal = 
cctx.config().getInterceptor().onBeforePut(e, updated0);
 
                     if (interceptorVal == null)
-                        return new GridTuple3<>(false, 
cctx.unwrapTemporary(old0), invokeRes);
+                        return new GridTuple3<>(false, 
cctx.unwrapTemporary(value(old0, old, false)), invokeRes);
                     else {
                         updated0 = cctx.unwrapTemporary(interceptorVal);
 
@@ -1430,12 +1445,16 @@ public abstract class GridCacheMapEntry implements 
GridCacheEntryEx {
                     }
                 }
                 else {
-                    interceptorRes = cctx.config().getInterceptor()
-                        .onBeforeRemove(new CacheLazyEntry(cctx, key, old));
+                    e = new CacheLazyEntry(cctx, key, key0, old, old0);
+
+                    interceptorRes = 
cctx.config().getInterceptor().onBeforeRemove(e);
 
                     if (cctx.cancelRemove(interceptorRes))
                         return new GridTuple3<>(false, 
cctx.unwrapTemporary(interceptorRes.get2()), invokeRes);
                 }
+
+                key0 = e.key();
+                old0 = e.val();
             }
 
             boolean hadVal = hasValueUnlocked();
@@ -1550,9 +1569,9 @@ public abstract class GridCacheMapEntry implements 
GridCacheEntryEx {
 
             if (intercept) {
                 if (op == GridCacheOperation.UPDATE)
-                    cctx.config().getInterceptor().onAfterPut(new 
CacheLazyEntry(cctx, key, updated));
+                    cctx.config().getInterceptor().onAfterPut(new 
CacheLazyEntry(cctx, key, key0, updated, updated0));
                 else
-                    cctx.config().getInterceptor().onAfterRemove(new 
CacheLazyEntry(cctx, key, old));
+                    cctx.config().getInterceptor().onAfterRemove(new 
CacheLazyEntry(cctx, key, key0, old, old0));
             }
         }
 
@@ -1818,6 +1837,8 @@ public abstract class GridCacheMapEntry implements 
GridCacheEntryEx {
                 }
             }
 
+            Object key0 = null;
+
             // Calculate new value in case we met transform.
             if (op == GridCacheOperation.TRANSFORM) {
                 assert conflictCtx == null : "Cannot be TRANSFORM here if 
conflict resolution was performed earlier.";
@@ -1834,10 +1855,17 @@ public abstract class GridCacheMapEntry implements 
GridCacheEntryEx {
                     if (entry.modified()) {
                         updated0 = cctx.unwrapTemporary(entry.getValue());
                         updated = cctx.toCacheObject(updated0);
+
+                        old0 = entry.originVal();
                     }
-                    else
+                    else {
                         updated = oldVal;
 
+                        old0 = entry.val();
+                    }
+
+                    key0 = entry.key();
+
                     if (computed != null)
                         invokeRes = new CacheInvokeDirectResult(key,
                             
cctx.toCacheObject(cctx.unwrapTemporary(computed)));
@@ -1950,7 +1978,7 @@ public abstract class GridCacheMapEntry implements 
GridCacheEntryEx {
                     updated0 = value(updated0, updated, false);
 
                     Object interceptorVal = cctx.config().getInterceptor()
-                        .onBeforePut(new CacheLazyEntry(cctx, key, oldVal), 
updated0);
+                        .onBeforePut(new CacheLazyEntry(cctx, key, key0, 
oldVal, old0), updated0);
 
                     if (interceptorVal == null)
                         return new GridCacheUpdateAtomicResult(false,
@@ -2025,7 +2053,8 @@ public abstract class GridCacheMapEntry implements 
GridCacheEntryEx {
             }
             else {
                 if (intercept) {
-                    interceptRes = 
cctx.config().getInterceptor().onBeforeRemove(new CacheLazyEntry(cctx, key, 
oldVal));
+                    interceptRes = 
cctx.config().getInterceptor().onBeforeRemove(new CacheLazyEntry(cctx, key, 
key0, 
+                        oldVal, old0));
 
                     if (cctx.cancelRemove(interceptRes))
                         return new GridCacheUpdateAtomicResult(false,
@@ -2121,9 +2150,9 @@ public abstract class GridCacheMapEntry implements 
GridCacheEntryEx {
 
             if (intercept) {
                 if (op == GridCacheOperation.UPDATE)
-                    cctx.config().getInterceptor().onAfterPut(new 
CacheLazyEntry(cctx, key, updated));
+                    cctx.config().getInterceptor().onAfterPut(new 
CacheLazyEntry(cctx, key, key0, updated, updated0));
                 else
-                    cctx.config().getInterceptor().onAfterRemove(new 
CacheLazyEntry(cctx, key, oldVal));
+                    cctx.config().getInterceptor().onAfterRemove(new 
CacheLazyEntry(cctx, key, key0, oldVal, old0));
 
                 if (interceptRes != null)
                     oldVal = 
cctx.toCacheObject(cctx.unwrapTemporary(interceptRes.get2()));

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b3be8e57/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index 4fd583a..9c627ec 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -1323,6 +1323,7 @@ public class GridDhtAtomicCache<K, V> extends 
GridDhtCacheAdapter<K, V> {
                         taskName,
                         null);
 
+                    Object oldVal = null;
                     Object updatedVal = null;
 
                     CacheInvokeEntry<Object, Object> invokeEntry = new 
CacheInvokeEntry(ctx, entry.key(), old);
@@ -1341,7 +1342,7 @@ public class GridDhtAtomicCache<K, V> extends 
GridDhtCacheAdapter<K, V> {
                         else {
                             updated = old;
 
-                            updatedVal = CU.value(old, ctx, true);
+                            oldVal = updatedVal = CU.value(old, ctx, false);
                         }
 
                         if (computed != null)
@@ -1359,8 +1360,9 @@ public class GridDhtAtomicCache<K, V> extends 
GridDhtCacheAdapter<K, V> {
 
                     if (updated == null) {
                         if (intercept) {
-                            IgniteBiTuple<Boolean, ?> interceptorRes = 
ctx.config().getInterceptor().onBeforeRemove(
-                                new CacheLazyEntry(ctx, entry.key(), old));
+                            CacheLazyEntry e = new CacheLazyEntry(ctx, 
entry.key(), invokeEntry.key(), old, oldVal);
+
+                            IgniteBiTuple<Boolean, ?> interceptorRes = 
ctx.config().getInterceptor().onBeforeRemove(e);
 
                             if (ctx.cancelRemove(interceptorRes))
                                 continue;
@@ -1402,8 +1404,9 @@ public class GridDhtAtomicCache<K, V> extends 
GridDhtCacheAdapter<K, V> {
                     }
                     else {
                         if (intercept) {
-                            Object val = ctx.config().getInterceptor()
-                                .onBeforePut(new CacheLazyEntry(ctx, 
entry.key(), old), updatedVal);
+                            CacheLazyEntry e = new CacheLazyEntry(ctx, 
entry.key(), invokeEntry.key(), old, oldVal);
+
+                            Object val = 
ctx.config().getInterceptor().onBeforePut(e, updatedVal);
 
                             if (val == null)
                                 continue;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b3be8e57/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
index bb498e0..0d47f63 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
@@ -33,7 +33,6 @@ import org.apache.ignite.plugin.security.*;
 import org.apache.ignite.transactions.*;
 import org.jetbrains.annotations.*;
 
-import javax.cache.*;
 import javax.cache.expiry.*;
 import javax.cache.processor.*;
 import java.io.*;
@@ -1135,8 +1134,7 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
                             taskName,
                             null);
 
-                        Object keyVal = 
entry.key().value(ctx.cacheObjectContext(), false);
-                        Object oldVal = CU.value(old, ctx, false);
+                        Object oldVal = null;
 
                         CacheInvokeEntry<Object, Object> invokeEntry = new 
CacheInvokeEntry<>(ctx, entry.key(), old);
 
@@ -1148,14 +1146,16 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
                             Object computed = 
entryProcessor.process(invokeEntry, invokeArgs);
 
                             if (invokeEntry.modified()) {
-                                updatedVal = 
ctx.unwrapTemporary(invokeEntry.getValue());
-
                                 updated = ctx.toCacheObject(updatedVal);
+
+                                oldVal = invokeEntry.originVal();
+
+                                updatedVal = 
ctx.unwrapTemporary(invokeEntry.getValue());
                             }
                             else {
-                                updatedVal = oldVal;
-
                                 updated = old;
+
+                                updatedVal = oldVal = CU.value(old, ctx, 
false);
                             }
 
                             if (computed != null)
@@ -1168,12 +1168,13 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
                         }
 
                         if (invokeRes != null)
-                            invokeResMap.put((K)keyVal, invokeRes);
+                            
invokeResMap.put((K)entry.key().value(ctx.cacheObjectContext(), false), 
invokeRes);
 
                         if (updated == null) {
                             if (intercept) {
                                 IgniteBiTuple<Boolean, ?> interceptorRes = 
ctx.config().getInterceptor()
-                                    .onBeforeRemove(new CacheEntryImpl(keyVal, 
oldVal));
+                                    .onBeforeRemove(new CacheLazyEntry(ctx, 
entry.key(), invokeEntry.key(), 
+                                        old, oldVal));
 
                                 if (ctx.cancelRemove(interceptorRes))
                                     continue;
@@ -1205,7 +1206,8 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
                         else {
                             if (intercept) {
                                 Object interceptorVal = 
ctx.config().getInterceptor()
-                                    .onBeforePut(new CacheLazyEntry(ctx, 
entry.key(), old), updatedVal);
+                                        .onBeforePut(new CacheLazyEntry(ctx, 
entry.key(), invokeEntry.getKey(),
+                                                old, oldVal), updatedVal);
 
                                 if (interceptorVal == null)
                                     continue;
@@ -1285,7 +1287,7 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
                                 null);
 
                             IgniteBiTuple<Boolean, ?> interceptorRes = 
ctx.config().getInterceptor()
-                                .onBeforeRemove(new CacheLazyEntry(ctx, 
entry.key(), old));
+                                    .onBeforeRemove(new CacheLazyEntry(ctx, 
entry.key(), old));
 
                             if (ctx.cancelRemove(interceptorRes))
                                 continue;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b3be8e57/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
index ed47505..ada429b 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
@@ -1225,11 +1225,12 @@ public abstract class IgniteTxAdapter extends 
GridMetadataAwareAdapter
 
                 boolean modified = false;
 
-                Object val = CU.value(cacheVal, txEntry.context(), false);
+                Object val = null;
+                Object key = null;
 
                 for (T2<EntryProcessor<Object, Object, Object>, Object[]> t : 
txEntry.entryProcessors()) {
-                    CacheInvokeEntry<Object, Object> invokeEntry = new 
CacheInvokeEntry<>(txEntry.context(), 
-                        txEntry.key(), cacheVal);
+                    CacheInvokeEntry<Object, Object> invokeEntry = new 
CacheInvokeEntry(txEntry.context(),
+                        txEntry.key(), key, cacheVal, val);
 
                     try {
                         EntryProcessor<Object, Object, Object> processor = 
t.get1();
@@ -1237,6 +1238,8 @@ public abstract class IgniteTxAdapter extends 
GridMetadataAwareAdapter
                         processor.process(invokeEntry, t.get2());
 
                         val = invokeEntry.getValue();
+
+                        key = invokeEntry.key();
                     }
                     catch (Exception ignore) {
                         // No-op.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b3be8e57/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
index 1b806f7..95d3527 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
@@ -556,17 +556,20 @@ public class IgniteTxEntry implements 
GridPeerDeployAware, Message {
      */
     @SuppressWarnings("unchecked")
     public CacheObject applyEntryProcessors(CacheObject cacheVal) {
-        Object val = CU.value(cacheVal, ctx, false);
+        Object val = null;
+        Object keyVal = null;
 
         for (T2<EntryProcessor<Object, Object, Object>, Object[]> t : 
entryProcessors()) {
             try {
-                CacheInvokeEntry<Object, Object> invokeEntry = new 
CacheInvokeEntry<>(ctx, key, cacheVal);
+                CacheInvokeEntry<Object, Object> invokeEntry = new 
CacheInvokeEntry(ctx, key, keyVal, cacheVal, val);
 
                 EntryProcessor processor = t.get1();
 
                 processor.process(invokeEntry, t.get2());
 
                 val = invokeEntry.getValue();
+
+                keyVal = invokeEntry.key();
             }
             catch (Exception ignore) {
                 // No-op.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b3be8e57/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
index 34e4943..92851cb 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
@@ -537,9 +537,8 @@ public abstract class IgniteTxLocalAdapter extends 
IgniteTxAdapter
 
                             if (intercept) {
                                 Object interceptorVal = 
cacheCtx.config().getInterceptor()
-                                    .onBeforePut(new CacheLazyEntry(
-                                                    cacheCtx, key, 
e.cached().rawGetOrUnmarshal(true)),
-                                            CU.value(val, cacheCtx, false));
+                                    .onBeforePut(new CacheLazyEntry(cacheCtx, 
key, e.cached().rawGetOrUnmarshal(true)),
+                                        CU.value(val, cacheCtx, false));
 
                                 if (interceptorVal == null)
                                     continue;
@@ -2463,18 +2462,21 @@ public abstract class IgniteTxLocalAdapter extends 
IgniteTxAdapter
     private void addInvokeResult(IgniteTxEntry txEntry, CacheObject cacheVal, 
GridCacheReturn<?> ret) {
         GridCacheContext ctx = txEntry.context();
 
-        Object keyVal = txEntry.key().value(ctx.cacheObjectContext(), false);
+        Object keyVal = txEntry.key().value(ctx.cacheObjectContext(), true);
+        Object val = null;
 
         try {
             Object res = null;
 
             for (T2<EntryProcessor<Object, Object, Object>, Object[]> t : 
txEntry.entryProcessors()) {
                 CacheInvokeEntry<Object, Object> invokeEntry =
-                    new CacheInvokeEntry<>(txEntry.context(), txEntry.key(), 
cacheVal);
+                    new CacheInvokeEntry(txEntry.context(), txEntry.key(), 
keyVal, cacheVal, val);
 
                 EntryProcessor<Object, Object, ?> entryProcessor = t.get1();
 
                 res = entryProcessor.process(invokeEntry, t.get2());
+
+                val = invokeEntry.val();
             }
 
             if (res != null)

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b3be8e57/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOnCopyFlagAbstractSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOnCopyFlagAbstractSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOnCopyFlagAbstractSelfTest.java
index 750a3aa..5f0b325 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOnCopyFlagAbstractSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOnCopyFlagAbstractSelfTest.java
@@ -364,6 +364,21 @@ public abstract class GridCacheOnCopyFlagAbstractSelfTest 
extends GridCacheAbstr
     }
 
     /**
+     * @throws Exception If failed.
+     */
+    public void testPutGet() throws Exception {
+        IgniteCache<TestKey, TestValue> cache = grid(0).jcache(null);
+
+        Map<Integer, TestValue> maps = new HashMap<>();
+        
+        for (int i = 0; i < ITER_CNT; i++) 
+            cache.put(new TestKey(i, i), new TestValue(i));
+
+        for (Cache.Entry<Object, Object> entry : internalCache(0, 
null).entrySet())
+            assertNotSame(entry.getValue(), 
maps.get(((TestKey)entry.getKey()).key()));
+    }
+
+    /**
      *
      */
     public static class TestKey implements Externalizable {
@@ -442,7 +457,6 @@ public abstract class GridCacheOnCopyFlagAbstractSelfTest 
extends GridCacheAbstr
         }
     }
 
-
     /**
      *
      */

Reply via email to