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

albumenj pushed a commit to branch 3.3
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/3.3 by this push:
     new 64264f6c46 Revert "Use releaseOnClose to release the ByteBuf when the 
output stream is c…" (#14294)
64264f6c46 is described below

commit 64264f6c46d0135a76e892723025563baa6bb036
Author: TomlongTK <[email protected]>
AuthorDate: Thu Jun 6 20:03:55 2024 +0800

    Revert "Use releaseOnClose to release the ByteBuf when the output stream is 
c…" (#14294)
    
    This reverts commit b831c26e83040a5008765b927d85593c0a498cf4.
---
 .../apache/dubbo/remoting/http12/h1/Http1OutputMessage.java   | 11 +++++++++++
 .../dubbo/remoting/http12/h2/Http2OutputMessageFrame.java     | 11 +++++++++++
 .../dubbo/remoting/http12/netty4/h1/NettyHttp1Channel.java    |  2 +-
 .../dubbo/remoting/http12/netty4/h2/NettyH2StreamChannel.java |  2 +-
 4 files changed, 24 insertions(+), 2 deletions(-)

diff --git 
a/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/h1/Http1OutputMessage.java
 
b/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/h1/Http1OutputMessage.java
index 2406b8249c..dd8844162b 100644
--- 
a/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/h1/Http1OutputMessage.java
+++ 
b/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/h1/Http1OutputMessage.java
@@ -18,8 +18,11 @@ package org.apache.dubbo.remoting.http12.h1;
 
 import org.apache.dubbo.remoting.http12.HttpOutputMessage;
 
+import java.io.IOException;
 import java.io.OutputStream;
 
+import io.netty.buffer.ByteBufOutputStream;
+
 public class Http1OutputMessage implements HttpOutputMessage {
 
     private final OutputStream outputStream;
@@ -32,4 +35,12 @@ public class Http1OutputMessage implements HttpOutputMessage 
{
     public OutputStream getBody() {
         return outputStream;
     }
+
+    @Override
+    public void close() throws IOException {
+        if (outputStream instanceof ByteBufOutputStream) {
+            ((ByteBufOutputStream) outputStream).buffer().release();
+        }
+        outputStream.close();
+    }
 }
diff --git 
a/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/h2/Http2OutputMessageFrame.java
 
b/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/h2/Http2OutputMessageFrame.java
index 15c87eb413..d3ba8ce66d 100644
--- 
a/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/h2/Http2OutputMessageFrame.java
+++ 
b/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/h2/Http2OutputMessageFrame.java
@@ -16,8 +16,11 @@
  */
 package org.apache.dubbo.remoting.http12.h2;
 
+import java.io.IOException;
 import java.io.OutputStream;
 
+import io.netty.buffer.ByteBufOutputStream;
+
 public class Http2OutputMessageFrame implements Http2OutputMessage {
 
     private final OutputStream body;
@@ -42,6 +45,14 @@ public class Http2OutputMessageFrame implements 
Http2OutputMessage {
         return body;
     }
 
+    @Override
+    public void close() throws IOException {
+        if (body instanceof ByteBufOutputStream) {
+            ((ByteBufOutputStream) body).buffer().release();
+        }
+        body.close();
+    }
+
     @Override
     public boolean isEndStream() {
         return endStream;
diff --git 
a/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/netty4/h1/NettyHttp1Channel.java
 
b/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/netty4/h1/NettyHttp1Channel.java
index 29ef06a08d..443bd21aec 100644
--- 
a/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/netty4/h1/NettyHttp1Channel.java
+++ 
b/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/netty4/h1/NettyHttp1Channel.java
@@ -52,7 +52,7 @@ public class NettyHttp1Channel implements HttpChannel {
 
     @Override
     public HttpOutputMessage newOutputMessage() {
-        return new Http1OutputMessage(new 
ByteBufOutputStream(channel.alloc().buffer(), true));
+        return new Http1OutputMessage(new 
ByteBufOutputStream(channel.alloc().buffer()));
     }
 
     @Override
diff --git 
a/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/netty4/h2/NettyH2StreamChannel.java
 
b/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/netty4/h2/NettyH2StreamChannel.java
index ade163606a..f85b127634 100644
--- 
a/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/netty4/h2/NettyH2StreamChannel.java
+++ 
b/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/netty4/h2/NettyH2StreamChannel.java
@@ -57,7 +57,7 @@ public class NettyH2StreamChannel implements H2StreamChannel {
     @Override
     public Http2OutputMessage newOutputMessage(boolean endStream) {
         ByteBuf buffer = http2StreamChannel.alloc().buffer();
-        ByteBufOutputStream outputStream = new ByteBufOutputStream(buffer, 
true);
+        ByteBufOutputStream outputStream = new ByteBufOutputStream(buffer);
         return new Http2OutputMessageFrame(outputStream, endStream);
     }
 

Reply via email to