From a72f0be2ff9ca4b4ac68db7cb07a37de1f57254e Mon Sep 17 00:00:00 2001 From: Jia Zhai Date: Thu, 23 Jan 2020 10:07:13 +0800 Subject: [PATCH 1/4] fix broker client tls settings error --- .../java/org/apache/pulsar/broker/PulsarService.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java index fe848b5e8b466..ffe29e8b41242 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java @@ -907,12 +907,16 @@ public synchronized PulsarClient getClient() throws PulsarServerException { ClientBuilder builder = PulsarClient.builder() .serviceUrl(this.getConfiguration().isTlsEnabled() ? this.brokerServiceUrlTls : this.brokerServiceUrl) - .enableTls(this.getConfiguration().isTlsEnabled()) - .allowTlsInsecureConnection(this.getConfiguration().isTlsAllowInsecureConnection()) - .tlsTrustCertsFilePath(this.getConfiguration().getTlsCertificateFilePath()); + .enableTls(this.getConfiguration().isTlsEnabled()); + + if (this.getConfiguration().isBrokerClientTlsEnabled()) { + builder.allowTlsInsecureConnection(this.getConfiguration().isTlsAllowInsecureConnection()); + builder.tlsTrustCertsFilePath(this.getConfiguration().getBrokerClientTrustCertsFilePath()); + } + if (isNotBlank(this.getConfiguration().getBrokerClientAuthenticationPlugin())) { builder.authentication(this.getConfiguration().getBrokerClientAuthenticationPlugin(), - this.getConfiguration().getBrokerClientAuthenticationParameters()); + this.getConfiguration().getBrokerClientAuthenticationParameters()); } this.client = builder.build(); } catch (Exception e) { From 35866c313bcc35ff3c8bc3d71af01bdd20d15478 Mon Sep 17 00:00:00 2001 From: Jia Zhai Date: Sun, 2 Feb 2020 15:31:30 +0800 Subject: [PATCH 2/4] change following comments --- .../main/java/org/apache/pulsar/broker/PulsarService.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java index ffe29e8b41242..0898fe45d4720 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java @@ -911,7 +911,10 @@ public synchronized PulsarClient getClient() throws PulsarServerException { if (this.getConfiguration().isBrokerClientTlsEnabled()) { builder.allowTlsInsecureConnection(this.getConfiguration().isTlsAllowInsecureConnection()); - builder.tlsTrustCertsFilePath(this.getConfiguration().getBrokerClientTrustCertsFilePath()); + builder.tlsTrustCertsFilePath( + isNotBlank(this.getConfiguration().getBrokerClientTrustCertsFilePath()) + ? this.getConfiguration().getBrokerClientTrustCertsFilePath() + : this.getConfiguration().getTlsCertificateFilePath()); } if (isNotBlank(this.getConfiguration().getBrokerClientAuthenticationPlugin())) { From cf898a3f233e903a6b3f5bb7c51f3e6d75a51f53 Mon Sep 17 00:00:00 2001 From: Jia Zhai Date: Sun, 23 Feb 2020 16:58:37 +0800 Subject: [PATCH 3/4] python-ut: move print before assert --- .../main/java/org/apache/pulsar/broker/PulsarService.java | 2 +- pulsar-client-cpp/python/pulsar_test.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java index 0898fe45d4720..3cf0e20287391 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java @@ -919,7 +919,7 @@ public synchronized PulsarClient getClient() throws PulsarServerException { if (isNotBlank(this.getConfiguration().getBrokerClientAuthenticationPlugin())) { builder.authentication(this.getConfiguration().getBrokerClientAuthenticationPlugin(), - this.getConfiguration().getBrokerClientAuthenticationParameters()); + this.getConfiguration().getBrokerClientAuthenticationParameters()); } this.client = builder.build(); } catch (Exception e) { diff --git a/pulsar-client-cpp/python/pulsar_test.py b/pulsar-client-cpp/python/pulsar_test.py index 14cf2938bc554..4109ec79eeaa2 100755 --- a/pulsar-client-cpp/python/pulsar_test.py +++ b/pulsar-client-cpp/python/pulsar_test.py @@ -152,7 +152,7 @@ def test_redelivery_count(self): producer.send(b'hello') redelivery_count = 0 - for i in range(4): + for i in range(4): msg = consumer.receive(TM) print("Received message %s" % msg.data()) consumer.negative_acknowledge(msg) @@ -668,13 +668,13 @@ def test_publish_compact_and_consume(self): while True: s=doHttpGet(url).decode('utf-8') if 'RUNNING' in s: - print("Compact still running") print(s) + print("Compact still running") time.sleep(0.2) else: - self.assertTrue('SUCCESS' in s) - print("Compact Complete now") print(s) + print("Compact Complete now") + self.assertTrue('SUCCESS' in s) break # after compaction completes the compacted ledger is recorded From 71e13c3b69922b0b43369035b0caa8322729e956 Mon Sep 17 00:00:00 2001 From: Jia Zhai Date: Sun, 23 Feb 2020 18:52:30 +0800 Subject: [PATCH 4/4] change to make backward compat --- .../main/java/org/apache/pulsar/broker/PulsarService.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java index 3cf0e20287391..31b7fa391f245 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java @@ -907,10 +907,11 @@ public synchronized PulsarClient getClient() throws PulsarServerException { ClientBuilder builder = PulsarClient.builder() .serviceUrl(this.getConfiguration().isTlsEnabled() ? this.brokerServiceUrlTls : this.brokerServiceUrl) - .enableTls(this.getConfiguration().isTlsEnabled()); + .enableTls(this.getConfiguration().isTlsEnabled()) + .allowTlsInsecureConnection(this.getConfiguration().isTlsAllowInsecureConnection()) + .tlsTrustCertsFilePath(this.getConfiguration().getTlsCertificateFilePath()); if (this.getConfiguration().isBrokerClientTlsEnabled()) { - builder.allowTlsInsecureConnection(this.getConfiguration().isTlsAllowInsecureConnection()); builder.tlsTrustCertsFilePath( isNotBlank(this.getConfiguration().getBrokerClientTrustCertsFilePath()) ? this.getConfiguration().getBrokerClientTrustCertsFilePath() @@ -919,7 +920,7 @@ public synchronized PulsarClient getClient() throws PulsarServerException { if (isNotBlank(this.getConfiguration().getBrokerClientAuthenticationPlugin())) { builder.authentication(this.getConfiguration().getBrokerClientAuthenticationPlugin(), - this.getConfiguration().getBrokerClientAuthenticationParameters()); + this.getConfiguration().getBrokerClientAuthenticationParameters()); } this.client = builder.build(); } catch (Exception e) {