You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by yo...@apache.org on 2022/08/19 00:49:00 UTC
[bookkeeper] branch branch-4.14 updated: Fix the tls failed test (#3448)
This is an automated email from the ASF dual-hosted git repository.
yong pushed a commit to branch branch-4.14
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/branch-4.14 by this push:
new 8341dad2c0 Fix the tls failed test (#3448)
8341dad2c0 is described below
commit 8341dad2c0553c7a456a1d48eda23a309813afc8
Author: Yong Zhang <zh...@gmail.com>
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.
(cherry picked from commit 1cbde1a31cde56383ed28967f3d10f607eec36d0)
---
.../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 aeef8f8e19..1c4a4a2f8f 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
@@ -1489,7 +1489,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>>() {