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 e2ca88e5 fix(java): fix nested chunk map serialization error when
generics exists (#2136)
e2ca88e5 is described below
commit e2ca88e5f4e078758c89334efaee41b2b87a0252
Author: Shawn Yang <[email protected]>
AuthorDate: Tue Apr 1 22:49:47 2025 +0800
fix(java): fix nested chunk map serialization error when generics exists
(#2136)
## What does this PR do?
fix nested chunk map serialization error when generics exists
## Related issues
Closes #2135
## 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 0e39420f..f392fe3a 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
@@ -769,6 +769,8 @@ public abstract class AbstractMapSerializer<T> extends
Serializer<T> {
}
} else {
for (int i = 0; i < chunkSize; i++) {
+ // increase depth to avoid read wrong outer generic type
+ fury.incDepth(1);
Object key =
trackKeyRef
? binding.readRef(buffer, keySerializer)
@@ -777,6 +779,7 @@ public abstract class AbstractMapSerializer<T> extends
Serializer<T> {
trackValueRef
? binding.readRef(buffer, valueSerializer)
: binding.read(buffer, valueSerializer);
+ 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]