From 88805f02108fb0790d2ec81cef48a447d61694ee Mon Sep 17 00:00:00 2001 From: Qiang Zhao <74767115+mattisonchao@users.noreply.github.com> Date: Sun, 13 Feb 2022 12:23:29 +0800 Subject: [PATCH] Check ``getTlsTrustStorePath`` NPE when user forget to set it. (#14253) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- .../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 e9a8bcd8e5d17..57726daf57074 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.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.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 { @@ -66,7 +67,10 @@ public PulsarChannelInitializer(ClientConfigurationData conf, Supplier