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

pandalee pushed a commit to branch releases-0.10
in repository https://gitbox.apache.org/repos/asf/fury.git


The following commit(s) were added to refs/heads/releases-0.10 by this push:
     new 122eb2d9 fix(java): fix nested chunk map serialization error when 
generics exists (#2162)
122eb2d9 is described below

commit 122eb2d991cbe467509198f7ea50b8376b153939
Author: Shawn Yang <[email protected]>
AuthorDate: Sat Apr 19 16:15:32 2025 +0800

    fix(java): fix nested chunk map serialization error when generics exists 
(#2162)
    
    <!--
    **Thanks for contributing to Fury.**
    
    **If this is your first time opening a PR on fury, you can refer to
    
[CONTRIBUTING.md](https://github.com/apache/fury/blob/main/CONTRIBUTING.md).**
    
    Contribution Checklist
    
    - The **Apache Fury (incubating)** community has restrictions on the
    naming of pr titles. You can also find instructions in
    [CONTRIBUTING.md](https://github.com/apache/fury/blob/main/CONTRIBUTING.md).
    
    - Fury has a strong focus on performance. If the PR you submit will have
    an impact on performance, please benchmark it first and provide the
    benchmark result here.
    -->
    
    ## What does this PR do?
    
    <!-- Describe the purpose of this PR. -->
    
    ## Related issues
    
    #2136
    
    ## 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.
    -->
---
 .../fury/serializer/collection/AbstractMapSerializer.java  |  3 +++
 .../fury/serializer/collection/MapSerializersTest.java     | 14 ++++++++++++++
 2 files changed, 17 insertions(+)

diff --git 
a/java/fury-core/src/main/java/org/apache/fury/serializer/collection/AbstractMapSerializer.java
 
b/java/fury-core/src/main/java/org/apache/fury/serializer/collection/AbstractMapSerializer.java
index d9741139..da8f7a3d 100644
--- 
a/java/fury-core/src/main/java/org/apache/fury/serializer/collection/AbstractMapSerializer.java
+++ 
b/java/fury-core/src/main/java/org/apache/fury/serializer/collection/AbstractMapSerializer.java
@@ -767,9 +767,12 @@ public abstract class AbstractMapSerializer<T> extends 
Serializer<T> {
           classResolver.readClassInfo(buffer, 
valueClassInfoReadCache).getSerializer();
     }
     for (int i = 0; i < chunkSize; i++) {
+      // increase depth to avoid read wrong outer generic type
+      fury.incDepth(1);
       Object key = trackKeyRef ? fury.readRef(buffer, keySerializer) : 
keySerializer.read(buffer);
       Object value =
           trackValueRef ? fury.readRef(buffer, valueSerializer) : 
valueSerializer.read(buffer);
+      fury.incDepth(-1);
       map.put(key, value);
       size--;
     }
diff --git 
a/java/fury-core/src/test/java/org/apache/fury/serializer/collection/MapSerializersTest.java
 
b/java/fury-core/src/test/java/org/apache/fury/serializer/collection/MapSerializersTest.java
index a7cd8965..f05de4e7 100644
--- 
a/java/fury-core/src/test/java/org/apache/fury/serializer/collection/MapSerializersTest.java
+++ 
b/java/fury-core/src/test/java/org/apache/fury/serializer/collection/MapSerializersTest.java
@@ -990,4 +990,18 @@ public class MapSerializersTest extends FuryTestBase {
     o.map2 = ofArrayList(ofHashMap("k2", "2"));
     serDeCheck(fury, o);
   }
+
+  @Data
+  public static class NestedMapCollectionGenericTestClass {
+    public Map<String, Object> map = new HashMap<>();
+  }
+
+  @Test(dataProvider = "enableCodegen")
+  public void testNestedMapCollectionGeneric(boolean enableCodegen) {
+    NestedMapCollectionGenericTestClass obj = new 
NestedMapCollectionGenericTestClass();
+    obj.map = new LinkedHashMap<>();
+    obj.map.put("obj", ofHashMap("obj", 1, "b", ofArrayList(10)));
+    Fury fury = 
Fury.builder().requireClassRegistration(false).withCodegen(enableCodegen).build();
+    fury.deserialize(fury.serialize(obj));
+  }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to