This is an automated email from the ASF dual-hosted git repository.
mmarshall pushed a commit to branch branch-2.8
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/branch-2.8 by this push:
new 88805f0 Check ``getTlsTrustStorePath`` NPE when user forget to set
it. (#14253)
88805f0 is described below
commit 88805f02108fb0790d2ec81cef48a447d61694ee
Author: Qiang Zhao <[email protected]>
AuthorDate: Sun Feb 13 12:23:29 2022 +0800
Check ``getTlsTrustStorePath`` NPE when user forget to set it. (#14253)
If a user sets ``useKeyStoreTls=true`` then forget to set
``getTlsTrustStorePath``, we’re having NPE which becomes hard to debug for
users.
- Add NPE check and give use more clear error information.
- [x] Make sure that the change passes the CI checks.
*If `yes` was chosen, please highlight the changes*
- Dependencies (does it add or upgrade a dependency): (no)
- The public API: (no)
- The schema: (no)
- The default values of configurations: (no)
- The wire protocol: (no)
- The rest endpoints: (no)
- The admin cli options: (no)
- Anything that affects deployment: (no)
- [x] `no-need-doc`
(cherry picked from commit eca563e2cb4ebaadd2dc1762e490c05b30fbde18)
---
.../apache/pulsar/client/impl/PulsarChannelInitializer.java | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git
a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarChannelInitializer.java
b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarChannelInitializer.java
index e9a8bcd..57726da 100644
---
a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarChannelInitializer.java
+++
b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarChannelInitializer.java
@@ -23,8 +23,11 @@ import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
-
+import lombok.Getter;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
import org.apache.pulsar.client.api.AuthenticationDataProvider;
+import org.apache.pulsar.client.api.PulsarClientException;
import org.apache.pulsar.client.impl.conf.ClientConfigurationData;
import org.apache.pulsar.client.util.ObjectCache;
import org.apache.pulsar.common.protocol.ByteBufPair;
@@ -38,8 +41,6 @@ import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslHandler;
-import lombok.Getter;
-import lombok.extern.slf4j.Slf4j;
@Slf4j
public class PulsarChannelInitializer extends
ChannelInitializer<SocketChannel> {
@@ -66,7 +67,10 @@ public class PulsarChannelInitializer extends
ChannelInitializer<SocketChannel>
if (tlsEnabled) {
if (tlsEnabledWithKeyStore) {
AuthenticationDataProvider authData1 =
conf.getAuthentication().getAuthData();
-
+ if (StringUtils.isBlank(conf.getTlsTrustStorePath())) {
+ throw new PulsarClientException("Failed to create TLS
context, the tlsTrustStorePath"
+ + " need to be configured if useKeyStoreTls
enabled");
+ }
nettySSLContextAutoRefreshBuilder = new
NettySSLContextAutoRefreshBuilder(
conf.getSslProvider(),
conf.isTlsAllowInsecureConnection(),