You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by av...@apache.org on 2026/08/03 16:55:44 UTC

(ignite) branch ignite-28938 created (now 74954d120c0)

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

anton-vinogradov pushed a change to branch ignite-28938
in repository https://gitbox.apache.org/repos/asf/ignite.git


      at 74954d120c0 IGNITE-28938 Self-review: check CustomMarshallingMessage on registration, drop unused imports, shorten javadocs

This branch includes the following new commits:

     new 74954d120c0 IGNITE-28938 Self-review: check CustomMarshallingMessage on registration, drop unused imports, shorten javadocs

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(ignite) 01/01: IGNITE-28938 Self-review: check CustomMarshallingMessage on registration, drop unused imports, shorten javadocs

Posted by av...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

anton-vinogradov pushed a commit to branch ignite-28938
in repository https://gitbox.apache.org/repos/asf/ignite.git

commit 74954d120c09e27bfc806682e7e5a617ed766fb8
Author: Anton Vinogradov <av...@apache.org>
AuthorDate: Mon Aug 3 19:55:29 2026 +0300

    IGNITE-28938 Self-review: check CustomMarshallingMessage on registration, drop unused imports, shorten javadocs
    
    Co-Authored-By: Claude Opus 5 <no...@anthropic.com>
---
 .../query/calcite/metadata/ColocationGroup.java    |  1 -
 .../ignite/internal/CustomMarshallingMessage.java  |  9 ++----
 .../ignite/internal/CustomWireFormMessage.java     | 10 +++---
 .../ignite/internal/MarshallableMessage.java       |  1 -
 .../communication/IgniteMessageFactoryImpl.java    |  6 ++--
 ...AbstractMarshallableMessageFactoryProvider.java | 37 ++++++++++++----------
 .../processors/cache/GridCacheEntryInfo.java       |  1 -
 .../preloader/GridDhtPartitionsFullMessage.java    |  1 -
 .../preloader/GridDhtPartitionsSingleMessage.java  |  1 -
 .../distributed/near/GridNearTxPrepareRequest.java |  1 -
 .../discovery/tcp/internal/TcpDiscoveryNode.java   |  3 +-
 11 files changed, 32 insertions(+), 39 deletions(-)

diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/ColocationGroup.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/ColocationGroup.java
index 1aeb5c77009..1187baa6b4b 100644
--- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/ColocationGroup.java
+++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/ColocationGroup.java
@@ -38,7 +38,6 @@ import org.apache.ignite.internal.util.GridIntIterator;
 import org.apache.ignite.internal.util.GridIntList;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.marshaller.Marshaller;
 
 /** */
 public class ColocationGroup implements CustomWireFormMessage {
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/CustomMarshallingMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/CustomMarshallingMessage.java
index 9730ff0347b..0bb1a6ecbef 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/CustomMarshallingMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/CustomMarshallingMessage.java
@@ -17,15 +17,12 @@
 
 package org.apache.ignite.internal;
 
-import org.apache.ignite.marshaller.Marshaller;
 import org.apache.ignite.plugin.extensions.communication.Message;
 
 /**
- * A {@link Message} that takes part in marshalling itself, so the generated companion has a step to call. What that
- * step is differs: {@link MarshallableMessage} turns fields into bytes with a {@link Marshaller},
- * {@link CustomWireFormMessage} only reshapes its own fields. Everything that treats both the same way - the check
- * against {@link org.apache.ignite.plugin.extensions.communication.NonMarshallableMessage}, requiring the generated
- * marshaller to exist - refers to this interface.
+ * A {@link Message} with a marshalling step of its own, so its generated companion always has something to call.
+ * The step is either {@link MarshallableMessage} or {@link CustomWireFormMessage}; code that does not care which
+ * refers to this interface.
  */
 public interface CustomMarshallingMessage extends Message {
     // No-op.
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/CustomWireFormMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/CustomWireFormMessage.java
index 0ed63001d01..e2abc0ce410 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/CustomWireFormMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/CustomWireFormMessage.java
@@ -19,17 +19,15 @@ package org.apache.ignite.internal;
 
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.marshaller.Marshaller;
-import org.apache.ignite.plugin.extensions.communication.Message;
 
 /**
- * A {@link CustomMarshallingMessage} that converts its own fields to and from the form that goes on the wire: copying a value into the
- * field that is actually sent, packing bits, recalculating a TTL. Unlike {@link MarshallableMessage} it needs no {@link Marshaller}
- * to do that.
+ * A message that converts its own fields to and from the form that goes on the wire: copying a value into the field
+ * that is actually sent, packing bits, recalculating a TTL. Needs no {@link Marshaller} for that.
  */
 public interface CustomWireFormMessage extends CustomMarshallingMessage {
-    /** Converts the fields into the form that goes on the wire. Called before sending. */
+    /** Called before sending. */
     public void toWireForm() throws IgniteCheckedException;
 
-    /** Converts the fields back from the form they arrived in. Called after receiving. */
+    /** Called after receiving. */
     public void fromWireForm() throws IgniteCheckedException;
 }
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/MarshallableMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/MarshallableMessage.java
index 99ec4e25457..c8c95b8aae0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/MarshallableMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/MarshallableMessage.java
@@ -19,7 +19,6 @@ package org.apache.ignite.internal;
 
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.marshaller.Marshaller;
-import org.apache.ignite.plugin.extensions.communication.Message;
 
 /** A {@link CustomMarshallingMessage} whose step needs a {@link Marshaller}. */
 public interface MarshallableMessage extends CustomMarshallingMessage {
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImpl.java
index a44bbf2706e..57ff0bcaf7a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteMessageFactoryImpl.java
@@ -19,7 +19,7 @@ package org.apache.ignite.internal.managers.communication;
 
 import java.lang.reflect.Array;
 import org.apache.ignite.IgniteException;
-import org.apache.ignite.internal.MarshallableMessage;
+import org.apache.ignite.internal.CustomMarshallingMessage;
 import org.apache.ignite.internal.processors.cache.DeployableMessage;
 import org.apache.ignite.internal.processors.cache.GridCacheMessage;
 import org.apache.ignite.internal.processors.cache.GridCacheMessageDeployer;
@@ -92,8 +92,8 @@ public class IgniteMessageFactoryImpl<M extends Message, CM extends GridCacheMes
         try {
             Message msg = serializer.createMessage();
 
-            if (marshaller == null && msg instanceof MarshallableMessage) {
-                throw new IgniteException("Failed to register a message: it implements MarshallableMessage but no" +
+            if (marshaller == null && msg instanceof CustomMarshallingMessage) {
+                throw new IgniteException("Failed to register a message: it implements CustomMarshallingMessage but no" +
                     " marshaller is provided [directType=" + directType +
                     ", cls=" + msg.getClass().getName() + ']');
             }
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/plugin/AbstractMarshallableMessageFactoryProvider.java b/modules/core/src/main/java/org/apache/ignite/internal/plugin/AbstractMarshallableMessageFactoryProvider.java
index cc2f1b4bde0..83cd19578a4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/plugin/AbstractMarshallableMessageFactoryProvider.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/plugin/AbstractMarshallableMessageFactoryProvider.java
@@ -69,39 +69,32 @@ public abstract class AbstractMarshallableMessageFactoryProvider implements Mess
 
     /** */
     private static <T extends Message> void register(IgniteMessageFactory factory, Class<T> cls, short id, Marshaller marsh) {
-        MessageSerializer<T> serializer = loadGenerated(cls, "Serializer", null, true);
+        MessageSerializer<T> serializer = loadGenerated(cls, "Serializer", null);
 
-        // A CustomMarshallingMessage always gets a generated marshaller (its own step alone is a statement), so the
-        // absence of one is a build problem. For the rest the generator skips statement-free
-        // marshallers, so absence legitimately means "nothing to marshal"; the message and its companions ship in the
-        // same jar, hence a missing class cannot be a packaging accident that spares the (required) serializer.
         MessageMarshaller<T> marshaller = NonMarshallableMessage.class.isAssignableFrom(cls)
             ? null
-            : loadGenerated(cls, "Marshaller", marsh, CustomMarshallingMessage.class.isAssignableFrom(cls));
+            : loadGenerated(cls, "Marshaller", marsh);
 
-        // Deployers are generated for GridCacheMessage subclasses only, so the class lookup is skipped for the rest;
-        // a DeployableMessage left without a deployer is then rejected at registration.
+        // Deployers exist for GridCacheMessage only; a DeployableMessage left without one is rejected at registration.
         GridCacheMessageDeployer<?> deployer = GridCacheMessage.class.isAssignableFrom(cls)
-            ? loadGenerated(cls, "Deployer", null, false)
+            ? loadGenerated(cls, "Deployer", null)
             : null;
 
         factory.register(id, serializer, marshaller, deployer);
     }
 
     /**
-     * Instantiates the generated companion class {@code <message>Serializer/Marshaller/Deployer}. Only the marshaller
-     * companion ever takes a {@code Marshaller}, and only when the message has fields to marshal with one, so
-     * {@code marsh} is {@code null} for the other two. Constructor lookups, including missing companions, are cached
-     * per message class in {@link #COMPANIONS}.
+     * Instantiates the generated {@code <message>Serializer/Marshaller/Deployer}. Only the marshaller may take a
+     * {@code Marshaller}, so {@code marsh} is {@code null} for the other two. Lookups are cached in {@link #COMPANIONS}.
      *
-     * @return the companion, or {@code null} when it is not generated and {@code required} is {@code false}.
+     * @return the companion, or {@code null} when it is not generated and not required.
      */
     @SuppressWarnings("unchecked")
-    private static <T> @Nullable T loadGenerated(Class<?> cls, String suffix, @Nullable Marshaller marsh, boolean required) {
+    private static <T> @Nullable T loadGenerated(Class<?> cls, String suffix, @Nullable Marshaller marsh) {
         Constructor<?> ctor = COMPANIONS.get(cls).ctor(suffix);
 
         if (ctor == null) {
-            if (required) {
+            if (required(cls, suffix)) {
                 throw new IgniteException("No " + cls.getSimpleName() + suffix + " found for " + cls.getName() +
                     ". Either the class is not processed by codegen or the generated sources are stale," +
                     " try 'mvn clean install'.");
@@ -121,6 +114,18 @@ public abstract class AbstractMarshallableMessageFactoryProvider implements Mess
         }
     }
 
+    /**
+     * Every message gets a serializer, and a {@link CustomMarshallingMessage} always gets a marshaller, so a missing
+     * one means a broken build. The other companions are generated only when there is something to do, so their
+     * absence is normal.
+     *
+     * @return {@code true} if {@code cls} must have the {@code suffix} companion.
+     */
+    private static boolean required(Class<?> cls, String suffix) {
+        return "Serializer".equals(suffix)
+            || ("Marshaller".equals(suffix) && CustomMarshallingMessage.class.isAssignableFrom(cls));
+    }
+
     /** @return the sole public constructor of the generated companion {@code <message><suffix>}, or {@code null} when it does not exist. */
     private static @Nullable Constructor<?> companionCtor(Class<?> cls, String suffix) {
         try {
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java
index f7e8dca7b0d..a66c48fa5b0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java
@@ -25,7 +25,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.internal.util.typedef.internal.U;
-import org.apache.ignite.marshaller.Marshaller;
 import org.apache.ignite.plugin.extensions.communication.CacheIdAware;
 
 /**
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
index f1e8f1d4275..4e16d10e9e9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
@@ -40,7 +40,6 @@ import org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.marshaller.Marshaller;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
index 05796597d1c..f877b734f5a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
@@ -31,7 +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.F;
 import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.marshaller.Marshaller;
 import org.jetbrains.annotations.Nullable;
 
 /**
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java
index 2f5964237a1..947f479baa4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java
@@ -34,7 +34,6 @@ 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.IgniteUuid;
-import org.apache.ignite.marshaller.Marshaller;
 import org.jetbrains.annotations.Nullable;
 
 /**
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java
index 88f588e80c2..4956ac8fd0c 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java
@@ -35,8 +35,8 @@ import org.apache.ignite.cache.CacheMetrics;
 import org.apache.ignite.cluster.ClusterMetrics;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.internal.ClusterMetricsSnapshot;
-import org.apache.ignite.internal.IgniteNodeAttributes;
 import org.apache.ignite.internal.CustomWireFormMessage;
+import org.apache.ignite.internal.IgniteNodeAttributes;
 import org.apache.ignite.internal.Marshalled;
 import org.apache.ignite.internal.Order;
 import org.apache.ignite.internal.managers.discovery.IgniteClusterNode;
@@ -49,7 +49,6 @@ import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgnitePredicate;
 import org.apache.ignite.lang.IgniteProductVersion;
-import org.apache.ignite.marshaller.Marshaller;
 import org.apache.ignite.spi.discovery.DiscoveryMetricsProvider;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
 import org.jetbrains.annotations.Nullable;