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

chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fury.git


The following commit(s) were added to refs/heads/main by this push:
     new 8bbd35ef fix(java): fix serializer factory getSerializerClass (#1836)
8bbd35ef is described below

commit 8bbd35effac7e864bb7aa8fc7d61fc35699db2dd
Author: Shawn Yang <shawn.ck.y...@gmail.com>
AuthorDate: Thu Sep 12 14:33:35 2024 +0800

    fix(java): fix serializer factory getSerializerClass (#1836)
    
    ## What does this PR do?
    fix serializer factory getSerializerClass
    <!-- Describe the purpose of this PR. -->
    
    ## Related issues
    
    <!--
    Is there any related issue? Please attach here.
    
    - #xxxx0
    - #xxxx1
    - #xxxx2
    -->
    
    ## Does this PR introduce any user-facing change?
    
    <!--
    If any user-facing interface changes, please [open an
    issue](https://github.com/apache/fury/issues/new/choose) describing the
    need to do so and update the document if necessary.
    -->
    
    - [ ] Does this PR introduce any public API change?
    - [ ] Does this PR introduce any binary protocol compatibility change?
    
    ## Benchmark
    
    <!--
    When the PR has an impact on performance (if you don't know whether the
    PR will have an impact on performance, you can submit the PR first, and
    if it will have impact on performance, the code reviewer will explain
    it), be sure to attach a benchmark data here.
    -->
---
 .../src/main/java/org/apache/fury/resolver/ClassResolver.java       | 6 ++++++
 .../test/java/org/apache/fury/serializer/SerializerFactoryTest.java | 1 +
 2 files changed, 7 insertions(+)

diff --git 
a/java/fury-core/src/main/java/org/apache/fury/resolver/ClassResolver.java 
b/java/fury-core/src/main/java/org/apache/fury/resolver/ClassResolver.java
index 3160850c..8ee93a38 100644
--- a/java/fury-core/src/main/java/org/apache/fury/resolver/ClassResolver.java
+++ b/java/fury-core/src/main/java/org/apache/fury/resolver/ClassResolver.java
@@ -824,6 +824,12 @@ public class ClassResolver {
       // serialized, which will create a class info with serializer null, see 
`#writeClassInternal`
       return classInfo.serializer.getClass();
     } else {
+      if (getSerializerFactory() != null) {
+        Serializer serializer = getSerializerFactory().createSerializer(fury, 
cls);
+        if (serializer != null) {
+          return serializer.getClass();
+        }
+      }
       if (NonexistentClass.isNonexistent(cls)) {
         return NonexistentClassSerializers.getSerializer(fury, "Unknown", 
cls).getClass();
       }
diff --git 
a/java/fury-core/src/test/java/org/apache/fury/serializer/SerializerFactoryTest.java
 
b/java/fury-core/src/test/java/org/apache/fury/serializer/SerializerFactoryTest.java
index 83bfdd3f..154d70d0 100644
--- 
a/java/fury-core/src/test/java/org/apache/fury/serializer/SerializerFactoryTest.java
+++ 
b/java/fury-core/src/test/java/org/apache/fury/serializer/SerializerFactoryTest.java
@@ -93,6 +93,7 @@ public class SerializerFactoryTest {
             return null;
           }
         });
+    Assert.assertEquals(fury.getClassResolver().getSerializerClass(A.class), 
KryoSerializer.class);
     A a = new A();
     a.f1 = "f1";
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@fury.apache.org
For additional commands, e-mail: commits-h...@fury.apache.org

Reply via email to