Skip to content

Commit

Permalink
fix(h3): fix handler mistake
Browse files Browse the repository at this point in the history
  • Loading branch information
oxsean committed Apr 15, 2024
1 parent 5589f17 commit 30e4462
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 6 deletions.
8 changes: 8 additions & 0 deletions dubbo-distribution/dubbo-all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,14 @@
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</dependency>
<dependency>
<groupId>io.netty.incubator</groupId>
<artifactId>netty-incubator-codec-http3</artifactId>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public Object decode(InputStream is, Class<?> targetType, Charset charset) throw
public Object[] decode(InputStream is, Class<?>[] targetTypes, Charset charset) throws DecodeException {
try {
int len = targetTypes.length;
if (len == 0) {
return new Object[0];
}
Object obj = JsonUtils.toJavaObject(StreamUtils.toString(is, charset), Object.class);
if (obj instanceof List) {
List<?> list = (List<?>) obj;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ protected void doOpen() throws Throwable {
@Override
protected void initChannel(QuicChannel ch) {
ch.pipeline()
.addLast(nettyServerHandler)
.addLast(new IdleStateHandler(0, 0, idleTimeout, MILLISECONDS))
.addLast(new Http3ServerConnectionHandler(new ChannelInitializer<QuicStreamChannel>() {
@Override
protected void initChannel(QuicStreamChannel ch) {
ch.pipeline()
.addLast(nettyServerHandler)
.addLast(NettyHttp3FrameCodec.INSTANCE)
.addLast(new HttpWriteQueueHandler())
.addLast(new IdleStateHandler(0, 0, idleTimeout, MILLISECONDS))
.addLast(selectorHandler);
}
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.apache.dubbo.rpc.model.FrameworkModel;

import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.List;

import io.netty.channel.Channel;
Expand Down Expand Up @@ -62,7 +63,11 @@ public static String getRemoteAddressKey(Channel channel) {
return accessor.getProtocol() + ' ' + NetUtils.toAddressString(address);
}
}
return NetUtils.toAddressString((InetSocketAddress) channel.remoteAddress());
InetSocketAddress remoteAddress = (InetSocketAddress) channel.remoteAddress();
if (remoteAddress == null) {
return "UNKNOWN";
}
return NetUtils.toAddressString(remoteAddress);
}

public static String getLocalAddressKey(Channel channel) {
Expand All @@ -74,6 +79,10 @@ public static String getLocalAddressKey(Channel channel) {
return accessor.getProtocol() + ' ' + NetUtils.toAddressString(address);
}
}
return NetUtils.toAddressString((InetSocketAddress) channel.localAddress());
SocketAddress localAddress = channel.localAddress();
if (localAddress == null) {
return "UNKNOWN";
}
return NetUtils.toAddressString((InetSocketAddress) localAddress);
}
}
5 changes: 4 additions & 1 deletion dubbo-rpc/dubbo-rpc-triple/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@
<dependency>
<groupId>io.netty.incubator</groupId>
<artifactId>netty-incubator-codec-http3</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
import org.apache.dubbo.rpc.protocol.tri.stream.ClientStream;
import org.apache.dubbo.rpc.protocol.tri.stream.TripleStreamChannelFuture;
import org.apache.dubbo.rpc.protocol.tri.transport.TripleCommandOutBoundHandler;
import org.apache.dubbo.rpc.protocol.tri.transport.TripleGoAwayHandler;
import org.apache.dubbo.rpc.protocol.tri.transport.TripleHttp2ClientResponseHandler;
import org.apache.dubbo.rpc.protocol.tri.transport.TripleTailHandler;
import org.apache.dubbo.rpc.protocol.tri.transport.TripleWriteQueue;

import java.util.concurrent.Executor;
Expand Down Expand Up @@ -63,7 +65,9 @@ protected void initRequestStream(QuicStreamChannel ch) {
ch.pipeline()
.addLast(Http3ClientFrameCodec.INSTANCE)
.addLast(new TripleCommandOutBoundHandler())
.addLast(new TripleHttp2ClientResponseHandler(createTransportListener()));
.addLast(new TripleHttp2ClientResponseHandler(createTransportListener()))
.addLast(new TripleGoAwayHandler())
.addLast(new TripleTailHandler());
}
};
TripleStreamChannelFuture future = new TripleStreamChannelFuture(parent);
Expand Down

0 comments on commit 30e4462

Please sign in to comment.