shishkovilja commented on code in PR #13344:
URL: https://github.com/apache/ignite/pull/13344#discussion_r3603546921


##########
modules/core/src/test/java/org/apache/ignite/internal/processors/service/LazyServiceConfigurationMessageSerializationTest.java:
##########
@@ -0,0 +1,181 @@
+/*
+ * 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.processors.service;
+
+import java.io.Externalizable;
+import java.io.Serializable;
+import java.lang.reflect.Modifier;
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import org.apache.ignite.internal.CoreMessagesProvider;
+import org.apache.ignite.internal.direct.DirectMessageReader;
+import org.apache.ignite.internal.direct.DirectMessageWriter;
+import 
org.apache.ignite.internal.managers.communication.IgniteMessageFactoryImpl;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.plugin.extensions.communication.Message;
+import org.apache.ignite.plugin.extensions.communication.MessageFactory;
+import 
org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider;
+import org.apache.ignite.plugin.extensions.communication.MessageSerializer;
+import org.apache.ignite.services.ServiceConfiguration;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+import static org.apache.ignite.internal.util.CommonUtils.makeMessageType;
+import static org.apache.ignite.marshaller.Marshallers.jdk;
+import static org.junit.Assert.assertArrayEquals;
+
+/** Test for serialization round-trip of {@link 
LazyServiceConfigurationMessage}. */
+public class LazyServiceConfigurationMessageSerializationTest extends 
GridCommonAbstractTest {
+    /** Error suffix. */
+    public static final String ERROR_SUFFIX = " count is not equal to the 
expected fields count. " +
+        "Has the number of fields in the `LazyServiceConfiguration` class 
changed?";
+
+    /** */
+    private final Marshaller marsh = jdk();
+
+    /** */
+    private final MessageFactory msgFactory = new IgniteMessageFactoryImpl(
+        new MessageFactoryProvider[] {new CoreMessagesProvider(marsh, marsh, 
U.gridClassLoader())});
+
+    /**
+     * LazyServiceConfiguration marks {@code svc}, {@code nodeFilter}, {@code 
interceptors} as transient,
+     * so they are not serialized via MessageSerializer (replaced by byte[] 
counterparts).
+     */
+    private static final long TRANSIENT_FIELD_PENALTY = 3;

Review Comment:
   In fact it is not true, transient fields are filtered, see list from debug:
   ```
   0 = {Field@3671} "protected java.lang.String 
org.apache.ignite.services.ServiceConfiguration.name"
   1 = {Field@3672} "private org.apache.ignite.services.Service 
org.apache.ignite.services.ServiceConfiguration.svc"
   2 = {Field@3673} "protected int 
org.apache.ignite.services.ServiceConfiguration.totalCnt"
   3 = {Field@3674} "protected int 
org.apache.ignite.services.ServiceConfiguration.maxPerNodeCnt"
   4 = {Field@3675} "protected java.lang.String 
org.apache.ignite.services.ServiceConfiguration.cacheName"
   5 = {Field@3676} "protected java.lang.Object 
org.apache.ignite.services.ServiceConfiguration.affKey"
   6 = {Field@3677} "protected org.apache.ignite.lang.IgnitePredicate 
org.apache.ignite.services.ServiceConfiguration.nodeFilter"
   7 = {Field@3678} "protected boolean 
org.apache.ignite.services.ServiceConfiguration.isStatisticsEnabled"
   8 = {Field@3679} "protected 
org.apache.ignite.services.ServiceCallInterceptor[] 
org.apache.ignite.services.ServiceConfiguration.interceptors"
   9 = {Field@3680} "protected int 
org.apache.ignite.services.ServiceConfiguration.locStartOrder"
   10 = {Field@3681} "private java.lang.String 
org.apache.ignite.internal.processors.service.LazyServiceConfiguration.srvcClsName"
   11 = {Field@3682} "private byte[] 
org.apache.ignite.internal.processors.service.LazyServiceConfiguration.srvcBytes"
   12 = {Field@3683} "private byte[] 
org.apache.ignite.internal.processors.service.LazyServiceConfiguration.nodeFilterBytes"
   13 = {Field@3684} "private byte[] 
org.apache.ignite.internal.processors.service.LazyServiceConfiguration.interceptorsBytes"
   14 = {Field@3685} "private java.lang.String[] 
org.apache.ignite.internal.processors.service.LazyServiceConfiguration.platformMtdNames"
   ```
   ----
   As I see, divergency of count is caused by fields below 
(`LazyServiceConfiguration` duplicates some of them):
   - `ServiceConfiguration#svc`
   - `ServiceConfiguration#interceptors`
   - `ServiceConfiguration#nodeFilter`



-- 
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