This is an automated email from the ASF dual-hosted git repository.
hefengen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 7f34b57e25 [type: performance] Implement zero-copy in TCP plugin
(#5066)
7f34b57e25 is described below
commit 7f34b57e2538c324afedea44d16b4a636a16892e
Author: 吴伟杰 <[email protected]>
AuthorDate: Thu Aug 24 19:06:41 2023 +0800
[type: performance] Implement zero-copy in TCP plugin (#5066)
Co-authored-by: moremind <[email protected]>
---
.../apache/shenyu/protocol/tcp/connection/TcpConnectionBridge.java | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git
a/shenyu-protocol/shenyu-protocol-tcp/src/main/java/org/apache/shenyu/protocol/tcp/connection/TcpConnectionBridge.java
b/shenyu-protocol/shenyu-protocol-tcp/src/main/java/org/apache/shenyu/protocol/tcp/connection/TcpConnectionBridge.java
index 66945e9daf..2f1de6985b 100644
---
a/shenyu-protocol/shenyu-protocol-tcp/src/main/java/org/apache/shenyu/protocol/tcp/connection/TcpConnectionBridge.java
+++
b/shenyu-protocol/shenyu-protocol-tcp/src/main/java/org/apache/shenyu/protocol/tcp/connection/TcpConnectionBridge.java
@@ -21,8 +21,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import reactor.core.Disposable;
import reactor.core.Disposables;
-import reactor.core.publisher.Flux;
-import reactor.core.publisher.Mono;
import reactor.netty.Connection;
import reactor.netty.NettyInbound;
import reactor.netty.NettyOutbound;
@@ -46,8 +44,7 @@ public class TcpConnectionBridge implements Bridge {
}
private Disposable bridge(final NettyInbound inbound, final NettyOutbound
outbound) {
- Flux<byte[]> flux = inbound.receive().asByteArray();
- return flux.concatMap(next ->
outbound.sendByteArray(Mono.just(next))).subscribe();
+ return outbound.send(inbound.receive().retain()).then().subscribe();
}
}