wernerdv commented on code in PR #12651:
URL: https://github.com/apache/ignite/pull/12651#discussion_r2758903643


##########
modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryCustomEventMessage.java:
##########
@@ -73,47 +89,91 @@ public 
TcpDiscoveryCustomEventMessage(TcpDiscoveryCustomEventMessage msg) {
      */
     public void clearMessage() {
         msg = null;
+        serMsg = null;
     }
 
     /**
-     * @return Serialized message.
+     * @return Serialized message bytes.
      */
     public byte[] messageBytes() {
         return msgBytes;
     }
 
     /**
-     * @param msg Message.
-     * @param msgBytes Serialized message.
+     * @param msgBytes Serialized message bytes.
      */
-    public void message(@Nullable DiscoverySpiCustomMessage msg, @NotNull 
byte[] msgBytes) {
-        this.msg = msg;
+    public void messageBytes(@Nullable byte[] msgBytes) {
         this.msgBytes = msgBytes;
     }
 
     /**
+     * @return {@link Message} representation of original message.
+     */
+    public @Nullable Message serializedMessage() {
+        return serMsg;
+    }
+
+    /**
+     * @param serMsg {@link Message} representation of original message.
+     */
+    public void serializedMessage(@Nullable Message serMsg) {
+        this.serMsg = serMsg;
+    }
+
+    /**
+     * @return Original message.
+     */
+    public DiscoveryCustomMessage message() {
+        return msg;
+    }
+
+    /**
+     * Prepare message for serialization.
+     *
      * @param marsh Marshaller.
-     * @param ldr Classloader.
-     * @return Deserialized message,
-     * @throws java.lang.Throwable if unmarshal failed.
      */
-    @Nullable public DiscoverySpiCustomMessage message(@NotNull Marshaller 
marsh, ClassLoader ldr) throws Throwable {
-        if (msg == null) {
+    //TODO: Should be removed in 
https://issues.apache.org/jira/browse/IGNITE-27627
+    public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException 
{
+        if (msg instanceof Message)
+            serMsg = (Message)msg;
+        else {
+            assert msgBytes == null || msg.isMutable() : "Message bytes are 
not null for immutable message: bytes=" +
+                Arrays.toString(msgBytes) + "]";
+
+            msgBytes = U.marshal(marsh, msg);
+        }
+    }
+
+    /**
+     * Finish deserialization.
+     *
+     * @param marsh Marshaller.
+     * @param ldr Class loader.
+     */
+    //TODO: Should be removed in 
https://issues.apache.org/jira/browse/IGNITE-27627
+    public void finishUnmarhal(Marshaller marsh, ClassLoader ldr) throws 
IgniteCheckedException {
+        if (msg != null)
+            return;
+
+        if (serMsg != null)
+            msg = (DiscoveryCustomMessage)serMsg;
+        else {
             try {
                 msg = U.unmarshal(marsh, msgBytes, ldr);

Review Comment:
   Should we add a check that msgBytes != null?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to