This is an automated email from the ASF dual-hosted git repository.
av 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 81dda2275ca IGNITE-28203 Use MarshalableMessage for ErrorMessage
(#12878)
81dda2275ca is described below
commit 81dda2275caa8a7e05014d852a1d1e24ec652e7e
Author: Anton Vinogradov <[email protected]>
AuthorDate: Fri Mar 13 19:36:17 2026 +0300
IGNITE-28203 Use MarshalableMessage for ErrorMessage (#12878)
---
.../query/calcite/message/CalciteErrorMessage.java | 36 ++++++++--
.../internal/MessageSerializerGenerator.java | 40 +++++++++++
.../managers/communication/ErrorMessage.java | 82 +++++-----------------
.../managers/communication/GridIoManager.java | 2 +-
.../communication/GridIoMessageFactory.java | 18 ++++-
.../discovery/DiscoveryMessageFactory.java | 13 ++--
.../communication/MarshallableMessage.java | 5 +-
.../TcpDiscoveryClientReconnectMessage.java | 27 ++-----
.../messages/TcpDiscoveryJoinRequestMessage.java | 27 ++-----
.../TcpDiscoveryNodeAddFinishedMessage.java | 27 ++-----
.../direct/DirectMarshallingMessagesTest.java | 4 +-
.../communication/CompressedMessageTest.java | 4 +-
.../communication/ErrorMessageSelfTest.java | 22 +++---
...iteIoCommunicationMessageSerializationTest.java | 4 +-
.../IgniteDiscoveryMessageSerializationTest.java | 5 +-
...niteCacheContinuousQueryImmutableEntryTest.java | 4 +-
.../GridAbstractCommunicationSelfTest.java | 4 +-
...pCommunicationSpiConcurrentConnectSelfTest.java | 4 +-
.../tcp/GridTcpCommunicationSpiConfigSelfTest.java | 4 +-
...idTcpCommunicationSpiMultithreadedSelfTest.java | 3 +-
...GridTcpCommunicationSpiRecoveryAckSelfTest.java | 4 +-
.../GridTcpCommunicationSpiRecoverySelfTest.java | 4 +-
...TcpCommunicationRecoveryAckClosureSelfTest.java | 4 +-
.../ignite/testframework/GridSpiTestContext.java | 4 +-
.../resources/codegen/TestMarshallableMessage.java | 24 ++-----
...tMarshallableMessageMarshallableSerializer.java | 18 ++++-
.../zk/internal/DiscoveryMessageParser.java | 2 +-
27 files changed, 207 insertions(+), 188 deletions(-)
diff --git
a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/CalciteErrorMessage.java
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/CalciteErrorMessage.java
index 99695f9cf1a..702580e5195 100644
---
a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/CalciteErrorMessage.java
+++
b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/message/CalciteErrorMessage.java
@@ -18,13 +18,17 @@
package org.apache.ignite.internal.processors.query.calcite.message;
import java.util.UUID;
+import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.Order;
-import org.apache.ignite.internal.managers.communication.ErrorMessage;
+import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
+import org.apache.ignite.internal.util.tostring.GridToStringExclude;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.jetbrains.annotations.Nullable;
/**
*
*/
-public class CalciteErrorMessage extends ErrorMessage implements
CalciteMessage {
+public class CalciteErrorMessage implements CalciteMarshalableMessage {
/** */
@Order(0)
UUID qryId;
@@ -33,6 +37,14 @@ public class CalciteErrorMessage extends ErrorMessage
implements CalciteMessage
@Order(1)
long fragmentId;
+ /** Error bytes. */
+ @Order(2)
+ @GridToStringExclude
+ @Nullable public byte[] errBytes;
+
+ /** Error. */
+ private @Nullable Throwable err;
+
/** */
public CalciteErrorMessage() {
// No-op.
@@ -40,12 +52,11 @@ public class CalciteErrorMessage extends ErrorMessage
implements CalciteMessage
/** */
public CalciteErrorMessage(UUID qryId, long fragmentId, Throwable err) {
- super(err);
-
assert err != null;
this.qryId = qryId;
this.fragmentId = fragmentId;
+ this.err = err;
}
/**
@@ -62,6 +73,11 @@ public class CalciteErrorMessage extends ErrorMessage
implements CalciteMessage
return fragmentId;
}
+ /** */
+ public @Nullable Throwable error() {
+ return err;
+ }
+
/** {@inheritDoc} */
@Override public MessageType type() {
return MessageType.QUERY_ERROR_MESSAGE;
@@ -71,4 +87,16 @@ public class CalciteErrorMessage extends ErrorMessage
implements CalciteMessage
@Override public short directType() {
return MessageType.QUERY_ERROR_MESSAGE.directType();
}
+
+ /** {@inheritDoc} */
+ @Override public void prepareMarshal(GridCacheSharedContext<?, ?> ctx)
throws IgniteCheckedException {
+ if (err != null)
+ errBytes = U.marshal(ctx.marshaller(), err);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void prepareUnmarshal(GridCacheSharedContext<?, ?> ctx)
throws IgniteCheckedException {
+ if (errBytes != null)
+ err = U.unmarshal(ctx.marshaller(), errBytes,
U.resolveClassLoader(ctx.cache().context().gridConfig()));
+ }
}
diff --git
a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java
b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java
index 8acc83f01c0..723adfd9852 100644
---
a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java
+++
b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageSerializerGenerator.java
@@ -280,9 +280,29 @@ public class MessageSerializerGenerator {
returnFalseIfWriteFailed(code, "writer.writeHeader",
"directType()");
if (write && marshallableMessage()) {
+ imports.add("org.apache.ignite.IgniteCheckedException");
+ imports.add("org.apache.ignite.IgniteException");
+
code.add(EMPTY);
+ code.add(identedLine("try {"));
+
+ indent++;
+
code.add(identedLine("msg.prepareMarshal(marshaller);"));
+
+ indent--;
+
+ code.add(identedLine("}"));
+ code.add(identedLine("catch (IgniteCheckedException e) {"));
+
+ indent++;
+
+ code.add(identedLine("throw new IgniteException(\"Failed to
marshal object\" + msg.getClass().getSimpleName(), e);"));
+
+ indent--;
+
+ code.add(identedLine("}"));
}
code.add(EMPTY);
@@ -949,8 +969,28 @@ public class MessageSerializerGenerator {
code.add(EMPTY);
if (read && marshallable) {
+ imports.add("org.apache.ignite.IgniteCheckedException");
+ imports.add("org.apache.ignite.IgniteException");
+
+ code.add(identedLine("try {"));
+
+ indent++;
+
code.add(identedLine("msg.finishUnmarshal(marshaller, clsLdr);"));
+ indent--;
+
+ code.add(identedLine("}"));
+ code.add(identedLine("catch (IgniteCheckedException e) {"));
+
+ indent++;
+
+ code.add(identedLine("throw new IgniteException(\"Failed to
unmarshal object\" + msg.getClass().getSimpleName(), e);"));
+
+ indent--;
+
+ code.add(identedLine("}"));
+
code.add(EMPTY);
}
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/ErrorMessage.java
b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/ErrorMessage.java
index 34146c63d11..990e681215a 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/ErrorMessage.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/ErrorMessage.java
@@ -17,41 +17,26 @@
package org.apache.ignite.internal.managers.communication;
-import java.io.Serializable;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.internal.MessageProcessor;
import org.apache.ignite.internal.Order;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
-import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.marshaller.jdk.JdkMarshaller;
-import org.apache.ignite.plugin.extensions.communication.Message;
-import org.apache.ignite.plugin.extensions.communication.MessageWriter;
+import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.plugin.extensions.communication.MarshallableMessage;
import org.jetbrains.annotations.Nullable;
-import static org.apache.ignite.marshaller.Marshallers.jdk;
-
/**
* Message used to transfer {@link Throwable} objects.
- * <p>Because raw serialization of throwables is prohibited, you should use
this message when it is necessary
- * to transfer some error as part of some message. See {@link
MessageProcessor} for details.
- * <p>Currently, under the hood marshalling and unmarshalling is performed by
{@link JdkMarshaller}.
- * <p>If the message serialization fails, wraps this error with own one.
*/
@SuppressWarnings({"NullableProblems", "unused"})
-// TODO Remove Serializable once
https://issues.apache.org/jira/browse/IGNITE-27627 is completed.
-public class ErrorMessage implements Message, Serializable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Serialization and deserealization call holder. */
- @Order(value = 0, method = "errorBytes")
+public class ErrorMessage implements MarshallableMessage {
+ /** Error bytes. */
+ @Order(0)
@GridToStringExclude
@Nullable public byte[] errBytes;
- /** Original error. It is transient and necessary only to avoid duplicated
serialization and deserializtion. */
+ /** Error. */
private @Nullable Throwable err;
/**
@@ -62,61 +47,32 @@ public class ErrorMessage implements Message, Serializable {
}
/**
- * @param err Original error. Will be lazily serialized.
+ * @param err Original error.
*/
public ErrorMessage(@Nullable Throwable err) {
this.err = err;
}
- /**
- * Provides serialized bytes of the error. Should be called only once.
- *
- * @return Serialized error.
- * @see MessageWriter
- */
- public @Nullable byte[] errorBytes() {
- if (err == null)
- return null;
-
+ /** {@inheritDoc} */
+ @Override public void prepareMarshal(Marshaller marsh) throws
IgniteCheckedException {
try {
- return U.marshal(jdk(), err);
+ if (err != null)
+ errBytes = U.marshal(marsh, err);
}
- catch (IgniteCheckedException e0) {
+ catch (IgniteCheckedException e) {
IgniteCheckedException wrappedErr = new
IgniteCheckedException(err.getMessage());
wrappedErr.setStackTrace(err.getStackTrace());
- wrappedErr.addSuppressed(e0);
+ wrappedErr.addSuppressed(e);
- try {
- return U.marshal(jdk(), wrappedErr);
- }
- catch (IgniteCheckedException e1) {
- IgniteException marshErr = new IgniteException("Unable to
marshal the wrapping error.", e1);
-
- marshErr.addSuppressed(wrappedErr);
-
- throw marshErr;
- }
+ errBytes = U.marshal(marsh, wrappedErr);
}
}
- /**
- * Deserializes the error from {@code errBytes}. Should be called only
once.
- *
- * @param errBytes Serialized error.
- * @see MessageWriter
- */
- public void errorBytes(@Nullable byte[] errBytes) {
- if (F.isEmpty(errBytes))
- err = null;
- else {
- try {
- err = U.unmarshal(jdk(), errBytes, U.gridClassLoader());
- }
- catch (IgniteCheckedException e) {
- throw new IgniteException("Failed to unmarshal error data
bytes.", e);
- }
- }
+ /** {@inheritDoc} */
+ @Override public void finishUnmarshal(Marshaller marsh, ClassLoader
clsLdr) throws IgniteCheckedException {
+ if (errBytes != null)
+ err = U.unmarshal(marsh, errBytes, clsLdr);
}
/** */
@@ -125,8 +81,6 @@ public class ErrorMessage implements Message, Serializable {
}
/**
- * Safely gets original error from an error message.
- *
* @param errorMsg Error message.
* @return Error containing in the message.
*/
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
index 07785b6913f..446546b8962 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
@@ -449,7 +449,7 @@ public class GridIoManager extends
GridManagerAdapter<CommunicationSpi<Object>>
List<MessageFactoryProvider> compMsgs = new ArrayList<>();
- compMsgs.add(new GridIoMessageFactory());
+ compMsgs.add(new GridIoMessageFactory(marsh, U.gridClassLoader()));
for (IgniteComponentType compType : IgniteComponentType.values()) {
MessageFactoryProvider f = compType.messageFactory();
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 6baea4e7684..eb022f0edb1 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
@@ -330,6 +330,7 @@ import
org.apache.ignite.internal.util.GridPartitionStateMapSerializer;
import org.apache.ignite.internal.util.UUIDCollectionMessage;
import org.apache.ignite.internal.util.UUIDCollectionMessageSerializer;
import org.apache.ignite.internal.util.distributed.SingleNodeMessage;
+import org.apache.ignite.marshaller.Marshaller;
import org.apache.ignite.plugin.extensions.communication.MessageFactory;
import
org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider;
import org.apache.ignite.spi.collision.jobstealing.JobStealingRequest;
@@ -350,12 +351,27 @@ import
org.apache.ignite.spi.communication.tcp.messages.RecoveryLastReceivedMess
* Message factory implementation.
*/
public class GridIoMessageFactory implements MessageFactoryProvider {
+ /** Custom data marshaller. */
+ private final Marshaller cstDataMarshall;
+
+ /** Class loader for the custom data marshalling. */
+ private final ClassLoader cstDataMarshallClsLdr;
+
+ /**
+ * @param cstDataMarshall Custom data marshaller.
+ * @param cstDataMarshallClsLdr Class loader for the custom data
marshalling.
+ */
+ public GridIoMessageFactory(Marshaller cstDataMarshall, ClassLoader
cstDataMarshallClsLdr) {
+ this.cstDataMarshall = cstDataMarshall;
+ this.cstDataMarshallClsLdr = cstDataMarshallClsLdr;
+ }
+
/** {@inheritDoc} */
@Override public void registerAll(MessageFactory factory) {
// -54 is reserved for SQL.
// We don't use the code‑generated serializer for CompressedMessage -
serialization is highly customized.
factory.register(CompressedMessage.TYPE_CODE, CompressedMessage::new);
- factory.register((short)-66, ErrorMessage::new, new
ErrorMessageSerializer());
+ factory.register((short)-66, ErrorMessage::new, new
ErrorMessageMarshallableSerializer(cstDataMarshall, cstDataMarshallClsLdr));
factory.register((short)-65, TxInfo::new, new TxInfoSerializer());
factory.register((short)-64, TxEntriesInfo::new, new
TxEntriesInfoSerializer());
factory.register((short)-63, ExchangeInfo::new, new
ExchangeInfoSerializer());
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/DiscoveryMessageFactory.java
b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/DiscoveryMessageFactory.java
index 1e31e1bf079..3969c9dd317 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/DiscoveryMessageFactory.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/DiscoveryMessageFactory.java
@@ -18,7 +18,7 @@
package org.apache.ignite.internal.managers.discovery;
import org.apache.ignite.internal.managers.communication.ErrorMessage;
-import
org.apache.ignite.internal.managers.communication.ErrorMessageSerializer;
+import
org.apache.ignite.internal.managers.communication.ErrorMessageMarshallableSerializer;
import org.apache.ignite.internal.processors.authentication.User;
import
org.apache.ignite.internal.processors.authentication.UserAcceptedMessage;
import
org.apache.ignite.internal.processors.authentication.UserAcceptedMessageSerializer;
@@ -132,23 +132,20 @@ import
org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryServerOnlyCustom
import
org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryServerOnlyCustomEventMessageSerializer;
import
org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryStatusCheckMessage;
import
org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryStatusCheckMessageSerializer;
-import org.jetbrains.annotations.Nullable;
/** Message factory for discovery messages. */
public class DiscoveryMessageFactory implements MessageFactoryProvider {
/** Custom data marshaller. */
- private final @Nullable Marshaller cstDataMarshall;
+ private final Marshaller cstDataMarshall;
/** Class loader for the custom data marshalling. */
- private final @Nullable ClassLoader cstDataMarshallClsLdr;
+ private final ClassLoader cstDataMarshallClsLdr;
/**
* @param cstDataMarshall Custom data marshaller.
* @param cstDataMarshallClsLdr Class loader for the custom data
marshalling.
*/
- public DiscoveryMessageFactory(@Nullable Marshaller cstDataMarshall,
@Nullable ClassLoader cstDataMarshallClsLdr) {
- assert cstDataMarshall == null && cstDataMarshallClsLdr == null ||
cstDataMarshall != null && cstDataMarshallClsLdr != null;
-
+ public DiscoveryMessageFactory(Marshaller cstDataMarshall, ClassLoader
cstDataMarshallClsLdr) {
this.cstDataMarshall = cstDataMarshall;
this.cstDataMarshallClsLdr = cstDataMarshallClsLdr;
}
@@ -166,7 +163,7 @@ public class DiscoveryMessageFactory implements
MessageFactoryProvider {
factory.register((short)-102, TcpDiscoveryNodeMetricsMessage::new, new
TcpDiscoveryNodeMetricsMessageSerializer());
factory.register((short)-101, InetSocketAddressMessage::new, new
InetSocketAddressMessageSerializer());
factory.register((short)-100, InetAddressMessage::new, new
InetAddressMessageSerializer());
- factory.register((short)-66, ErrorMessage::new, new
ErrorMessageSerializer());
+ factory.register((short)-66, ErrorMessage::new, new
ErrorMessageMarshallableSerializer(cstDataMarshall, cstDataMarshallClsLdr));
// TcpDiscoveryAbstractMessage
factory.register((short)0, TcpDiscoveryCheckFailedMessage::new, new
TcpDiscoveryCheckFailedMessageSerializer());
diff --git
a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MarshallableMessage.java
b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MarshallableMessage.java
index f58e6cb3241..f3cc81dd68e 100644
---
a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MarshallableMessage.java
+++
b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MarshallableMessage.java
@@ -17,12 +17,13 @@
package org.apache.ignite.plugin.extensions.communication;
+import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.marshaller.Marshaller;
/** A {@link Message} which still requires external custom pre-marshalling and
post-unmarshalling. */
public interface MarshallableMessage extends Message {
/** @param marsh External custom marshaller. */
- public default void prepareMarshal(Marshaller marsh) {
+ public default void prepareMarshal(Marshaller marsh) throws
IgniteCheckedException {
throw new UnsupportedOperationException();
}
@@ -30,7 +31,7 @@ public interface MarshallableMessage extends Message {
* @param marsh External custom marshaller.
* @param clsLdr External class loader to post-unmarshall.
*/
- public default void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) {
+ public default void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr)
throws IgniteCheckedException {
throw new UnsupportedOperationException();
}
}
diff --git
a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryClientReconnectMessage.java
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryClientReconnectMessage.java
index 9d18e1d5b3c..3eaf562e5a7 100644
---
a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryClientReconnectMessage.java
+++
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryClientReconnectMessage.java
@@ -21,7 +21,6 @@ import java.util.Collection;
import java.util.Objects;
import java.util.UUID;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteException;
import org.apache.ignite.internal.Order;
import org.apache.ignite.internal.managers.discovery.DiscoveryMessageFactory;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
@@ -130,29 +129,15 @@ public class TcpDiscoveryClientReconnectMessage extends
TcpDiscoveryAbstractMess
}
/** {@inheritDoc} */
- @Override public void prepareMarshal(Marshaller marsh) {
- if (msgs != null && msgsBytes == null) {
- try {
- msgsBytes = U.marshal(marsh, msgs);
- }
- catch (IgniteCheckedException e) {
- throw new IgniteException("Failed to marshal the pending
messages.", e);
- }
- }
+ @Override public void prepareMarshal(Marshaller marsh) throws
IgniteCheckedException {
+ if (msgs != null)
+ msgsBytes = U.marshal(marsh, msgs);
}
/** {@inheritDoc} */
- @Override public void finishUnmarshal(Marshaller marsh, ClassLoader
clsLdr) {
- if (msgsBytes != null && msgs == null) {
- try {
- msgs = U.unmarshal(marsh, msgsBytes, clsLdr);
-
- msgsBytes = null;
- }
- catch (IgniteCheckedException e) {
- throw new IgniteException("Failed to unmarshal the pending
messages.", e);
- }
- }
+ @Override public void finishUnmarshal(Marshaller marsh, ClassLoader
clsLdr) throws IgniteCheckedException {
+ if (msgsBytes != null)
+ msgs = U.unmarshal(marsh, msgsBytes, clsLdr);
}
/** {@inheritDoc} */
diff --git
a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryJoinRequestMessage.java
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryJoinRequestMessage.java
index 8932c3f7af9..1e39d5b29fe 100644
---
a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryJoinRequestMessage.java
+++
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryJoinRequestMessage.java
@@ -18,7 +18,6 @@
package org.apache.ignite.spi.discovery.tcp.messages;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteException;
import org.apache.ignite.internal.Order;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -96,29 +95,15 @@ public class TcpDiscoveryJoinRequestMessage extends
TcpDiscoveryAbstractTraceabl
}
/** {@inheritDoc} */
- @Override public void prepareMarshal(Marshaller marsh) {
- if (node != null && nodeBytes == null) {
- try {
- nodeBytes = U.marshal(marsh, node);
- }
- catch (IgniteCheckedException e) {
- throw new IgniteException("Failed to marshal TcpDiscoveryNode
object", e);
- }
- }
+ @Override public void prepareMarshal(Marshaller marsh) throws
IgniteCheckedException {
+ if (node != null)
+ nodeBytes = U.marshal(marsh, node);
}
/** {@inheritDoc} */
- @Override public void finishUnmarshal(Marshaller marsh, ClassLoader
clsLdr) {
- if (nodeBytes != null && node == null) {
- try {
- node = U.unmarshal(marsh, nodeBytes, clsLdr);
-
- nodeBytes = null;
- }
- catch (IgniteCheckedException e) {
- throw new IgniteException("Failed to unmarshal
TcpDiscoveryNode object", e);
- }
- }
+ @Override public void finishUnmarshal(Marshaller marsh, ClassLoader
clsLdr) throws IgniteCheckedException {
+ if (nodeBytes != null)
+ node = U.unmarshal(marsh, nodeBytes, clsLdr);
}
/** {@inheritDoc} */
diff --git
a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryNodeAddFinishedMessage.java
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryNodeAddFinishedMessage.java
index 820c42156b5..451689eabe0 100644
---
a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryNodeAddFinishedMessage.java
+++
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryNodeAddFinishedMessage.java
@@ -20,7 +20,6 @@ package org.apache.ignite.spi.discovery.tcp.messages;
import java.util.Map;
import java.util.UUID;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteException;
import org.apache.ignite.internal.Order;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.typedef.internal.S;
@@ -127,29 +126,15 @@ public class TcpDiscoveryNodeAddFinishedMessage extends
TcpDiscoveryAbstractTrac
}
/** {@inheritDoc} */
- @Override public void prepareMarshal(Marshaller marsh) {
- if (clientNodeAttrs != null && clientNodeAttrsBytes == null) {
- try {
- clientNodeAttrsBytes = U.marshal(marsh, clientNodeAttrs);
- }
- catch (IgniteCheckedException e) {
- throw new IgniteException("Failed to marshal client node
attributes.", e);
- }
- }
+ @Override public void prepareMarshal(Marshaller marsh) throws
IgniteCheckedException {
+ if (clientNodeAttrs != null)
+ clientNodeAttrsBytes = U.marshal(marsh, clientNodeAttrs);
}
/** {@inheritDoc} */
- @Override public void finishUnmarshal(Marshaller marsh, ClassLoader
clsLdr) {
- if (clientNodeAttrsBytes != null && clientNodeAttrs == null) {
- try {
- clientNodeAttrs = U.unmarshal(marsh, clientNodeAttrsBytes,
clsLdr);
-
- clientNodeAttrsBytes = null;
- }
- catch (IgniteCheckedException e) {
- throw new IgniteException("Failed to unmarshal client node
attributes.", e);
- }
- }
+ @Override public void finishUnmarshal(Marshaller marsh, ClassLoader
clsLdr) throws IgniteCheckedException {
+ if (clientNodeAttrsBytes != null)
+ clientNodeAttrs = U.unmarshal(marsh, clientNodeAttrsBytes, clsLdr);
}
/** {@inheritDoc} */
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/direct/DirectMarshallingMessagesTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/direct/DirectMarshallingMessagesTest.java
index 3c07575f8b4..d3fb2b64dbd 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/direct/DirectMarshallingMessagesTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/direct/DirectMarshallingMessagesTest.java
@@ -23,6 +23,7 @@ import java.util.function.Function;
import org.apache.ignite.internal.managers.communication.GridIoMessageFactory;
import
org.apache.ignite.internal.managers.communication.IgniteMessageFactoryImpl;
import org.apache.ignite.internal.util.distributed.SingleNodeMessage;
+import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.plugin.extensions.communication.Message;
import org.apache.ignite.plugin.extensions.communication.MessageFactory;
import
org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider;
@@ -30,6 +31,7 @@ import
org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;
import static
org.apache.ignite.internal.util.distributed.DistributedProcess.DistributedProcessType.TEST_PROCESS;
+import static org.apache.ignite.marshaller.Marshallers.jdk;
/**
* Messages marshalling test.
@@ -37,7 +39,7 @@ import static
org.apache.ignite.internal.util.distributed.DistributedProcess.Dis
public class DirectMarshallingMessagesTest extends GridCommonAbstractTest {
/** Message factory. */
private final MessageFactory msgFactory =
- new IgniteMessageFactoryImpl(new MessageFactoryProvider[] {new
GridIoMessageFactory()});
+ new IgniteMessageFactoryImpl(new MessageFactoryProvider[] {new
GridIoMessageFactory(jdk(), U.gridClassLoader())});
/** */
@Test
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/CompressedMessageTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/CompressedMessageTest.java
index 270fe7e47b3..e5d8ca19307 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/CompressedMessageTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/CompressedMessageTest.java
@@ -37,6 +37,7 @@ import
org.apache.ignite.plugin.extensions.communication.MessageFactory;
import
org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider;
import org.junit.Test;
+import static org.apache.ignite.marshaller.Marshallers.jdk;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -45,7 +46,8 @@ public class CompressedMessageTest {
/** */
@Test
public void testWriteReadHugeMessage() {
- MessageFactory msgFactory = new IgniteMessageFactoryImpl(new
MessageFactoryProvider[]{new GridIoMessageFactory()});
+ MessageFactory msgFactory = new IgniteMessageFactoryImpl(new
MessageFactoryProvider[]{
+ new GridIoMessageFactory(jdk(), U.gridClassLoader())});
DirectMessageWriter writer = new DirectMessageWriter(msgFactory);
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/ErrorMessageSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/ErrorMessageSelfTest.java
index 8463e67df63..b3ff36de94b 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/ErrorMessageSelfTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/ErrorMessageSelfTest.java
@@ -20,8 +20,10 @@ package org.apache.ignite.internal.managers.communication;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.internal.util.typedef.X;
+import org.apache.ignite.internal.util.typedef.internal.U;
import org.junit.Test;
+import static org.apache.ignite.marshaller.Marshallers.jdk;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
@@ -31,20 +33,24 @@ import static org.junit.Assert.assertTrue;
public class ErrorMessageSelfTest {
/** */
@Test
- public void testDirectAndInsverseConversion() {
+ public void testDirectAndInsverseConversion() throws
IgniteCheckedException {
IgniteException e = new IgniteException("Test exception", new
IgniteCheckedException("Test cause"));
ErrorMessage msg0 = new ErrorMessage(e);
-
+
assertSame(e, msg0.error());
- byte[] errBytes = msg0.errorBytes();
+ msg0.prepareMarshal(jdk());
+
+ byte[] errBytes = msg0.errBytes;
assertNotNull(errBytes);
ErrorMessage msg1 = new ErrorMessage();
- msg1.errorBytes(errBytes);
-
+ msg1.errBytes = errBytes;
+
+ msg1.finishUnmarshal(jdk(), U.gridClassLoader());
+
Throwable t = msg1.error();
assertNotNull(t);
@@ -56,13 +62,13 @@ public class ErrorMessageSelfTest {
@Test
public void testNull() {
assertNull(new ErrorMessage(null).error());
- assertNull(new ErrorMessage(null).errorBytes());
+ assertNull(new ErrorMessage(null).errBytes);
ErrorMessage msg = new ErrorMessage();
- msg.errorBytes(null);
+ msg.errBytes = null;
assertNull(msg.error());
- assertNull(msg.errorBytes());
+ assertNull(msg.errBytes);
}
}
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/IgniteIoCommunicationMessageSerializationTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/IgniteIoCommunicationMessageSerializationTest.java
index a05bb4e9ac6..3f2a942ddb1 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/IgniteIoCommunicationMessageSerializationTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/IgniteIoCommunicationMessageSerializationTest.java
@@ -20,18 +20,20 @@ package org.apache.ignite.internal.managers.communication;
import java.util.UUID;
import org.apache.commons.lang3.reflect.FieldUtils;
import
org.apache.ignite.internal.processors.cache.distributed.dht.PartitionUpdateCountersMessage;
+import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.plugin.extensions.communication.Message;
import
org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider;
import org.apache.ignite.spi.communication.tcp.messages.NodeIdMessage;
import static org.apache.ignite.internal.util.IgniteUtils.toBytes;
+import static org.apache.ignite.marshaller.Marshallers.jdk;
/** */
public class IgniteIoCommunicationMessageSerializationTest extends
AbstractMessageSerializationTest {
/** {@inheritDoc} */
@Override protected MessageFactoryProvider messageFactory() {
- return new GridIoMessageFactory();
+ return new GridIoMessageFactory(jdk(), U.gridClassLoader());
}
/** {@inheritDoc} */
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/IgniteDiscoveryMessageSerializationTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/IgniteDiscoveryMessageSerializationTest.java
index f6eaab9c754..b37398fa139 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/IgniteDiscoveryMessageSerializationTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/IgniteDiscoveryMessageSerializationTest.java
@@ -18,12 +18,15 @@
package org.apache.ignite.internal.managers.discovery;
import
org.apache.ignite.internal.managers.communication.AbstractMessageSerializationTest;
+import org.apache.ignite.internal.util.typedef.internal.U;
import
org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider;
+import static org.apache.ignite.marshaller.Marshallers.jdk;
+
/** Serialization test for discovery messages. */
public class IgniteDiscoveryMessageSerializationTest extends
AbstractMessageSerializationTest {
/** {@inheritDoc} */
@Override protected MessageFactoryProvider messageFactory() {
- return new DiscoveryMessageFactory(null, null);
+ return new DiscoveryMessageFactory(jdk(), U.gridClassLoader());
}
}
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/IgniteCacheContinuousQueryImmutableEntryTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/IgniteCacheContinuousQueryImmutableEntryTest.java
index 7dc74b73de6..e75ed12f400 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/IgniteCacheContinuousQueryImmutableEntryTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/IgniteCacheContinuousQueryImmutableEntryTest.java
@@ -37,6 +37,7 @@ import
org.apache.ignite.internal.managers.communication.IgniteMessageFactoryImp
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.CacheObjectImpl;
import org.apache.ignite.internal.processors.cache.KeyCacheObjectImpl;
+import org.apache.ignite.internal.util.typedef.internal.U;
import
org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;
@@ -44,6 +45,7 @@ import org.junit.Test;
import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+import static org.apache.ignite.marshaller.Marshallers.jdk;
/**
*
@@ -148,7 +150,7 @@ public class IgniteCacheContinuousQueryImmutableEntryTest
extends GridCommonAbst
e0.markFiltered();
IgniteMessageFactoryImpl msgFactory =
- new IgniteMessageFactoryImpl(new MessageFactoryProvider[]{new
GridIoMessageFactory()});
+ new IgniteMessageFactoryImpl(new MessageFactoryProvider[]{new
GridIoMessageFactory(jdk(), U.gridClassLoader())});
ByteBuffer buf = ByteBuffer.allocate(4096);
DirectMessageWriter writer = new DirectMessageWriter(msgFactory);
diff --git
a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridAbstractCommunicationSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridAbstractCommunicationSelfTest.java
index 3427867c84f..b2b94378e98 100644
---
a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridAbstractCommunicationSelfTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridAbstractCommunicationSelfTest.java
@@ -47,6 +47,7 @@ import
org.apache.ignite.testframework.junits.IgniteTestResources;
import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MACS;
+import static org.apache.ignite.marshaller.Marshallers.jdk;
/**
* Super class for all communication self tests.
@@ -160,7 +161,8 @@ public abstract class GridAbstractCommunicationSelfTest<T
extends CommunicationS
}
};
- ctx.messageFactory(new IgniteMessageFactoryImpl(new
MessageFactoryProvider[] {new GridIoMessageFactory(), testMsgFactory}));
+ ctx.messageFactory(new IgniteMessageFactoryImpl(new
MessageFactoryProvider[] {
+ new GridIoMessageFactory(jdk(), U.gridClassLoader()),
testMsgFactory}));
ctx.setLocalNode(node);
diff --git
a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConcurrentConnectSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConcurrentConnectSelfTest.java
index b2ee543a8cb..54c6a40c1fa 100644
---
a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConcurrentConnectSelfTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConcurrentConnectSelfTest.java
@@ -64,6 +64,8 @@ import
org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest;
import org.apache.ignite.testframework.junits.spi.GridSpiTest;
import org.junit.Test;
+import static org.apache.ignite.marshaller.Marshallers.jdk;
+
/**
*
*/
@@ -438,7 +440,7 @@ public class
GridTcpCommunicationSpiConcurrentConnectSelfTest<T extends Communic
};
ctx.messageFactory(new IgniteMessageFactoryImpl(
- new MessageFactoryProvider[] {new GridIoMessageFactory(),
testMsgFactory})
+ new MessageFactoryProvider[] {new
GridIoMessageFactory(jdk(), U.gridClassLoader()), testMsgFactory})
);
ctx.setLocalNode(node);
diff --git
a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConfigSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConfigSelfTest.java
index d4d63ac7e66..11a00c77265 100644
---
a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConfigSelfTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConfigSelfTest.java
@@ -58,6 +58,7 @@ import static
org.apache.ignite.IgniteSystemProperties.IGNITE_TCP_COMM_SET_ATTR_
import static org.apache.ignite.IgniteSystemProperties.getBoolean;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MACS;
import static org.apache.ignite.internal.util.IgniteUtils.spiAttribute;
+import static org.apache.ignite.marshaller.Marshallers.jdk;
import static
org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi.ATTR_HOST_NAMES;
import static org.apache.ignite.testframework.GridTestUtils.getFreeCommPort;
@@ -251,7 +252,8 @@ public class GridTcpCommunicationSpiConfigSelfTest extends
GridSpiAbstractConfig
MessageFactoryProvider testMsgFactory = factory ->
factory.register(GridTestMessage.DIRECT_TYPE, GridTestMessage::new);
- ctx.messageFactory(new IgniteMessageFactoryImpl(new
MessageFactoryProvider[]{new GridIoMessageFactory(), testMsgFactory}));
+ ctx.messageFactory(new IgniteMessageFactoryImpl(new
MessageFactoryProvider[]{
+ new GridIoMessageFactory(jdk(), U.gridClassLoader()),
testMsgFactory}));
ctx.setLocalNode(node);
diff --git
a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiMultithreadedSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiMultithreadedSelfTest.java
index 976108cef7a..2d08829de43 100644
---
a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiMultithreadedSelfTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiMultithreadedSelfTest.java
@@ -64,6 +64,7 @@ import
org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest;
import org.junit.Test;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MACS;
+import static org.apache.ignite.marshaller.Marshallers.jdk;
/**
* Class for multithreaded {@link TcpCommunicationSpi} test.
@@ -468,7 +469,7 @@ public class GridTcpCommunicationSpiMultithreadedSelfTest
extends GridSpiAbstrac
MessageFactoryProvider testMsgFactory = factory ->
factory.register(GridTestMessage.DIRECT_TYPE, GridTestMessage::new);
ctx.messageFactory(new IgniteMessageFactoryImpl(
- new MessageFactoryProvider[] {new GridIoMessageFactory(),
testMsgFactory})
+ new MessageFactoryProvider[] {new
GridIoMessageFactory(jdk(), U.gridClassLoader()), testMsgFactory})
);
ctx.timeoutProcessor(timeoutProcessor);
diff --git
a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoveryAckSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoveryAckSelfTest.java
index 479c300a263..d9673085e92 100644
---
a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoveryAckSelfTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoveryAckSelfTest.java
@@ -55,6 +55,8 @@ import
org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest;
import org.apache.ignite.testframework.junits.spi.GridSpiTest;
import org.junit.Test;
+import static org.apache.ignite.marshaller.Marshallers.jdk;
+
/**
*
*/
@@ -404,7 +406,7 @@ public class GridTcpCommunicationSpiRecoveryAckSelfTest<T
extends CommunicationS
};
ctx.messageFactory(new IgniteMessageFactoryImpl(
- new MessageFactoryProvider[] {new GridIoMessageFactory(),
testMsgFactory})
+ new MessageFactoryProvider[] {new
GridIoMessageFactory(jdk(), U.gridClassLoader()), testMsgFactory})
);
ctx.setLocalNode(node);
diff --git
a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoverySelfTest.java
b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoverySelfTest.java
index c1cf05bea13..2169a66915f 100644
---
a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoverySelfTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoverySelfTest.java
@@ -59,6 +59,8 @@ import
org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest;
import org.apache.ignite.testframework.junits.spi.GridSpiTest;
import org.junit.Test;
+import static org.apache.ignite.marshaller.Marshallers.jdk;
+
/**
*
*/
@@ -728,7 +730,7 @@ public class GridTcpCommunicationSpiRecoverySelfTest<T
extends CommunicationSpi<
MessageFactoryProvider testMsgFactory = factory ->
factory.register(GridTestMessage.DIRECT_TYPE, GridTestMessage::new);
ctx.messageFactory(new IgniteMessageFactoryImpl(
- new MessageFactoryProvider[] {new GridIoMessageFactory(),
testMsgFactory})
+ new MessageFactoryProvider[] {new
GridIoMessageFactory(jdk(), U.gridClassLoader()), testMsgFactory})
);
ctx.setLocalNode(node);
diff --git
a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/IgniteTcpCommunicationRecoveryAckClosureSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/IgniteTcpCommunicationRecoveryAckClosureSelfTest.java
index d6e406bf91a..de813ed505d 100644
---
a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/IgniteTcpCommunicationRecoveryAckClosureSelfTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/IgniteTcpCommunicationRecoveryAckClosureSelfTest.java
@@ -58,6 +58,8 @@ import
org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest;
import org.apache.ignite.testframework.junits.spi.GridSpiTest;
import org.junit.Test;
+import static org.apache.ignite.marshaller.Marshallers.jdk;
+
/**
*
*/
@@ -457,7 +459,7 @@ public class
IgniteTcpCommunicationRecoveryAckClosureSelfTest<T extends Communic
};
ctx.messageFactory(new IgniteMessageFactoryImpl(
- new MessageFactoryProvider[] {new GridIoMessageFactory(),
testMsgFactory})
+ new MessageFactoryProvider[] {new
GridIoMessageFactory(jdk(), U.gridClassLoader()), testMsgFactory})
);
ctx.setLocalNode(node);
diff --git
a/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java
b/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java
index 651c8e099d5..8809b1c204b 100644
---
a/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java
+++
b/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java
@@ -52,6 +52,7 @@ import
org.apache.ignite.internal.processors.timeout.GridSpiTimeoutObject;
import org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiPredicate;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.logger.NullLogger;
@@ -75,6 +76,7 @@ import static
org.apache.ignite.events.EventType.EVT_NODE_JOINED;
import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
import static org.apache.ignite.events.EventType.EVT_NODE_METRICS_UPDATED;
import static org.apache.ignite.internal.GridTopic.TOPIC_COMM_USER;
+import static org.apache.ignite.marshaller.Marshallers.jdk;
/**
* Test SPI context.
@@ -552,7 +554,7 @@ public class GridSpiTestContext implements IgniteSpiContext
{
/** {@inheritDoc} */
@Override public MessageFactory messageFactory() {
if (factory == null)
- factory = new IgniteMessageFactoryImpl(new
MessageFactoryProvider[]{new GridIoMessageFactory()});
+ factory = new IgniteMessageFactoryImpl(new
MessageFactoryProvider[]{new GridIoMessageFactory(jdk(), U.gridClassLoader())});
return factory;
}
diff --git
a/modules/core/src/test/resources/codegen/TestMarshallableMessage.java
b/modules/core/src/test/resources/codegen/TestMarshallableMessage.java
index 58a871692d3..7d33f076d88 100644
--- a/modules/core/src/test/resources/codegen/TestMarshallableMessage.java
+++ b/modules/core/src/test/resources/codegen/TestMarshallableMessage.java
@@ -43,29 +43,13 @@ public class TestMarshallableMessage implements
MarshallableMessage {
byte[] cstDataBytes;
/** {@inheritDoc} */
- @Override public void prepareMarshal(Marshaller marsh) {
- if (cstData != null && cstDataBytes == null) {
- try {
- cstDataBytes = U.marshal(marsh, cstData);
- }
- catch (IgniteCheckedException e) {
- throw new IgniteException("Failed to marshal custom data.", e);
- }
- }
+ @Override public void prepareMarshal(Marshaller marsh) throws
IgniteCheckedException {
+ cstDataBytes = U.marshal(marsh, cstData);
}
/** {@inheritDoc} */
- @Override public void finishUnmarshal(Marshaller marsh, ClassLoader
clsLdr) {
- if (cstDataBytes != null && cstData == null) {
- try {
- cstData = U.unmarshal(marsh, cstDataBytes, clsLdr);
-
- cstDataBytes = null;
- }
- catch (IgniteCheckedException e) {
- throw new IgniteException("Failed to unmarshal custom data.",
e);
- }
- }
+ @Override public void finishUnmarshal(Marshaller marsh, ClassLoader
clsLdr) throws IgniteCheckedException {
+ cstData = U.unmarshal(marsh, cstDataBytes, clsLdr);
}
public short directType() {
diff --git
a/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshallableSerializer.java
b/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshallableSerializer.java
index 365ec8b80bf..80602f050ee 100644
---
a/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshallableSerializer.java
+++
b/modules/core/src/test/resources/codegen/TestMarshallableMessageMarshallableSerializer.java
@@ -17,6 +17,8 @@
package org.apache.ignite.internal;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
import org.apache.ignite.internal.TestMarshallableMessage;
import org.apache.ignite.marshaller.Marshaller;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
@@ -45,7 +47,12 @@ public class TestMarshallableMessageMarshallableSerializer
implements MessageSer
if (!writer.writeHeader(msg.directType()))
return false;
- msg.prepareMarshal(marshaller);
+ try {
+ msg.prepareMarshal(marshaller);
+ }
+ catch (IgniteCheckedException e) {
+ throw new IgniteException("Failed to marshal object", e);
+ }
writer.onHeaderWritten();
}
@@ -101,8 +108,13 @@ public class TestMarshallableMessageMarshallableSerializer
implements MessageSer
reader.incrementState();
}
- msg.finishUnmarshal(marshaller, clsLdr);
+ try {
+ msg.finishUnmarshal(marshaller, clsLdr);
+ }
+ catch (IgniteCheckedException e) {
+ throw new IgniteException("Failed to unmarshal object", e);
+ }
return true;
}
-}
\ No newline at end of file
+}
diff --git
a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java
b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java
index bd2dd5857b5..790a573df4a 100644
---
a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java
+++
b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java
@@ -66,7 +66,7 @@ public class DiscoveryMessageParser {
public DiscoveryMessageParser(Marshaller marsh) {
this.marsh = marsh;
this.msgFactory = new IgniteMessageFactoryImpl(
- new MessageFactoryProvider[] { new DiscoveryMessageFactory(null,
null) });
+ new MessageFactoryProvider[] { new DiscoveryMessageFactory(marsh,
U.gridClassLoader()) });
}
/** Marshals discovery message to bytes array. */