This is an automated email from the ASF dual-hosted git repository. penghui pushed a commit to branch branch-2.9 in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit 2bfa60152c3e9889d3f2b904b322603c7d81dd55 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 1353424..b7a5fba 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,9 +23,12 @@ import java.util.Objects; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import java.util.function.Supplier; - import io.netty.handler.proxy.Socks5ProxyHandler; +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; @@ -39,8 +42,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> { @@ -74,7 +75,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(),
