This is an automated email from the ASF dual-hosted git repository.
yong pushed a commit to branch branch-4.15
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/branch-4.15 by this push:
new 681436286f Fix the tls failed test (#3448)
681436286f is described below
commit 681436286fc9223c4d6d4bf5aa474fd0d405a994
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.
(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 2f41d41054..0be3996ac8 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
@@ -1499,7 +1499,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>>() {