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

alexpl 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 c56d5328aa0 IGNITE-24447 Java thin client: Fix binary meta sending on 
reconnect - Fixes #11861.
c56d5328aa0 is described below

commit c56d5328aa0c205d149c22fab24445936dfcca46
Author: Aleksey Plekhanov <[email protected]>
AuthorDate: Tue Feb 11 16:02:35 2025 +0300

    IGNITE-24447 Java thin client: Fix binary meta sending on reconnect - Fixes 
#11861.
    
    Signed-off-by: Aleksey Plekhanov <[email protected]>
---
 .../internal/client/thin/TcpIgniteClient.java      |  1 +
 .../org/apache/ignite/client/IgniteBinaryTest.java | 59 +++++++++++++++++++++-
 .../apache/ignite/client/PersonBinarylizable.java  |  5 ++
 3 files changed, 63 insertions(+), 2 deletions(-)

diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpIgniteClient.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpIgniteClient.java
index f0c26f5dc13..b7d2442bb7a 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpIgniteClient.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpIgniteClient.java
@@ -164,6 +164,7 @@ public class TcpIgniteClient implements IgniteClient {
                 metadataHnd.onReconnect();
                 marshCtx.clearUserTypesCache();
                 marsh.context().unregisterUserTypeDescriptors();
+                marsh.context().unregisterBinarySchemas();
             });
 
             // Send postponed metadata after channel init.
diff --git 
a/modules/core/src/test/java/org/apache/ignite/client/IgniteBinaryTest.java 
b/modules/core/src/test/java/org/apache/ignite/client/IgniteBinaryTest.java
index 6e019c86d5e..016adee55bc 100644
--- a/modules/core/src/test/java/org/apache/ignite/client/IgniteBinaryTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/client/IgniteBinaryTest.java
@@ -17,12 +17,17 @@
 
 package org.apache.ignite.client;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.List;
 import java.util.Map;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 import javax.cache.Cache;
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.MutableEntry;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteBinary;
 import org.apache.ignite.IgniteCache;
@@ -45,6 +50,7 @@ import org.apache.ignite.internal.binary.BinaryObjectImpl;
 import org.apache.ignite.internal.binary.GridBinaryMarshaller;
 import org.apache.ignite.internal.processors.odbc.ClientListenerProcessor;
 import org.apache.ignite.internal.util.typedef.X;
+import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.mxbean.ClientProcessorMXBean;
 import org.apache.ignite.testframework.ListeningTestLogger;
 import org.apache.ignite.testframework.LogListener;
@@ -52,8 +58,6 @@ import 
org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 import org.junit.Test;
 
 import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
 
 /**
  * Ignite {@link BinaryObject} API system tests.
@@ -426,6 +430,49 @@ public class IgniteBinaryTest extends 
GridCommonAbstractTest {
         }
     }
 
+    /** */
+    @Test
+    public void testBinaryMetaSendAfterServerRestart() {
+        String name = "name";
+
+        List<Function<String, Object>> factories = new ArrayList<>();
+        factories.add(n -> new Person(0, n));
+        factories.add(PersonBinarylizable::new);
+
+        for (Function<String, Object> factory : factories) {
+            Ignite ignite = null;
+            IgniteClient client = null;
+
+            try {
+                ignite = Ignition.start(Config.getServerConfiguration());
+                client = Ignition.startClient(new 
ClientConfiguration().setAddresses(Config.SERVER));
+
+                ClientCache<Integer, Object> cache = 
client.getOrCreateCache(DEFAULT_CACHE_NAME);
+
+                Object person = factory.apply(name);
+
+                log.info(">>>> Check object class: " + 
person.getClass().getSimpleName());
+
+                cache.put(0, person);
+
+                ignite.close();
+
+                ignite = Ignition.start(Config.getServerConfiguration());
+
+                cache = client.getOrCreateCache(DEFAULT_CACHE_NAME);
+
+                cache.put(0, person);
+
+                // Perform any action on server-side with binary object to 
ensure binary meta exists on node.
+                assertEquals(name, cache.invoke(0, new 
ExtractNameEntryProcessor()));
+            }
+            finally {
+                U.close(client, log);
+                U.close(ignite, log);
+            }
+        }
+    }
+
     /** */
     private void assertBinaryTypesEqual(BinaryType exp, BinaryType actual) {
         assertEquals(exp.typeId(), actual.typeId());
@@ -463,4 +510,12 @@ public class IgniteBinaryTest extends 
GridCommonAbstractTest {
         /** Default. */
         DEFAULT
     }
+
+    /** */
+    private static class ExtractNameEntryProcessor implements 
EntryProcessor<Integer, Object, String> {
+        /** {@inheritDoc} */
+        @Override public String process(MutableEntry<Integer, Object> entry, 
Object... arguments) {
+            return ((BinaryObject)entry.getValue()).field("name").toString();
+        }
+    }
 }
diff --git 
a/modules/core/src/test/java/org/apache/ignite/client/PersonBinarylizable.java 
b/modules/core/src/test/java/org/apache/ignite/client/PersonBinarylizable.java
index 28918b238e2..94dd411fe58 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/client/PersonBinarylizable.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/client/PersonBinarylizable.java
@@ -40,6 +40,11 @@ public class PersonBinarylizable implements Binarylizable {
     /** */
     private boolean readWaits;
 
+    /** */
+    public PersonBinarylizable(String name) {
+        this(name, false, false, false);
+    }
+
     /** */
     public PersonBinarylizable(String name, boolean writeThrows, boolean 
readThrows, boolean readWaits) {
         this.name = name;

Reply via email to