You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@zookeeper.apache.org by "dsmiley (via GitHub)" <gi...@apache.org> on 2026/04/20 17:39:47 UTC
[PR] ZOOKEEPER-4835: Make use of Netty optional when no SSL is used [zookeeper]
dsmiley opened a new pull request, #2374:
URL: https://github.com/apache/zookeeper/pull/2374
https://issues.apache.org/jira/browse/ZOOKEEPER-4835
ZOOKEEPER-4835: Make Netty an optional dependency when SSL is not used
Netty is now declared as `<optional>true</optional>` in zookeeper-server/pom.xml,
so embedders who do not need SSL/TLS no longer pull in Netty transitively.
The zookeeper-assembly distribution still includes Netty for full SSL support.
Key changes:
- Split `ClientX509Util` into a Netty-free base class and `ClientNettyX509Util` subclass,
so the common X509/SSL abstraction compiles without Netty on the classpath.
- Removed hard Netty references from `ZooKeeper`, `ZooKeeperServer`, and startup classes;
Netty factory/util classes are now loaded reflectively or guarded by classpath checks.
- Added an ArchUnit test (`NettyOptionalArchTest`) to enforce that core classes never
acquire a hard compile-time dependency on Netty.
I tested that Solr's tests pass when changing it to use a local snapshot of ZK with these changes. Solr's tests embed ZK server, and also are a client to ZK.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ZOOKEEPER-4835: Make use of Netty optional when no SSL is used [zookeeper]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #2374:
URL: https://github.com/apache/zookeeper/pull/2374#discussion_r3327919137
##########
zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/QuorumPeerMain.java:
##########
@@ -170,7 +170,7 @@ public void runFromConfig(QuorumPeerConfig config) throws IOException, AdminServ
}
if (config.getSecureClientPortAddress() != null) {
- secureCnxnFactory = ServerCnxnFactory.createFactory();
+ secureCnxnFactory = ServerCnxnFactory.createFactory(true);
Review Comment:
wow, good catch! I included the simple change, even though it's arguably out-of-scope.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ZOOKEEPER-4835: Make use of Netty optional when no SSL is used [zookeeper]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #2374:
URL: https://github.com/apache/zookeeper/pull/2374#discussion_r3915969787
##########
pom.xml:
##########
@@ -693,6 +694,17 @@
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-inline</artifactId>
+ <version>${mockito.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.tngtech.archunit</groupId>
+ <artifactId>archunit-junit5</artifactId>
+ <version>${archunit.version}</version>
+ </dependency>
Review Comment:
_LLM generated_
> The mockito-inline part is a red herring. This PR doesn't add or touch mockito-inline — it's pre-existing in the root <dependencyManagement>. It only shows up in anmolnar's diff view as context lines directly above the new archunit-junit5 entry. The new tests (NettyOptionalArchTest, HexDumpOutputFormatterTest) use no Mockito at all. That's just a PR-comment reply, no code change.
> The scope inconsistency is real but minor. The new archunit-junit5 entry in root <dependencyManagement> has no <scope>test</scope>, while its neighbors mockito-inline and junit-jupiter do. That section is already mixed (mockito-core, junit-vintage-engine have no scope), so it's not a hard rule — but archunit is genuinely test-only (one ArchUnit test, nothing in src/main), and zookeeper-server/pom.xml already declares it <scope>test</scope> at point of use.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ZOOKEEPER-4835: Make use of Netty optional when no SSL is used [zookeeper]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on PR #2374:
URL: https://github.com/apache/zookeeper/pull/2374#issuecomment-5275503219
@PDavid could you please consider merging this?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ZOOKEEPER-4835: Make use of Netty optional when no SSL is used [zookeeper]
Posted by "anmolnar (via GitHub)" <gi...@apache.org>.
anmolnar commented on code in PR #2374:
URL: https://github.com/apache/zookeeper/pull/2374#discussion_r3917972814
##########
pom.xml:
##########
@@ -693,6 +694,17 @@
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-inline</artifactId>
+ <version>${mockito.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.tngtech.archunit</groupId>
+ <artifactId>archunit-junit5</artifactId>
+ <version>${archunit.version}</version>
+ </dependency>
Review Comment:
No, `mockito-inline` doesn't exist in the root pom on the master branch. This patch is about to add it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ZOOKEEPER-4835: Make use of Netty optional when no SSL is used [zookeeper]
Posted by "anmolnar (via GitHub)" <gi...@apache.org>.
anmolnar commented on code in PR #2374:
URL: https://github.com/apache/zookeeper/pull/2374#discussion_r3915692020
##########
pom.xml:
##########
@@ -693,6 +694,17 @@
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-inline</artifactId>
+ <version>${mockito.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.tngtech.archunit</groupId>
+ <artifactId>archunit-junit5</artifactId>
+ <version>${archunit.version}</version>
+ </dependency>
Review Comment:
Mockito scope is "test", but archunit is not. Why is that?
Where do you use `mockito-inline` in the new code?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ZOOKEEPER-4835: Make use of Netty optional when no SSL is used [zookeeper]
Posted by "anmolnar (via GitHub)" <gi...@apache.org>.
anmolnar commented on PR #2374:
URL: https://github.com/apache/zookeeper/pull/2374#issuecomment-5637343032
@dsmiley Ooops, just about to merge it, but looks like the Single EKU patch conflicts with this one.
Could you please rebase your patch one more time?
(apologies for the hassle)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ZOOKEEPER-4835: Make use of Netty optional when no SSL is used [zookeeper]
Posted by "PDavid (via GitHub)" <gi...@apache.org>.
PDavid commented on code in PR #2374:
URL: https://github.com/apache/zookeeper/pull/2374#discussion_r3341447135
##########
zookeeper-server/src/test/java/org/apache/zookeeper/cli/HexDumpOutputFormatterTest.java:
##########
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.zookeeper.cli;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.nio.charset.StandardCharsets;
+import org.junit.jupiter.api.Test;
+
+public class HexDumpOutputFormatterTest {
Review Comment:
Many thanks for adding this test. 👍
##########
zookeeper-server/src/main/java/org/apache/zookeeper/server/ServerCnxnFactory.java:
##########
@@ -228,6 +236,49 @@ public static ServerCnxnFactory createFactory() throws IOException {
}
}
+ /**
+ * Creates a ServerCnxnFactory, defaulting to NettyServerCnxnFactory when
+ * {@code secure} is {@code true} and no explicit factory is configured via
+ * the {@value #ZOOKEEPER_SERVER_CNXN_FACTORY} system property. SSL/TLS
+ * requires Netty; if Netty is not present on the classpath a helpful
+ * {@link IOException} is thrown.
+ *
+ * @param secure {@code true} when the factory will be used for secure (SSL/TLS) connections
+ * @return a new ServerCnxnFactory instance
+ * @throws IOException if the factory cannot be instantiated
+ */
+ public static ServerCnxnFactory createFactory(boolean secure) throws IOException {
+ String serverCnxnFactoryName = System.getProperty(ZOOKEEPER_SERVER_CNXN_FACTORY);
+ if (serverCnxnFactoryName == null) {
+ if (secure) {
+ serverCnxnFactoryName = "org.apache.zookeeper.server.NettyServerCnxnFactory";
+ } else {
+ serverCnxnFactoryName = NIOServerCnxnFactory.class.getName();
+ }
+ }
+ try {
+ ServerCnxnFactory serverCnxnFactory = (ServerCnxnFactory) Class.forName(serverCnxnFactoryName)
+ .getDeclaredConstructor()
+ .newInstance();
+ LOG.info("Using {} as server connection factory", serverCnxnFactoryName);
+ return serverCnxnFactory;
+ } catch (Exception e) {
+ String msg = "Couldn't instantiate " + serverCnxnFactoryName;
+ if (secure) {
+ msg += ". SSL/TLS support requires Netty; please add netty-handler"
+ + " (and optionally netty-tcnative-boringssl-static) to your project's dependencies.";
+ }
+ throw new IOException(msg, e);
+ } catch (NoClassDefFoundError e) {
+ String msg = "Couldn't instantiate " + serverCnxnFactoryName;
+ if (secure) {
+ msg += ". SSL/TLS support requires Netty; please add netty-handler"
+ + " (and optionally netty-tcnative-boringssl-static) to your project's dependencies.";
+ }
+ throw new IOException(msg, e);
+ }
+ }
Review Comment:
Sorry, I missed this last time. Here we could also use multi-catch instead of duplicating the catch block code.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ZOOKEEPER-4835: Make use of Netty optional when no SSL is used [zookeeper]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #2374:
URL: https://github.com/apache/zookeeper/pull/2374#discussion_r3112572302
##########
zookeeper-server/src/main/java/org/apache/zookeeper/common/ClientNettyX509Util.java:
##########
Review Comment:
All the code here moved from ClientX509Util
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ZOOKEEPER-4835: Make use of Netty optional when no SSL is used [zookeeper]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #2374:
URL: https://github.com/apache/zookeeper/pull/2374#discussion_r3327878085
##########
zookeeper-server/src/main/java/org/apache/zookeeper/cli/HexDumpOutputFormatter.java:
##########
@@ -18,17 +18,44 @@
package org.apache.zookeeper.cli;
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.ByteBufUtil;
-import io.netty.buffer.Unpooled;
-
public class HexDumpOutputFormatter implements OutputFormatter {
public static final HexDumpOutputFormatter INSTANCE = new HexDumpOutputFormatter();
+ private static final int BYTES_PER_ROW = 16;
+ private static final int ASCII_PRINTABLE_MIN = 0x20; // space
+ private static final int ASCII_PRINTABLE_MAX = 0x7f; // DEL (exclusive)
+ private static final String HEADER_LINE =
+ " +-------------------------------------------------+\n"
+ + " | 0 1 2 3 4 5 6 7 8 9 a b c d e f |\n"
+ + "+--------+-------------------------------------------------+----------------+";
+ private static final String FOOTER_LINE =
+ "+--------+-------------------------------------------------+----------------+";
+
@Override
public String format(byte[] data) {
- ByteBuf buf = Unpooled.wrappedBuffer(data);
- return ByteBufUtil.prettyHexDump(buf);
+ if (data == null || data.length == 0) {
Review Comment:
Very thorough of you to have noticed! I should add a test to at least easily observe it's output, which I think of as for human consumption, not really for another system that requires strict compatibility.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ZOOKEEPER-4835: Make use of Netty optional when no SSL is used [zookeeper]
Posted by "PDavid (via GitHub)" <gi...@apache.org>.
PDavid commented on code in PR #2374:
URL: https://github.com/apache/zookeeper/pull/2374#discussion_r3347004585
##########
zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/QuorumPeerMain.java:
##########
@@ -170,7 +170,7 @@ public void runFromConfig(QuorumPeerConfig config) throws IOException, AdminServ
}
if (config.getSecureClientPortAddress() != null) {
- secureCnxnFactory = ServerCnxnFactory.createFactory();
+ secureCnxnFactory = ServerCnxnFactory.createFactory(true);
Review Comment:
Many thanks for fixing this. :+1:
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ZOOKEEPER-4835: Make use of Netty optional when no SSL is used [zookeeper]
Posted by "PDavid (via GitHub)" <gi...@apache.org>.
PDavid commented on code in PR #2374:
URL: https://github.com/apache/zookeeper/pull/2374#discussion_r3317387346
##########
zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/QuorumPeerMain.java:
##########
@@ -170,7 +170,7 @@ public void runFromConfig(QuorumPeerConfig config) throws IOException, AdminServ
}
if (config.getSecureClientPortAddress() != null) {
- secureCnxnFactory = ServerCnxnFactory.createFactory();
+ secureCnxnFactory = ServerCnxnFactory.createFactory(true);
Review Comment:
The same issue should also be fixed in `QuorumPeer.java:2426`. The dynamic reconfiguration path for `secureCnxnFactory` still calls the no-arg `createFactory()`, which defaults to NIO. This means adding a secure client port via live reconfig will silently produce a non-TLS server socket.
##########
zookeeper-server/src/main/java/org/apache/zookeeper/cli/HexDumpOutputFormatter.java:
##########
@@ -18,17 +18,44 @@
package org.apache.zookeeper.cli;
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.ByteBufUtil;
-import io.netty.buffer.Unpooled;
-
public class HexDumpOutputFormatter implements OutputFormatter {
public static final HexDumpOutputFormatter INSTANCE = new HexDumpOutputFormatter();
+ private static final int BYTES_PER_ROW = 16;
+ private static final int ASCII_PRINTABLE_MIN = 0x20; // space
+ private static final int ASCII_PRINTABLE_MAX = 0x7f; // DEL (exclusive)
+ private static final String HEADER_LINE =
+ " +-------------------------------------------------+\n"
+ + " | 0 1 2 3 4 5 6 7 8 9 a b c d e f |\n"
+ + "+--------+-------------------------------------------------+----------------+";
+ private static final String FOOTER_LINE =
+ "+--------+-------------------------------------------------+----------------+";
+
@Override
public String format(byte[] data) {
- ByteBuf buf = Unpooled.wrappedBuffer(data);
- return ByteBufUtil.prettyHexDump(buf);
+ if (data == null || data.length == 0) {
Review Comment:
There seems to be a slight difference between the original and this Hex dump output formatter implementation.
Original (Netty):
```
[zk: localhost:2181(CONNECTED) 1] get -x /test
+-------------------------------------------------+
| 0 1 2 3 4 5 6 7 8 9 a b c d e f |
+--------+-------------------------------------------------+----------------+
|00000000| 68 65 6c 6c 6f 20 77 6f 72 6c 64 |hello world |
+--------+-------------------------------------------------+----------------+
[zk: localhost:2181(CONNECTED) 2]
```
New:
```
[zk: localhost:2181(CONNECTED) 1] get -x /test
+-------------------------------------------------+
| 0 1 2 3 4 5 6 7 8 9 a b c d e f |
+--------+-------------------------------------------------+----------------+
|00000000| 68 65 6c 6c 6f 20 77 6f 72 6c 64 |hello world |
+--------+-------------------------------------------------+----------------+
[zk: localhost:2181(CONNECTED) 2]
```
If any downstream tooling, log parsers, or integration tests depend on the exact Netty prettyHexDump format, the output change could break them.
Maybe would it make sense to add unit tests for this formatter to make sure that the output stays the same? 🤔
##########
zookeeper-server/src/test/java/org/apache/zookeeper/NettyOptionalArchTest.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.zookeeper;
+
+import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses;
+import com.tngtech.archunit.base.DescribedPredicate;
+import com.tngtech.archunit.core.domain.JavaClass;
+import com.tngtech.archunit.core.domain.JavaClasses;
+import com.tngtech.archunit.core.importer.ClassFileImporter;
+import com.tngtech.archunit.core.importer.ImportOption;
+import com.tngtech.archunit.lang.ArchRule;
+import java.util.Collections;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Architectural test to enforce that Netty is an optional dependency.
+ *
+ * <p>Only classes whose name contains "Netty" (e.g. {@code NettyServerCnxnFactory},
+ * {@code ClientCnxnSocketNetty}, {@code ClientNettyX509Util}) and a small set of
+ * explicitly allowed SSL/TLS utility classes ({@code UnifiedServerSocket}) may depend
+ * on {@code io.netty} packages. All other ZooKeeper classes must remain Netty-free so
+ * that Netty can be an optional dependency for users who do not need SSL/TLS.
+ */
+public class NettyOptionalArchTest {
Review Comment:
I really like that you added this test. 👍
##########
zookeeper-server/src/main/java/org/apache/zookeeper/ZooKeeper.java:
##########
@@ -3154,7 +3161,19 @@ private ClientCnxnSocket getClientCnxnSocket() throws IOException {
ClientCnxnSocket clientCxnSocket = (ClientCnxnSocket) clientCxnConstructor.newInstance(getClientConfig());
return clientCxnSocket;
} catch (Exception e) {
- throw new IOException("Couldn't instantiate " + clientCnxnSocketName, e);
+ String msg = "Couldn't instantiate " + clientCnxnSocketName;
+ if (getClientConfig().getBoolean(ZKClientConfig.SECURE_CLIENT)) {
+ msg += ". SSL/TLS support requires Netty; please add netty-handler"
+ + " (and optionally netty-tcnative-boringssl-static) to your project's dependencies.";
+ }
+ throw new IOException(msg, e);
+ } catch (NoClassDefFoundError e) {
+ String msg = "Couldn't instantiate " + clientCnxnSocketName;
+ if (getClientConfig().getBoolean(ZKClientConfig.SECURE_CLIENT)) {
+ msg += ". SSL/TLS support requires Netty; please add netty-handler"
+ + " (and optionally netty-tcnative-boringssl-static) to your project's dependencies.";
+ }
+ throw new IOException(msg, e);
Review Comment:
It seems both catch-es are using the same error handling.
Would it maybe make sense to use a multi-catch to avoid this code duplication?
##########
pom.xml:
##########
@@ -574,6 +574,7 @@
<commons-io.version>2.17.0</commons-io.version>
<burningwave.mockdns.version>0.25.4</burningwave.mockdns.version>
<dnsjava.version>3.5.1</dnsjava.version>
+ <archunit.version>1.3.0</archunit.version>
Review Comment:
Can we maybe use 1.4.2 (latest) version here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ZOOKEEPER-4835: Make use of Netty optional when no SSL is used [zookeeper]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #2374:
URL: https://github.com/apache/zookeeper/pull/2374#discussion_r3919016995
##########
pom.xml:
##########
@@ -693,6 +694,17 @@
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-inline</artifactId>
+ <version>${mockito.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.tngtech.archunit</groupId>
+ <artifactId>archunit-junit5</artifactId>
+ <version>${archunit.version}</version>
+ </dependency>
Review Comment:
Good catch; you are quite right! I must have messed that up from the merge... given this PR has been sitting around forever, it increased the chances of having to update it. Now fixed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ZOOKEEPER-4835: Make use of Netty optional when no SSL is used [zookeeper]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on PR #2374:
URL: https://github.com/apache/zookeeper/pull/2374#issuecomment-5586888015
_(matters are addressed)_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ZOOKEEPER-4835: Make use of Netty optional when no SSL is used [zookeeper]
Posted by "anmolnar (via GitHub)" <gi...@apache.org>.
anmolnar commented on code in PR #2374:
URL: https://github.com/apache/zookeeper/pull/2374#discussion_r3915647026
##########
zookeeper-server/src/main/java/org/apache/zookeeper/ZooKeeper.java:
##########
@@ -3142,19 +3142,31 @@ protected SocketAddress testableLocalSocketAddress() {
private ClientCnxnSocket getClientCnxnSocket() throws IOException {
String clientCnxnSocketName = getClientConfig().getProperty(ZKClientConfig.ZOOKEEPER_CLIENT_CNXN_SOCKET);
- if (clientCnxnSocketName == null || clientCnxnSocketName.equals(ClientCnxnSocketNIO.class.getSimpleName())) {
+ if (clientCnxnSocketName == null) {
+ boolean secureClient = getClientConfig().getBoolean(ZKClientConfig.SECURE_CLIENT);
+ if (secureClient) {
+ clientCnxnSocketName = "org.apache.zookeeper.ClientCnxnSocketNetty";
+ } else {
+ clientCnxnSocketName = ClientCnxnSocketNIO.class.getName();
+ }
+ } else if (clientCnxnSocketName.equals(ClientCnxnSocketNIO.class.getSimpleName())) {
clientCnxnSocketName = ClientCnxnSocketNIO.class.getName();
- } else if (clientCnxnSocketName.equals(ClientCnxnSocketNetty.class.getSimpleName())) {
- clientCnxnSocketName = ClientCnxnSocketNetty.class.getName();
+ } else if (clientCnxnSocketName.equals("ClientCnxnSocketNetty")) {
+ clientCnxnSocketName = "org.apache.zookeeper.ClientCnxnSocketNetty";
Review Comment:
I'm not sure hardcoding the full classname here is the right thing to do. There could be clients where a shaded version of ZooKeeper is being referenced, like in the HBase client, and in that case this hardcoded value won't work or even break compatibility.
Why do you need this change?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ZOOKEEPER-4835: Make use of Netty optional when no SSL is used [zookeeper]
Posted by "anmolnar (via GitHub)" <gi...@apache.org>.
anmolnar commented on code in PR #2374:
URL: https://github.com/apache/zookeeper/pull/2374#discussion_r3917957840
##########
zookeeper-server/src/main/java/org/apache/zookeeper/ZooKeeper.java:
##########
@@ -3142,19 +3142,31 @@ protected SocketAddress testableLocalSocketAddress() {
private ClientCnxnSocket getClientCnxnSocket() throws IOException {
String clientCnxnSocketName = getClientConfig().getProperty(ZKClientConfig.ZOOKEEPER_CLIENT_CNXN_SOCKET);
- if (clientCnxnSocketName == null || clientCnxnSocketName.equals(ClientCnxnSocketNIO.class.getSimpleName())) {
+ if (clientCnxnSocketName == null) {
+ boolean secureClient = getClientConfig().getBoolean(ZKClientConfig.SECURE_CLIENT);
+ if (secureClient) {
+ clientCnxnSocketName = "org.apache.zookeeper.ClientCnxnSocketNetty";
+ } else {
+ clientCnxnSocketName = ClientCnxnSocketNIO.class.getName();
+ }
+ } else if (clientCnxnSocketName.equals(ClientCnxnSocketNIO.class.getSimpleName())) {
clientCnxnSocketName = ClientCnxnSocketNIO.class.getName();
- } else if (clientCnxnSocketName.equals(ClientCnxnSocketNetty.class.getSimpleName())) {
- clientCnxnSocketName = ClientCnxnSocketNetty.class.getName();
+ } else if (clientCnxnSocketName.equals("ClientCnxnSocketNetty")) {
+ clientCnxnSocketName = "org.apache.zookeeper.ClientCnxnSocketNetty";
Review Comment:
Oh, thanks, my bad.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ZOOKEEPER-4835: Make use of Netty optional when no SSL is used [zookeeper]
Posted by "anmolnar (via GitHub)" <gi...@apache.org>.
anmolnar commented on code in PR #2374:
URL: https://github.com/apache/zookeeper/pull/2374#discussion_r3971936330
##########
pom.xml:
##########
@@ -693,6 +694,17 @@
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-inline</artifactId>
+ <version>${mockito.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.tngtech.archunit</groupId>
+ <artifactId>archunit-junit5</artifactId>
+ <version>${archunit.version}</version>
+ </dependency>
Review Comment:
No worries @dsmiley , thanks for working on it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ZOOKEEPER-4835: Make use of Netty optional when no SSL is used [zookeeper]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on PR #2374:
URL: https://github.com/apache/zookeeper/pull/2374#issuecomment-5638364271
Done via LLM:
**Brought up to date with apache/master**
- Merged latest `apache/master` (15 commits, including ZOOKEEPER-5070). One real conflict in `ClientX509Util.java`: upstream renamed `buildKeyManager`/`buildTrustManager` to `buildClientKeyManager`/`buildServerTrustManager` in methods this PR had already relocated to `ClientNettyX509Util.java` (keeping `ClientX509Util` Netty-free). Resolved by applying the same renames in `ClientNettyX509Util.java`, and updated one test (`X509UtilTest`) that referenced the relocated methods.
- Verified: `mvn compile`, `mvn test-compile`, and `X509UtilTest` + `NettyOptionalArchTest` all pass clean.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ZOOKEEPER-4835: Make use of Netty optional when no SSL is used [zookeeper]
Posted by "anmolnar (via GitHub)" <gi...@apache.org>.
anmolnar merged PR #2374:
URL: https://github.com/apache/zookeeper/pull/2374
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ZOOKEEPER-4835: Make use of Netty optional when no SSL is used [zookeeper]
Posted by "anmolnar (via GitHub)" <gi...@apache.org>.
anmolnar commented on PR #2374:
URL: https://github.com/apache/zookeeper/pull/2374#issuecomment-5639367763
Merged to master.
Thanks for contribution @dsmiley !
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ZOOKEEPER-4835: Make use of Netty optional when no SSL is used [zookeeper]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #2374:
URL: https://github.com/apache/zookeeper/pull/2374#discussion_r3915856540
##########
zookeeper-server/src/main/java/org/apache/zookeeper/ZooKeeper.java:
##########
@@ -3142,19 +3142,31 @@ protected SocketAddress testableLocalSocketAddress() {
private ClientCnxnSocket getClientCnxnSocket() throws IOException {
String clientCnxnSocketName = getClientConfig().getProperty(ZKClientConfig.ZOOKEEPER_CLIENT_CNXN_SOCKET);
- if (clientCnxnSocketName == null || clientCnxnSocketName.equals(ClientCnxnSocketNIO.class.getSimpleName())) {
+ if (clientCnxnSocketName == null) {
+ boolean secureClient = getClientConfig().getBoolean(ZKClientConfig.SECURE_CLIENT);
+ if (secureClient) {
+ clientCnxnSocketName = "org.apache.zookeeper.ClientCnxnSocketNetty";
+ } else {
+ clientCnxnSocketName = ClientCnxnSocketNIO.class.getName();
+ }
+ } else if (clientCnxnSocketName.equals(ClientCnxnSocketNIO.class.getSimpleName())) {
clientCnxnSocketName = ClientCnxnSocketNIO.class.getName();
- } else if (clientCnxnSocketName.equals(ClientCnxnSocketNetty.class.getSimpleName())) {
- clientCnxnSocketName = ClientCnxnSocketNetty.class.getName();
+ } else if (clientCnxnSocketName.equals("ClientCnxnSocketNetty")) {
+ clientCnxnSocketName = "org.apache.zookeeper.ClientCnxnSocketNetty";
Review Comment:
"Why" is hopefully clear based on the fundamental point of this issue/PR -- to prevent a dependency on Netty when the user doesn't configure ZK to need it.
Good point about shading. I'll fix in a minute by using the same package as another, thus potentially shade-relative if shading is used.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org