This is an automated email from the ASF dual-hosted git repository. symat pushed a commit to branch branch-3.5 in repository https://gitbox.apache.org/repos/asf/zookeeper.git
commit 65615a54e30777af757ac52980fb2a5ac5fb0219 Author: Bo Cui <[email protected]> AuthorDate: Wed Aug 11 20:40:33 2021 +0530 ZOOKEEPER-4345: Avoid NoSunchMethodException caused by shaded zookeeper jar Author: Bo <[email protected]> Reviewers: Enrico Olivelli <[email protected]>, Mohammad Arshad <[email protected]> Closes #1736 from cuibo01/zookeeper-4345 and squashes the following commits: 3965f2e8d [Bo] [ZOOKEEPER-4345]Avoid NoSunchMethodException caused by shaded 970972971 [Bo] [ZOOKEEPER-4345]Avoid NoSunchMethodException caused by shaded (cherry picked from commit f658cdced8a417d7969c4a72b7732ae32db0b266) --- .../src/main/java/org/apache/zookeeper/ZooKeeper.java | 7 ++++--- .../test/java/org/apache/zookeeper/test/ClientSSLTest.java | 12 ++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/zookeeper-server/src/main/java/org/apache/zookeeper/ZooKeeper.java b/zookeeper-server/src/main/java/org/apache/zookeeper/ZooKeeper.java index 4ee58a9d1..b82d3c213 100644 --- a/zookeeper-server/src/main/java/org/apache/zookeeper/ZooKeeper.java +++ b/zookeeper-server/src/main/java/org/apache/zookeeper/ZooKeeper.java @@ -3054,10 +3054,11 @@ public class ZooKeeper implements AutoCloseable { } private ClientCnxnSocket getClientCnxnSocket() throws IOException { - String clientCnxnSocketName = getClientConfig().getProperty( - ZKClientConfig.ZOOKEEPER_CLIENT_CNXN_SOCKET); - if (clientCnxnSocketName == null) { + String clientCnxnSocketName = getClientConfig().getProperty(ZKClientConfig.ZOOKEEPER_CLIENT_CNXN_SOCKET); + if (clientCnxnSocketName == null || clientCnxnSocketName.equals(ClientCnxnSocketNIO.class.getSimpleName())) { clientCnxnSocketName = ClientCnxnSocketNIO.class.getName(); + } else if (clientCnxnSocketName.equals(ClientCnxnSocketNetty.class.getSimpleName())) { + clientCnxnSocketName = ClientCnxnSocketNetty.class.getName(); } try { Constructor<?> clientCxnConstructor = Class.forName(clientCnxnSocketName).getDeclaredConstructor(ZKClientConfig.class); diff --git a/zookeeper-server/src/test/java/org/apache/zookeeper/test/ClientSSLTest.java b/zookeeper-server/src/test/java/org/apache/zookeeper/test/ClientSSLTest.java index 0d50bc925..66fb56df2 100644 --- a/zookeeper-server/src/test/java/org/apache/zookeeper/test/ClientSSLTest.java +++ b/zookeeper-server/src/test/java/org/apache/zookeeper/test/ClientSSLTest.java @@ -86,6 +86,18 @@ public class ClientSSLTest extends QuorumPeerTestBase { testClientServerSSL(false); } + @Test + public void testClientServerUnifiedPortWithCnxnClassName() throws Exception { + System.setProperty(ZKClientConfig.ZOOKEEPER_CLIENT_CNXN_SOCKET, "ClientCnxnSocketNIO"); + testClientServerSSL(false); + } + + @Test + public void testClientServerSSLWithCnxnClassName() throws Exception { + System.setProperty(ZKClientConfig.ZOOKEEPER_CLIENT_CNXN_SOCKET, "ClientCnxnSocketNetty"); + testClientServerSSL(true); + } + /** * This test checks that client <-> server SSL works in cluster setup of ZK servers, which includes: * 1. setting "secureClientPort" in "zoo.cfg" file.
