This is an automated email from the ASF dual-hosted git repository.
earthchen 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 b831c26e83 Use releaseOnClose to release the ByteBuf when the output
stream is closed (#14263)
b831c26e83 is described below
commit b831c26e83040a5008765b927d85593c0a498cf4
Author: TomlongTK <[email protected]>
AuthorDate: Fri May 31 16:11:25 2024 +0800
Use releaseOnClose to release the ByteBuf when the output stream is closed
(#14263)
---
.../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, 2 insertions(+), 24 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 dd8844162b..2406b8249c 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,11 +18,8 @@ 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;
@@ -35,12 +32,4 @@ 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 d3ba8ce66d..15c87eb413 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,11 +16,8 @@
*/
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;
@@ -45,14 +42,6 @@ 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 443bd21aec..29ef06a08d 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()));
+ return new Http1OutputMessage(new
ByteBufOutputStream(channel.alloc().buffer(), true));
}
@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 f85b127634..ade163606a 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);
+ ByteBufOutputStream outputStream = new ByteBufOutputStream(buffer,
true);
return new Http2OutputMessageFrame(outputStream, endStream);
}