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

shishkovilja 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 f345d77f599 IGNITE-26509 Use MessageSerializer for 
GridDistributedLockRequest (#12372)
f345d77f599 is described below

commit f345d77f5993b691e83760b86f68506ea735b6f8
Author: Dmitry Werner <[email protected]>
AuthorDate: Fri Oct 10 14:01:12 2025 +0500

    IGNITE-26509 Use MessageSerializer for GridDistributedLockRequest (#12372)
---
 .../internal/MessageSerializerGenerator.java       |  16 +
 .../communication/GridIoMessageFactory.java        |  14 +-
 .../communication/TransactionIsolationMessage.java | 117 +++++++
 .../distributed/GridDistributedLockRequest.java    | 361 +++++++--------------
 .../cache/distributed/dht/GridDhtLockRequest.java  | 279 ++++++----------
 .../dht/GridDhtTransactionalCacheAdapter.java      |   4 +-
 .../distributed/near/GridNearLockRequest.java      | 209 ++++--------
 .../internal/codegen/MessageProcessorTest.java     |  10 +
 .../TransactionIsolationMessageTest.java           |  79 +++++
 .../ignite/testsuites/IgniteBasicTestSuite.java    |   2 +
 .../codegen/UnwrappedEnumFieldMessage.java         |  38 +++
 11 files changed, 563 insertions(+), 566 deletions(-)

diff --git 
a/modules/codegen2/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java
 
b/modules/codegen2/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java
index ae05a19e5e6..d052aeb1dda 100644
--- 
a/modules/codegen2/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java
+++ 
b/modules/codegen2/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java
@@ -36,6 +36,7 @@ import java.util.UUID;
 import javax.annotation.processing.FilerException;
 import javax.annotation.processing.ProcessingEnvironment;
 import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
 import javax.lang.model.element.QualifiedNameable;
 import javax.lang.model.element.TypeElement;
 import javax.lang.model.element.VariableElement;
@@ -242,6 +243,10 @@ class MessageSerializerGenerator {
         if (assignableFrom(field.asType(), type(Throwable.class.getName())))
             throw new UnsupportedOperationException("You should use 
ErrorMessage for serialization of throwables.");
 
+        if (enumType(erasedType(field.asType())))
+            throw new IllegalArgumentException("Unsupported enum type: " + 
field.asType() +
+                    ". The enum must be wrapped into a Message (see, for 
example, TransactionIsolationMessage).");
+
         writeField(field, opt);
         readField(field, opt);
     }
@@ -717,6 +722,17 @@ class MessageSerializerGenerator {
         return env.getTypeUtils().isAssignable(type, superType);
     }
 
+    /** */
+    private boolean enumType(TypeMirror type) {
+        if (type.getKind() == TypeKind.DECLARED) {
+            Element element = env.getTypeUtils().asElement(type);
+
+            return element != null && element.getKind() == ElementKind.ENUM;
+        }
+
+        return false;
+    }
+
     /** */
     private TypeMirror type(String clazz) {
         Elements elementUtils = env.getElementUtils();
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
index 5ed2af4b441..a410d8ebb58 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
@@ -46,6 +46,7 @@ import 
org.apache.ignite.internal.codegen.GridDeploymentResponseSerializer;
 import 
org.apache.ignite.internal.codegen.GridDhtAffinityAssignmentRequestSerializer;
 import org.apache.ignite.internal.codegen.GridDhtAtomicNearResponseSerializer;
 import org.apache.ignite.internal.codegen.GridDhtForceKeysRequestSerializer;
+import org.apache.ignite.internal.codegen.GridDhtLockRequestSerializer;
 import org.apache.ignite.internal.codegen.GridDhtLockResponseSerializer;
 import 
org.apache.ignite.internal.codegen.GridDhtPartitionDemandMessageSerializer;
 import org.apache.ignite.internal.codegen.GridDhtPartitionExchangeIdSerializer;
@@ -54,6 +55,7 @@ import 
org.apache.ignite.internal.codegen.GridDhtPartitionsSingleRequestSerializ
 import 
org.apache.ignite.internal.codegen.GridDhtTxOnePhaseCommitAckRequestSerializer;
 import org.apache.ignite.internal.codegen.GridDhtTxPrepareRequestSerializer;
 import org.apache.ignite.internal.codegen.GridDhtUnlockRequestSerializer;
+import org.apache.ignite.internal.codegen.GridDistributedLockRequestSerializer;
 import 
org.apache.ignite.internal.codegen.GridDistributedLockResponseSerializer;
 import 
org.apache.ignite.internal.codegen.GridDistributedTxFinishResponseSerializer;
 import 
org.apache.ignite.internal.codegen.GridDistributedTxPrepareRequestSerializer;
@@ -62,6 +64,7 @@ import 
org.apache.ignite.internal.codegen.GridJobSiblingsRequestSerializer;
 import 
org.apache.ignite.internal.codegen.GridNearAtomicCheckUpdateRequestSerializer;
 import 
org.apache.ignite.internal.codegen.GridNearAtomicUpdateResponseSerializer;
 import org.apache.ignite.internal.codegen.GridNearGetRequestSerializer;
+import org.apache.ignite.internal.codegen.GridNearLockRequestSerializer;
 import org.apache.ignite.internal.codegen.GridNearLockResponseSerializer;
 import org.apache.ignite.internal.codegen.GridNearSingleGetRequestSerializer;
 import org.apache.ignite.internal.codegen.GridNearTxPrepareRequestSerializer;
@@ -90,6 +93,7 @@ import 
org.apache.ignite.internal.codegen.SnapshotFilesFailureMessageSerializer;
 import 
org.apache.ignite.internal.codegen.SnapshotFilesRequestMessageSerializer;
 import 
org.apache.ignite.internal.codegen.TcpInverseConnectionResponseMessageSerializer;
 import 
org.apache.ignite.internal.codegen.TransactionAttributesAwareRequestSerializer;
+import 
org.apache.ignite.internal.codegen.TransactionIsolationMessageSerializer;
 import org.apache.ignite.internal.codegen.TxLockSerializer;
 import org.apache.ignite.internal.codegen.TxLocksRequestSerializer;
 import org.apache.ignite.internal.codegen.TxLocksResponseSerializer;
@@ -277,7 +281,7 @@ public class GridIoMessageFactory implements 
MessageFactoryProvider {
         factory.register((short)16, GridCacheTxRecoveryRequest::new, new 
GridCacheTxRecoveryRequestSerializer());
         factory.register((short)17, GridCacheTxRecoveryResponse::new, new 
GridCacheTxRecoveryResponseSerializer());
         factory.register((short)20, GridCacheTtlUpdateRequest::new, new 
GridCacheTtlUpdateRequestSerializer());
-        factory.register((short)21, GridDistributedLockRequest::new);
+        factory.register((short)21, GridDistributedLockRequest::new, new 
GridDistributedLockRequestSerializer());
         factory.register((short)22, GridDistributedLockResponse::new, new 
GridDistributedLockResponseSerializer());
         factory.register((short)23, GridDistributedTxFinishRequest::new);
         factory.register((short)24, GridDistributedTxFinishResponse::new, new 
GridDistributedTxFinishResponseSerializer());
@@ -286,7 +290,7 @@ public class GridIoMessageFactory implements 
MessageFactoryProvider {
         // Type 27 is former GridDistributedUnlockRequest
         factory.register((short)28, GridDhtAffinityAssignmentRequest::new, new 
GridDhtAffinityAssignmentRequestSerializer());
         factory.register((short)29, GridDhtAffinityAssignmentResponse::new);
-        factory.register((short)30, GridDhtLockRequest::new);
+        factory.register((short)30, GridDhtLockRequest::new, new 
GridDhtLockRequestSerializer());
         factory.register((short)31, GridDhtLockResponse::new, new 
GridDhtLockResponseSerializer());
         factory.register((short)32, GridDhtTxFinishRequest::new);
         factory.register((short)33, GridDhtTxFinishResponse::new);
@@ -306,7 +310,7 @@ public class GridIoMessageFactory implements 
MessageFactoryProvider {
         factory.register((short)48, GridDhtPartitionsSingleRequest::new, new 
GridDhtPartitionsSingleRequestSerializer());
         factory.register((short)49, GridNearGetRequest::new, new 
GridNearGetRequestSerializer());
         factory.register((short)50, GridNearGetResponse::new);
-        factory.register((short)51, GridNearLockRequest::new);
+        factory.register((short)51, GridNearLockRequest::new, new 
GridNearLockRequestSerializer());
         factory.register((short)52, GridNearLockResponse::new, new 
GridNearLockResponseSerializer());
         factory.register((short)53, GridNearTxFinishRequest::new);
         factory.register((short)54, GridNearTxFinishResponse::new);
@@ -401,7 +405,9 @@ public class GridIoMessageFactory implements 
MessageFactoryProvider {
         factory.register(CachePartitionPartialCountersMap.TYPE_CODE, 
CachePartitionPartialCountersMap::new,
             new CachePartitionPartialCountersMapSerializer());
         factory.register(IgniteDhtDemandedPartitionsMap.TYPE_CODE, 
IgniteDhtDemandedPartitionsMap::new,
-                new IgniteDhtDemandedPartitionsMapSerializer());
+            new IgniteDhtDemandedPartitionsMapSerializer());
+        factory.register(TransactionIsolationMessage.TYPE_CODE, 
TransactionIsolationMessage::new,
+            new TransactionIsolationMessageSerializer());
 
         // [-3..119] [124..129] [-23..-28] [-36..-55] [183..188] - this
         // [120..123] - DR
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/TransactionIsolationMessage.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/TransactionIsolationMessage.java
new file mode 100644
index 00000000000..829cc55bfe9
--- /dev/null
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/TransactionIsolationMessage.java
@@ -0,0 +1,117 @@
+/*
+ * 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.managers.communication;
+
+import org.apache.ignite.internal.Order;
+import org.apache.ignite.plugin.extensions.communication.Message;
+import org.apache.ignite.transactions.TransactionIsolation;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Message for {@link TransactionIsolation}.
+ * Consistency between code-to-value and value-to-code conversions must be 
provided.
+ */
+public class TransactionIsolationMessage implements Message {
+    /** Type code. */
+    public static final short TYPE_CODE = 502;
+
+    /** Transaction isolation. */
+    private TransactionIsolation val;
+
+    /** Code. */
+    @Order(0)
+    private byte code = -1;
+
+    /** Constructor. */
+    public TransactionIsolationMessage() {
+        // No-op.
+    }
+
+    /** Constructor. */
+    public TransactionIsolationMessage(TransactionIsolation val) {
+        this.val = val;
+        code = code(val);
+    }
+
+    /** @return Code. */
+    public byte code() {
+        return code;
+    }
+
+    /** @param code Code. */
+    public void code(byte code) {
+        this.code = code;
+        val = value(code);
+    }
+
+    /** @return Transaction isolation. */
+    public TransactionIsolation value() {
+        return val;
+    }
+
+    /** {@inheritDoc} */
+    @Override public short directType() {
+        return TYPE_CODE;
+    }
+
+    /**
+     * @param val Transaction isolation.
+     * @return Code.
+     */
+    private byte code(@Nullable TransactionIsolation val) {
+        if (val == null)
+            return -1;
+
+        switch (val) {
+            case READ_COMMITTED:
+                return 0;
+
+            case REPEATABLE_READ:
+                return 1;
+
+            case SERIALIZABLE:
+                return 2;
+
+            default:
+                throw new IllegalArgumentException("Unknown transaction 
isolation value: " + val);
+        }
+    }
+
+    /**
+     * @param code Code.
+     * @return Transaction isolation or null.
+     */
+    @Nullable private TransactionIsolation value(byte code) {
+        switch (code) {
+            case -1:
+                return null;
+
+            case 0:
+                return TransactionIsolation.READ_COMMITTED;
+
+            case 1:
+                return TransactionIsolation.REPEATABLE_READ;
+
+            case 2:
+                return TransactionIsolation.SERIALIZABLE;
+
+            default:
+                throw new IllegalArgumentException("Unknown transaction 
isolation code: " + code);
+        }
+    }
+}
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java
index 5ad3abb7e16..fe522e94bda 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java
@@ -17,14 +17,13 @@
 
 package org.apache.ignite.internal.processors.cache.distributed;
 
-import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.UUID;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.internal.GridDirectCollection;
-import org.apache.ignite.internal.GridDirectTransient;
+import org.apache.ignite.internal.Order;
+import 
org.apache.ignite.internal.managers.communication.TransactionIsolationMessage;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
 import org.apache.ignite.internal.processors.cache.KeyCacheObject;
@@ -32,9 +31,6 @@ import 
org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.lang.IgniteUuid;
-import 
org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType;
-import org.apache.ignite.plugin.extensions.communication.MessageReader;
-import org.apache.ignite.plugin.extensions.communication.MessageWriter;
 import org.apache.ignite.transactions.TransactionIsolation;
 import org.jetbrains.annotations.Nullable;
 
@@ -52,48 +48,59 @@ public class GridDistributedLockRequest extends 
GridDistributedBaseMessage {
     private static final int STORE_USED_FLAG_MASK = 0x04;
 
     /** Sender node ID. */
+    @Order(7)
     private UUID nodeId;
 
     /** Near transaction version. */
+    @Order(value = 8, method = "nearXidVersion")
     private GridCacheVersion nearXidVer;
 
     /** Thread ID. */
+    @Order(9)
     private long threadId;
 
     /** Future ID. */
+    @Order(value = 10, method = "futureId")
     private IgniteUuid futId;
 
     /** Max wait timeout. */
+    @Order(11)
     private long timeout;
 
     /** Indicates whether lock is obtained within a scope of transaction. */
+    @Order(value = 12, method = "inTx")
     private boolean isInTx;
 
     /** Invalidate flag for transactions. */
+    @Order(13)
     private boolean isInvalidate;
 
     /** Indicates whether implicit lock so for read or write operation. */
+    @Order(value = 14, method = "txRead")
     private boolean isRead;
 
-    /** Transaction isolation. */
-    private TransactionIsolation isolation;
+    /** Transaction isolation message. */
+    @Order(15)
+    private TransactionIsolationMessage isolation;
 
     /** Key bytes for keys to lock. */
-    @GridDirectCollection(KeyCacheObject.class)
+    @Order(16)
     private List<KeyCacheObject> keys;
 
     /** Array indicating whether value should be returned for a key. */
+    @Order(value = 17, method = "returnValues")
     @GridToStringInclude
     private boolean[] retVals;
 
     /** Key-bytes index. */
-    @GridDirectTransient
     protected int idx;
 
     /** Key count. */
+    @Order(18)
     private int txSize;
 
     /** Additional flags. */
+    @Order(19)
     private byte flags;
 
     /**
@@ -151,7 +158,7 @@ public class GridDistributedLockRequest extends 
GridDistributedBaseMessage {
         this.futId = futId;
         this.isInTx = isInTx;
         this.isRead = isRead;
-        this.isolation = isolation;
+        this.isolation = new TransactionIsolationMessage(isolation);
         this.isInvalidate = isInvalidate;
         this.timeout = timeout;
         this.txSize = txSize;
@@ -163,13 +170,19 @@ public class GridDistributedLockRequest extends 
GridDistributedBaseMessage {
     }
 
     /**
-     *
      * @return Node ID.
      */
     public UUID nodeId() {
         return nodeId;
     }
 
+    /**
+     * @param nodeId Node ID.
+     */
+    public void nodeId(UUID nodeId) {
+        this.nodeId = nodeId;
+    }
+
     /**
      * @return Near transaction ID.
      */
@@ -178,13 +191,26 @@ public class GridDistributedLockRequest extends 
GridDistributedBaseMessage {
     }
 
     /**
-     *
+     * @param nearXidVer Near transaction ID.
+     */
+    public void nearXidVersion(GridCacheVersion nearXidVer) {
+        this.nearXidVer = nearXidVer;
+    }
+
+    /**
      * @return Owner node thread ID.
      */
     public long threadId() {
         return threadId;
     }
 
+    /**
+     * @param threadId Owner node thread ID.
+     */
+    public void threadId(long threadId) {
+        this.threadId = threadId;
+    }
+
     /**
      * @return Future ID.
      */
@@ -192,6 +218,13 @@ public class GridDistributedLockRequest extends 
GridDistributedBaseMessage {
         return futId;
     }
 
+    /**
+     * @param futId Future ID.
+     */
+    public void futureId(IgniteUuid futId) {
+        this.futId = futId;
+    }
+
     /**
      * @return {@code True} if implicit transaction lock.
      */
@@ -199,6 +232,13 @@ public class GridDistributedLockRequest extends 
GridDistributedBaseMessage {
         return isInTx;
     }
 
+    /**
+     * @param isInTx {@code True} if implicit transaction lock.
+     */
+    public void inTx(boolean isInTx) {
+        this.isInTx = isInTx;
+    }
+
     /**
      * @return Invalidate flag.
      */
@@ -206,6 +246,13 @@ public class GridDistributedLockRequest extends 
GridDistributedBaseMessage {
         return isInvalidate;
     }
 
+    /**
+     * @param isInvalidate Invalidate flag.
+     */
+    public void isInvalidate(boolean isInvalidate) {
+        this.isInvalidate = isInvalidate;
+    }
+
     /**
      * @return {@code True} if lock is implicit and for a read operation.
      */
@@ -213,6 +260,13 @@ public class GridDistributedLockRequest extends 
GridDistributedBaseMessage {
         return isRead;
     }
 
+    /**
+     * @param isRead {@code True} if lock is implicit and for a read operation.
+     */
+    public void txRead(boolean isRead) {
+        this.isRead = isRead;
+    }
+
     /**
      * @param idx Key index.
      * @return Flag indicating whether a value should be returned.
@@ -221,6 +275,20 @@ public class GridDistributedLockRequest extends 
GridDistributedBaseMessage {
         return retVals[idx];
     }
 
+    /**
+     * @return Array indicating whether value should be returned for a key.
+     */
+    public boolean[] returnValues() {
+        return retVals;
+    }
+
+    /**
+     * @param retVals Array indicating whether value should be returned for a 
key.
+     */
+    public void returnValues(boolean[] retVals) {
+        this.retVals = retVals;
+    }
+
     /**
      * Sets skip store flag value.
      *
@@ -240,7 +308,7 @@ public class GridDistributedLockRequest extends 
GridDistributedBaseMessage {
     /**
      * @param keepBinary Keep binary flag.
      */
-    public void keepBinary(boolean keepBinary) {
+    private void keepBinary(boolean keepBinary) {
         flags = keepBinary ? (byte)(flags | KEEP_BINARY_FLAG_MASK) : 
(byte)(flags & ~KEEP_BINARY_FLAG_MASK);
     }
 
@@ -269,12 +337,19 @@ public class GridDistributedLockRequest extends 
GridDistributedBaseMessage {
     }
 
     /**
-     * @return Transaction isolation or <tt>null</tt> if not in transaction.
+     * @return Transaction isolation message.
      */
-    public TransactionIsolation isolation() {
+    public TransactionIsolationMessage isolation() {
         return isolation;
     }
 
+    /**
+     * @param isolation Transaction isolation message.
+     */
+    public void isolation(TransactionIsolationMessage isolation) {
+        this.isolation = isolation;
+    }
+
     /**
      * @return Tx size.
      */
@@ -282,6 +357,13 @@ public class GridDistributedLockRequest extends 
GridDistributedBaseMessage {
         return txSize;
     }
 
+    /**
+     * @param txSize Tx size.
+     */
+    public void txSize(int txSize) {
+        this.txSize = txSize;
+    }
+
     /**
      * Adds a key.
      *
@@ -306,6 +388,13 @@ public class GridDistributedLockRequest extends 
GridDistributedBaseMessage {
         return keys;
     }
 
+    /**
+     * @param keys Unmarshalled keys.
+     */
+    public void keys(List<KeyCacheObject> keys) {
+        this.keys = keys;
+    }
+
     /** {@inheritDoc} */
     @Override public int partition() {
         return keys != null && !keys.isEmpty() ? keys.get(0).partition() : -1;
@@ -318,6 +407,27 @@ public class GridDistributedLockRequest extends 
GridDistributedBaseMessage {
         return timeout;
     }
 
+    /**
+     * @param timeout Max lock wait time.
+     */
+    public void timeout(long timeout) {
+        this.timeout = timeout;
+    }
+
+    /**
+     * @return Flags.
+     */
+    public byte flags() {
+        return flags;
+    }
+
+    /**
+     * @param flags Flags.
+     */
+    public void flags(byte flags) {
+        this.flags = flags;
+    }
+
     /** {@inheritDoc} */
     @Override public IgniteLogger messageLogger(GridCacheSharedContext<?, ?> 
ctx) {
         return ctx.txLockMessageLogger();
@@ -342,225 +452,6 @@ public class GridDistributedLockRequest extends 
GridDistributedBaseMessage {
         finishUnmarshalCacheObjects(keys, cctx, ldr);
     }
 
-    /** {@inheritDoc} */
-    @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
-        writer.setBuffer(buf);
-
-        if (!super.writeTo(buf, writer))
-            return false;
-
-        if (!writer.isHeaderWritten()) {
-            if (!writer.writeHeader(directType()))
-                return false;
-
-            writer.onHeaderWritten();
-        }
-
-        switch (writer.state()) {
-            case 7:
-                if (!writer.writeByte(flags))
-                    return false;
-
-                writer.incrementState();
-
-            case 8:
-                if (!writer.writeIgniteUuid(futId))
-                    return false;
-
-                writer.incrementState();
-
-            case 9:
-                if (!writer.writeBoolean(isInTx))
-                    return false;
-
-                writer.incrementState();
-
-            case 10:
-                if (!writer.writeBoolean(isInvalidate))
-                    return false;
-
-                writer.incrementState();
-
-            case 11:
-                if (!writer.writeBoolean(isRead))
-                    return false;
-
-                writer.incrementState();
-
-            case 12:
-                if (!writer.writeByte(isolation != null ? 
(byte)isolation.ordinal() : -1))
-                    return false;
-
-                writer.incrementState();
-
-            case 13:
-                if (!writer.writeCollection(keys, 
MessageCollectionItemType.KEY_CACHE_OBJECT))
-                    return false;
-
-                writer.incrementState();
-
-            case 14:
-                if (!writer.writeMessage(nearXidVer))
-                    return false;
-
-                writer.incrementState();
-
-            case 15:
-                if (!writer.writeUuid(nodeId))
-                    return false;
-
-                writer.incrementState();
-
-            case 16:
-                if (!writer.writeBooleanArray(retVals))
-                    return false;
-
-                writer.incrementState();
-
-            case 17:
-                if (!writer.writeLong(threadId))
-                    return false;
-
-                writer.incrementState();
-
-            case 18:
-                if (!writer.writeLong(timeout))
-                    return false;
-
-                writer.incrementState();
-
-            case 19:
-                if (!writer.writeInt(txSize))
-                    return false;
-
-                writer.incrementState();
-
-        }
-
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean readFrom(ByteBuffer buf, MessageReader reader) {
-        reader.setBuffer(buf);
-
-        if (!super.readFrom(buf, reader))
-            return false;
-
-        switch (reader.state()) {
-            case 7:
-                flags = reader.readByte();
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-            case 8:
-                futId = reader.readIgniteUuid();
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-            case 9:
-                isInTx = reader.readBoolean();
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-            case 10:
-                isInvalidate = reader.readBoolean();
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-            case 11:
-                isRead = reader.readBoolean();
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-            case 12:
-                byte isolationOrd;
-
-                isolationOrd = reader.readByte();
-
-                if (!reader.isLastRead())
-                    return false;
-
-                isolation = TransactionIsolation.fromOrdinal(isolationOrd);
-
-                reader.incrementState();
-
-            case 13:
-                keys = 
reader.readCollection(MessageCollectionItemType.KEY_CACHE_OBJECT);
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-            case 14:
-                nearXidVer = reader.readMessage();
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-            case 15:
-                nodeId = reader.readUuid();
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-            case 16:
-                retVals = reader.readBooleanArray();
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-            case 17:
-                threadId = reader.readLong();
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-            case 18:
-                timeout = reader.readLong();
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-            case 19:
-                txSize = reader.readInt();
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-        }
-
-        return true;
-    }
-
     /** {@inheritDoc} */
     @Override public short directType() {
         return 21;
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java
index d35a4e67dde..4c1a601c1a0 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java
@@ -17,12 +17,11 @@
 
 package org.apache.ignite.internal.processors.cache.distributed.dht;
 
-import java.nio.ByteBuffer;
 import java.util.BitSet;
 import java.util.Map;
 import java.util.UUID;
 import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.GridDirectTransient;
+import org.apache.ignite.internal.Order;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
 import org.apache.ignite.internal.processors.cache.KeyCacheObject;
@@ -33,9 +32,6 @@ import 
org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.lang.IgniteUuid;
-import 
org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType;
-import org.apache.ignite.plugin.extensions.communication.MessageReader;
-import org.apache.ignite.plugin.extensions.communication.MessageWriter;
 import org.apache.ignite.transactions.TransactionIsolation;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -45,37 +41,45 @@ import org.jetbrains.annotations.Nullable;
  */
 public class GridDhtLockRequest extends GridDistributedLockRequest {
     /** Invalidate reader flags. */
+    @Order(20)
     private BitSet invalidateEntries;
 
     /** Mini future ID. */
+    @Order(21)
     private IgniteUuid miniId;
 
     /** Owner mapped version, if any. */
     @GridToStringInclude
-    @GridDirectTransient
     private Map<KeyCacheObject, GridCacheVersion> owned;
 
     /** Array of keys from {@link #owned}. Used during marshalling and 
unmarshalling. */
+    @Order(22)
     @GridToStringExclude
     private KeyCacheObject[] ownedKeys;
 
     /** Array of values from {@link #owned}. Used during marshalling and 
unmarshalling. */
+    @Order(23)
     @GridToStringExclude
     private GridCacheVersion[] ownedValues;
 
     /** Topology version. */
+    @Order(value = 24, method = "topologyVersion")
     private AffinityTopologyVersion topVer;
 
     /** Task name hash. */
+    @Order(25)
     private int taskNameHash;
 
     /** Indexes of keys needed to be preloaded. */
+    @Order(26)
     private BitSet preloadKeys;
 
     /** TTL for read operation. */
+    @Order(27)
     private long accessTtl;
 
     /** Transaction label. */
+    @Order(value = 28, method = "txLabel")
     private String txLbl;
 
     /**
@@ -166,17 +170,17 @@ public class GridDhtLockRequest extends 
GridDistributedLockRequest {
     }
 
     /**
-     * @return Near node ID.
+     * @return Task name hash.
      */
-    public UUID nearNodeId() {
-        return nodeId();
+    public int taskNameHash() {
+        return taskNameHash;
     }
 
     /**
-     * @return Task name hash.
+     * @param taskNameHash Task name hash.
      */
-    public int taskNameHash() {
-        return taskNameHash;
+    public void taskNameHash(int taskNameHash) {
+        this.taskNameHash = taskNameHash;
     }
 
     /**
@@ -186,6 +190,69 @@ public class GridDhtLockRequest extends 
GridDistributedLockRequest {
         return topVer;
     }
 
+    /**
+     * @param topVer Topology version.
+     */
+    public void topologyVersion(AffinityTopologyVersion topVer) {
+        this.topVer = topVer;
+    }
+
+    /**
+     * @return Invalidate reader flags.
+     */
+    public BitSet invalidateEntries() {
+        return invalidateEntries;
+    }
+
+    /**
+     * @param invalidateEntries Invalidate reader flags.
+     */
+    public void invalidateEntries(BitSet invalidateEntries) {
+        this.invalidateEntries = invalidateEntries;
+    }
+
+    /**
+     * @return Array of keys from {@link #owned}. Used during marshalling and 
unmarshalling.
+     */
+    public KeyCacheObject[] ownedKeys() {
+        return ownedKeys;
+    }
+
+    /**
+     * @param ownedKeys Array of keys from {@link #owned}. Used during 
marshalling and unmarshalling.
+     */
+    public void ownedKeys(KeyCacheObject[] ownedKeys) {
+        this.ownedKeys = ownedKeys;
+    }
+
+    /**
+     * @return Array of values from {@link #owned}. Used during marshalling 
and unmarshalling.
+     */
+    public GridCacheVersion[] ownedValues() {
+        return ownedValues;
+    }
+
+    /**
+     * @param ownedValues Array of values from {@link #owned}. Used during 
marshalling and unmarshalling.
+     */
+    public void ownedValues(GridCacheVersion[] ownedValues) {
+        this.ownedValues = ownedValues;
+    }
+
+    /**
+     * @return Indexes of keys needed to be preloaded.
+     */
+    public BitSet preloadKeys() {
+        return preloadKeys;
+    }
+
+    /**
+     * @param preloadKeys Indexes of keys needed to be preloaded.
+     */
+    public void preloadKeys(BitSet preloadKeys) {
+        this.preloadKeys = preloadKeys;
+    }
+
     /**
      * Adds a DHT key.
      *
@@ -231,14 +298,6 @@ public class GridDhtLockRequest extends 
GridDistributedLockRequest {
         owned.put(key, ownerMapped);
     }
 
-    /**
-     * @param key Key.
-     * @return Owner and its mapped versions.
-     */
-    @Nullable public GridCacheVersion owned(KeyCacheObject key) {
-        return owned == null ? null : owned.get(key);
-    }
-
     /**
      * @param idx Entry index to check.
      * @return {@code True} if near entry should be invalidated.
@@ -254,6 +313,13 @@ public class GridDhtLockRequest extends 
GridDistributedLockRequest {
         return miniId;
     }
 
+    /**
+     * @param miniId Mini ID.
+     */
+    public void miniId(IgniteUuid miniId) {
+        this.miniId = miniId;
+    }
+
     /**
      * @return TTL for read operation.
      */
@@ -261,6 +327,13 @@ public class GridDhtLockRequest extends 
GridDistributedLockRequest {
         return accessTtl;
     }
 
+    /**
+     * @param accessTtl TTL for read operation.
+     */
+    public void accessTtl(long accessTtl) {
+        this.accessTtl = accessTtl;
+    }
+
     /**
      * @return Transaction label.
      */
@@ -268,6 +341,13 @@ public class GridDhtLockRequest extends 
GridDistributedLockRequest {
         return txLbl;
     }
 
+    /**
+     * @param txLbl Transaction label.
+     */
+    public void txLabel(String txLbl) {
+        this.txLbl = txLbl;
+    }
+
     /** {@inheritDoc} */
     @Override public void prepareMarshal(GridCacheSharedContext<?, ?> ctx) 
throws IgniteCheckedException {
         super.prepareMarshal(ctx);
@@ -303,165 +383,6 @@ public class GridDhtLockRequest extends 
GridDistributedLockRequest {
         }
     }
 
-    /** {@inheritDoc} */
-    @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
-        writer.setBuffer(buf);
-
-        if (!super.writeTo(buf, writer))
-            return false;
-
-        if (!writer.isHeaderWritten()) {
-            if (!writer.writeHeader(directType()))
-                return false;
-
-            writer.onHeaderWritten();
-        }
-
-        switch (writer.state()) {
-            case 20:
-                if (!writer.writeLong(accessTtl))
-                    return false;
-
-                writer.incrementState();
-
-            case 21:
-                if (!writer.writeBitSet(invalidateEntries))
-                    return false;
-
-                writer.incrementState();
-
-            case 22:
-                if (!writer.writeIgniteUuid(miniId))
-                    return false;
-
-                writer.incrementState();
-
-            case 23:
-                if (!writer.writeObjectArray(ownedKeys, 
MessageCollectionItemType.KEY_CACHE_OBJECT))
-                    return false;
-
-                writer.incrementState();
-
-            case 24:
-                if (!writer.writeObjectArray(ownedValues, 
MessageCollectionItemType.MSG))
-                    return false;
-
-                writer.incrementState();
-
-            case 25:
-                if (!writer.writeBitSet(preloadKeys))
-                    return false;
-
-                writer.incrementState();
-
-            case 26:
-                if (!writer.writeInt(taskNameHash))
-                    return false;
-
-                writer.incrementState();
-
-            case 27:
-                if (!writer.writeAffinityTopologyVersion(topVer))
-                    return false;
-
-                writer.incrementState();
-
-            case 28:
-                if (!writer.writeString(txLbl))
-                    return false;
-
-                writer.incrementState();
-
-        }
-
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean readFrom(ByteBuffer buf, MessageReader reader) {
-        reader.setBuffer(buf);
-
-        if (!super.readFrom(buf, reader))
-            return false;
-
-        switch (reader.state()) {
-            case 20:
-                accessTtl = reader.readLong();
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-            case 21:
-                invalidateEntries = reader.readBitSet();
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-            case 22:
-                miniId = reader.readIgniteUuid();
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-            case 23:
-                ownedKeys = 
reader.readObjectArray(MessageCollectionItemType.KEY_CACHE_OBJECT, 
KeyCacheObject.class);
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-            case 24:
-                ownedValues = 
reader.readObjectArray(MessageCollectionItemType.MSG, GridCacheVersion.class);
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-            case 25:
-                preloadKeys = reader.readBitSet();
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-            case 26:
-                taskNameHash = reader.readInt();
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-            case 27:
-                topVer = reader.readAffinityTopologyVersion();
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-            case 28:
-                txLbl = reader.readString();
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-        }
-
-        return true;
-    }
-
     /** {@inheritDoc} */
     @Override public short directType() {
         return 30;
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
index f6194f51d32..0b187c481ab 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
@@ -235,7 +235,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, 
V> extends GridDhtCach
                                     ctx.systemTx(),
                                     ctx.ioPolicy(),
                                     PESSIMISTIC,
-                                    req.isolation(),
+                                    req.isolation().value(),
                                     req.isInvalidate(),
                                     req.timeout(),
                                     req.txSize(),
@@ -914,7 +914,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, 
V> extends GridDhtCach
                             false,
                             ctx.ioPolicy(),
                             PESSIMISTIC,
-                            req.isolation(),
+                            req.isolation().value(),
                             req.timeout(),
                             req.isInvalidate(),
                             !req.skipStore(),
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java
index f108bf107c5..a06f059e32c 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java
@@ -17,8 +17,8 @@
 
 package org.apache.ignite.internal.processors.cache.distributed.near;
 
-import java.nio.ByteBuffer;
 import java.util.UUID;
+import org.apache.ignite.internal.Order;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.KeyCacheObject;
 import 
org.apache.ignite.internal.processors.cache.distributed.GridDistributedLockRequest;
@@ -26,9 +26,6 @@ import 
org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.lang.IgniteUuid;
-import 
org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType;
-import org.apache.ignite.plugin.extensions.communication.MessageReader;
-import org.apache.ignite.plugin.extensions.communication.MessageWriter;
 import org.apache.ignite.transactions.TransactionIsolation;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -50,28 +47,36 @@ public class GridNearLockRequest extends 
GridDistributedLockRequest {
     private static final int NEAR_CACHE_FLAG_MASK = 0x08;
 
     /** Topology version. */
+    @Order(value = 20, method = "topologyVersion")
     private AffinityTopologyVersion topVer;
 
     /** Mini future ID. */
+    @Order(21)
     private int miniId;
 
     /** Array of mapped DHT versions for this entry. */
+    @Order(value = 22, method = "dhtVersions")
     @GridToStringInclude
     private GridCacheVersion[] dhtVers;
 
     /** Task name hash. */
+    @Order(23)
     private int taskNameHash;
 
     /** TTL for create operation. */
+    @Order(24)
     private long createTtl;
 
     /** TTL for read operation. */
+    @Order(25)
     private long accessTtl;
 
     /** */
+    @Order(value = 26, method = "nearFlags")
     private byte flags;
 
     /** Transaction label. */
+    @Order(value = 27, method = "txLabel")
     private String txLbl;
 
     /**
@@ -215,12 +220,19 @@ public class GridNearLockRequest extends 
GridDistributedLockRequest {
     }
 
     /**
-     * @return Task name hash.q
+     * @return Task name hash.
      */
     public int taskNameHash() {
         return taskNameHash;
     }
 
+    /**
+     * @param taskNameHash Task name hash.
+     */
+    public void taskNameHash(int taskNameHash) {
+        this.taskNameHash = taskNameHash;
+    }
+
     /**
      * @return Sync commit flag.
      */
@@ -263,6 +275,20 @@ public class GridNearLockRequest extends 
GridDistributedLockRequest {
         addKeyBytes(key, retVal);
     }
 
+    /**
+     * @return Array of mapped DHT versions for this entry.
+     */
+    public GridCacheVersion[] dhtVersions() {
+        return dhtVers;
+    }
+
+    /**
+     * @param dhtVers Array of mapped DHT versions for this entry.
+     */
+    public void dhtVersions(GridCacheVersion[] dhtVers) {
+        this.dhtVers = dhtVers;
+    }
+
     /**
      * @param idx Index of the key.
      * @return DHT version for key at given index.
@@ -278,6 +304,13 @@ public class GridNearLockRequest extends 
GridDistributedLockRequest {
         return createTtl;
     }
 
+    /**
+     * @param createTtl New TTL to set after entry is created, -1 to leave 
unchanged.
+     */
+    public void createTtl(long createTtl) {
+        this.createTtl = createTtl;
+    }
+
     /**
      * @return TTL for read operation.
      */
@@ -286,154 +319,38 @@ public class GridNearLockRequest extends 
GridDistributedLockRequest {
     }
 
     /**
-     * @return Transaction label.
+     * @param accessTtl TTL for read operation.
      */
-    @Nullable public String txLabel() {
-        return txLbl;
+    public void accessTtl(long accessTtl) {
+        this.accessTtl = accessTtl;
     }
 
-    /** {@inheritDoc} */
-    @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
-        writer.setBuffer(buf);
-
-        if (!super.writeTo(buf, writer))
-            return false;
-
-        if (!writer.isHeaderWritten()) {
-            if (!writer.writeHeader(directType()))
-                return false;
-
-            writer.onHeaderWritten();
-        }
-
-        switch (writer.state()) {
-            case 20:
-                if (!writer.writeLong(accessTtl))
-                    return false;
-
-                writer.incrementState();
-
-            case 21:
-                if (!writer.writeLong(createTtl))
-                    return false;
-
-                writer.incrementState();
-
-            case 22:
-                if (!writer.writeObjectArray(dhtVers, 
MessageCollectionItemType.MSG))
-                    return false;
-
-                writer.incrementState();
-
-            case 23:
-                if (!writer.writeByte(flags))
-                    return false;
-
-                writer.incrementState();
-
-            case 24:
-                if (!writer.writeInt(miniId))
-                    return false;
-
-                writer.incrementState();
-
-            case 25:
-                if (!writer.writeInt(taskNameHash))
-                    return false;
-
-                writer.incrementState();
-
-            case 26:
-                if (!writer.writeAffinityTopologyVersion(topVer))
-                    return false;
-
-                writer.incrementState();
-
-            case 27:
-                if (!writer.writeString(txLbl))
-                    return false;
-
-                writer.incrementState();
-        }
-
-        return true;
+    /**
+     * @return Flags.
+     */
+    public byte nearFlags() {
+        return flags;
     }
 
-    /** {@inheritDoc} */
-    @Override public boolean readFrom(ByteBuffer buf, MessageReader reader) {
-        reader.setBuffer(buf);
-
-        if (!super.readFrom(buf, reader))
-            return false;
-
-        switch (reader.state()) {
-            case 20:
-                accessTtl = reader.readLong();
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-            case 21:
-                createTtl = reader.readLong();
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-            case 22:
-                dhtVers = 
reader.readObjectArray(MessageCollectionItemType.MSG, GridCacheVersion.class);
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-            case 23:
-                flags = reader.readByte();
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-            case 24:
-                miniId = reader.readInt();
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-            case 25:
-                taskNameHash = reader.readInt();
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-            case 26:
-                topVer = reader.readAffinityTopologyVersion();
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-            case 27:
-                txLbl = reader.readString();
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
+    /**
+     * @param flags Flags.
+     */
+    public void nearFlags(byte flags) {
+        this.flags = flags;
+    }
 
-        }
+    /**
+     * @return Transaction label.
+     */
+    @Nullable public String txLabel() {
+        return txLbl;
+    }
 
-        return true;
+    /**
+     * @param txLbl Transaction label.
+     */
+    public void txLabel(String txLbl) {
+        this.txLbl = txLbl;
     }
 
     /** {@inheritDoc} */
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java
index cb343e5ddab..18e7783f570 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java
@@ -30,6 +30,7 @@ import org.apache.ignite.internal.Order;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.plugin.extensions.communication.Message;
+import org.apache.ignite.transactions.TransactionIsolation;
 import org.junit.Test;
 
 import static com.google.testing.compile.CompilationSubject.assertThat;
@@ -170,6 +171,15 @@ public class MessageProcessorTest {
         assertThat(compilation).hadErrorContaining("You should use 
ErrorMessage for serialization of throwables.");
     }
 
+    /** */
+    @Test
+    public void testEnumFieldFailed() {
+        Compilation compilation = compile("UnwrappedEnumFieldMessage.java");
+
+        assertThat(compilation).failed();
+        assertThat(compilation).hadErrorContaining("Unsupported enum type: " + 
TransactionIsolation.class.getName());
+    }
+
     /** */
     private Compilation compile(String... srcFiles) {
         List<JavaFileObject> input = new ArrayList<>();
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/TransactionIsolationMessageTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/TransactionIsolationMessageTest.java
new file mode 100644
index 00000000000..1b41cb79044
--- /dev/null
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/TransactionIsolationMessageTest.java
@@ -0,0 +1,79 @@
+/*
+ * 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.managers.communication;
+
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.transactions.TransactionIsolation;
+import org.junit.Test;
+
+import static 
org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
+/** */
+public class TransactionIsolationMessageTest {
+    /** */
+    @Test
+    public void testTransactionIsolationCode() {
+        assertEquals(-1, new TransactionIsolationMessage(null).code());
+        assertEquals(0, new 
TransactionIsolationMessage(TransactionIsolation.READ_COMMITTED).code());
+        assertEquals(1, new 
TransactionIsolationMessage(TransactionIsolation.REPEATABLE_READ).code());
+        assertEquals(2, new 
TransactionIsolationMessage(TransactionIsolation.SERIALIZABLE).code());
+
+        for (TransactionIsolation isolation : TransactionIsolation.values())
+            assertTrue(new TransactionIsolationMessage(isolation).code() != 
-1);
+    }
+
+    /** */
+    @Test
+    public void testTransactionIsolationFromCode() {
+        TransactionIsolationMessage msg = new 
TransactionIsolationMessage(null);
+
+        msg.code((byte)-1);
+        assertNull(msg.value());
+
+        msg.code((byte)0);
+        assertSame(TransactionIsolation.READ_COMMITTED, msg.value());
+
+        msg.code((byte)1);
+        assertSame(TransactionIsolation.REPEATABLE_READ, msg.value());
+
+        msg.code((byte)2);
+        assertSame(TransactionIsolation.SERIALIZABLE, msg.value());
+
+        Throwable t = assertThrowsWithCause(() -> msg.code((byte)3), 
IllegalArgumentException.class);
+        assertEquals("Unknown transaction isolation code: 3", t.getMessage());
+    }
+
+    /** */
+    @Test
+    public void testConversionConsistency() {
+        for (TransactionIsolation isolation : 
F.concat(TransactionIsolation.values(), (TransactionIsolation)null)) {
+            TransactionIsolationMessage msg = new 
TransactionIsolationMessage(isolation);
+
+            assertEquals(isolation, msg.value());
+
+            TransactionIsolationMessage newMsg = new 
TransactionIsolationMessage();
+            newMsg.code(msg.code());
+
+            assertEquals(msg.value(), newMsg.value());
+        }
+    }
+}
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 b561782147e..b840db2b284 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
@@ -38,6 +38,7 @@ import 
org.apache.ignite.internal.IgniteSlowClientDetectionSelfTest;
 import org.apache.ignite.internal.TransactionsMXBeanImplTest;
 import org.apache.ignite.internal.codegen.MessageProcessorTest;
 import org.apache.ignite.internal.managers.communication.ErrorMessageSelfTest;
+import 
org.apache.ignite.internal.managers.communication.TransactionIsolationMessageTest;
 import 
org.apache.ignite.internal.processors.affinity.GridAffinityAssignmentV2Test;
 import 
org.apache.ignite.internal.processors.affinity.GridAffinityAssignmentV2TestNoOptimizations;
 import 
org.apache.ignite.internal.processors.affinity.GridAffinityProcessorRendezvousSelfTest;
@@ -146,6 +147,7 @@ import org.junit.runners.Suite;
 
     MessageProcessorTest.class,
     ErrorMessageSelfTest.class,
+    TransactionIsolationMessageTest.class
 })
 public class IgniteBasicTestSuite {
 }
diff --git 
a/modules/core/src/test/resources/codegen/UnwrappedEnumFieldMessage.java 
b/modules/core/src/test/resources/codegen/UnwrappedEnumFieldMessage.java
new file mode 100644
index 00000000000..fa16ff85d54
--- /dev/null
+++ b/modules/core/src/test/resources/codegen/UnwrappedEnumFieldMessage.java
@@ -0,0 +1,38 @@
+/*
+ * 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.plugin.extensions.communication.Message;
+import org.apache.ignite.transactions.TransactionIsolation;
+
+public class UnwrappedEnumFieldMessage implements Message {
+    @Order(0)
+    private TransactionIsolation isolation;
+
+    public TransactionIsolation isolation() {
+        return isolation;
+    }
+
+    public void isolation(TransactionIsolation isolation) {
+        this.isolation = isolation;
+    }
+
+    public short directType() {
+        return 0;
+    }
+}

Reply via email to