RainYuY commented on code in PR #15616:
URL: https://github.com/apache/dubbo/pull/15616#discussion_r2269285418


##########
dubbo-serialization/dubbo-serialization-hessian2/src/main/java/org/apache/dubbo/common/serialize/hessian2/Hessian2Serialization.java:
##########
@@ -83,4 +83,71 @@ public ObjectInput deserialize(URL url, InputStream is) 
throws IOException {
                 .getBean(Hessian2FactoryManager.class);
         return new Hessian2ObjectInput(is, hessian2FactoryManager);
     }
+
+    @Override
+    public void serializeZeroCopy(URL url, Class<?> clz, Object obj, 
OutputStream outputStream) throws IOException {
+        Hessian2FactoryManager hessian2FactoryManager = 
Optional.ofNullable(url)
+                .map(URL::getOrDefaultFrameworkModel)
+                .orElseGet(FrameworkModel::defaultModel)
+                .getBeanFactory()
+                .getBean(Hessian2FactoryManager.class);
+
+        // Check if we're in streaming mode (used with StreamingLengthEncoder)
+        boolean isStreamingMode = isStreamingMode(url);
+
+        // Use Hessian2Output directly for zero-copy serialization
+        com.alibaba.com.caucho.hessian.io.Hessian2Output hessianOutput =
+                new 
com.alibaba.com.caucho.hessian.io.Hessian2Output(outputStream);
+        
hessianOutput.setSerializerFactory(hessian2FactoryManager.getSerializerFactory(
+                Thread.currentThread().getContextClassLoader()));
+
+        try {
+            if (isStreamingMode) {

Review Comment:
   It looks like the same code is in both the if and else branches. Why?



##########
dubbo-serialization/dubbo-serialization-hessian2/src/main/java/org/apache/dubbo/common/serialize/hessian2/Hessian2Serialization.java:
##########
@@ -83,4 +83,71 @@ public ObjectInput deserialize(URL url, InputStream is) 
throws IOException {
                 .getBean(Hessian2FactoryManager.class);
         return new Hessian2ObjectInput(is, hessian2FactoryManager);
     }
+
+    @Override
+    public void serializeZeroCopy(URL url, Class<?> clz, Object obj, 
OutputStream outputStream) throws IOException {
+        Hessian2FactoryManager hessian2FactoryManager = 
Optional.ofNullable(url)
+                .map(URL::getOrDefaultFrameworkModel)
+                .orElseGet(FrameworkModel::defaultModel)
+                .getBeanFactory()
+                .getBean(Hessian2FactoryManager.class);
+
+        // Check if we're in streaming mode (used with StreamingLengthEncoder)
+        boolean isStreamingMode = isStreamingMode(url);
+
+        // Use Hessian2Output directly for zero-copy serialization
+        com.alibaba.com.caucho.hessian.io.Hessian2Output hessianOutput =

Review Comment:
   Why is there not 
org.apache.dubbo.common.serialize.hessian2.Hessian2ObjectOutput?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to