This is an automated email from the ASF dual-hosted git repository.
eolivelli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/master by this push:
new 1cbde1a31c Fix the tls failed test (#3448)
1cbde1a31c is described below
commit 1cbde1a31cde56383ed28967f3d10f607eec36d0
Author: Yong Zhang <[email protected]>
AuthorDate: Thu Aug 18 19:34:48 2022 +0800
Fix the tls failed test (#3448)
---
*Motivation*
When runing the tls test, the remote address is a LocalAddress,
but we cast it to the `InetSocketAddress`. That cause the test
`testConnectToLocalTLSClusterTLSClient` failed.
---
.../apache/bookkeeper/proto/PerChannelBookieClient.java | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java
index ac2ee41d2d..62a28c4a4b 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java
@@ -1500,7 +1500,19 @@ public class PerChannelBookieClient extends
ChannelInboundHandlerAdapter {
void initTLSHandshake() {
// create TLS handler
PerChannelBookieClient parentObj = PerChannelBookieClient.this;
- InetSocketAddress address = (InetSocketAddress)
channel.remoteAddress();
+ SocketAddress socketAddress = channel.remoteAddress();
+ InetSocketAddress address;
+ if (socketAddress instanceof LocalAddress) {
+ // if it is a local address, it looks like this:
local:hostname:port
+ String[] addr = socketAddress.toString().split(":");
+ String hostname = addr[1];
+ int port = Integer.parseInt(addr[2]);
+ address = new InetSocketAddress(hostname, port);
+ } else if (socketAddress instanceof InetSocketAddress) {
+ address = (InetSocketAddress) socketAddress;
+ } else {
+ throw new RuntimeException("Unexpected socket address type");
+ }
SslHandler handler =
parentObj.shFactory.newTLSHandler(address.getHostName(), address.getPort());
channel.pipeline().addFirst(parentObj.shFactory.getHandlerName(),
handler);
handler.handshakeFuture().addListener(new
GenericFutureListener<Future<Channel>>() {