You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by zr...@apache.org on 2025/09/28 03:50:40 UTC
(dubbo-hessian-lite) branch master updated: Fix reference handling in InetSocketAddress deserialization (#100)
This is an automated email from the ASF dual-hosted git repository.
zrlw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-hessian-lite.git
The following commit(s) were added to refs/heads/master by this push:
new 1b839565 Fix reference handling in InetSocketAddress deserialization (#100)
1b839565 is described below
commit 1b8395658149eb1e79a4d0f680706cbd4ff609c6
Author: wuwen <wu...@aliyun.com>
AuthorDate: Sun Sep 28 11:50:36 2025 +0800
Fix reference handling in InetSocketAddress deserialization (#100)
---
.../hessian/io/socket/InetSocketAddressDeserializer.java | 6 ++++--
.../com/caucho/hessian/io/socket/InetSocketAddressTest.java | 10 +++++++++-
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/socket/InetSocketAddressDeserializer.java b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/socket/InetSocketAddressDeserializer.java
index 681983eb..a93a2ca3 100644
--- a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/socket/InetSocketAddressDeserializer.java
+++ b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/socket/InetSocketAddressDeserializer.java
@@ -49,6 +49,9 @@ public class InetSocketAddressDeserializer extends AbstractDeserializer {
String[] fieldNames)
throws IOException {
try {
+
+ int ref = in.addRef(null);
+
String hostName = null;
InetAddress address = null;
int port = 0;
@@ -73,8 +76,7 @@ public class InetSocketAddressDeserializer extends AbstractDeserializer {
obj = new InetSocketAddress(port);
}
- in.addRef(obj);
-
+ in.setRef(ref, obj);
return obj;
} catch (IOException e) {
throw e;
diff --git a/java-8-test/src/test/java/com/alibaba/com/caucho/hessian/io/socket/InetSocketAddressTest.java b/java-8-test/src/test/java/com/alibaba/com/caucho/hessian/io/socket/InetSocketAddressTest.java
index e86f042f..8e9b1c5b 100644
--- a/java-8-test/src/test/java/com/alibaba/com/caucho/hessian/io/socket/InetSocketAddressTest.java
+++ b/java-8-test/src/test/java/com/alibaba/com/caucho/hessian/io/socket/InetSocketAddressTest.java
@@ -23,10 +23,11 @@ import org.junit.jupiter.api.condition.EnabledForJreRange;
import org.junit.jupiter.api.condition.JRE;
import java.io.IOException;
-import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.InetSocketAddress;
+import java.util.ArrayList;
+import java.util.List;
public class InetSocketAddressTest extends SerializeTestBase {
@Test
@@ -89,4 +90,11 @@ public class InetSocketAddressTest extends SerializeTestBase {
InetSocketAddress inetSocketAddress = new InetSocketAddress("localhost", 8080);
Assertions.assertEquals(inetSocketAddress, baseHessian2Serialize(inetSocketAddress));
}
+
+ @Test
+ void testCollectionRef() throws IOException {
+ InetSocketAddress inetSocketAddress = new InetSocketAddress("localhost", 8080);
+ List<Object> list = new ArrayList<>();
+ testCollection(list, inetSocketAddress);
+ }
}