You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by pe...@apache.org on 2021/12/20 11:56:57 UTC

[pulsar] 07/22: Remove redundant null check for getInternalListener (#12474)

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 668d52ea01cecf14387e2962f42e84944be70940
Author: Yunze Xu <xy...@163.com>
AuthorDate: Mon Oct 25 12:21:13 2021 +0800

    Remove redundant null check for getInternalListener (#12474)
    
    ### Motivation
    
    `ServiceConfigurationUtils#getInternalListener` never returns null. The null check is redundant. Otherwise, the null check should also be performed in `CompactorTool#main`.
    
    ### Modifications
    
    Remove the null check for `getInternalListener` and note the returned value is non-null in method description.
    
    (cherry picked from commit dda8cc7b2be8e130495edb0c84376e7611aea3f6)
---
 .../main/java/org/apache/pulsar/broker/ServiceConfigurationUtils.java | 2 +-
 .../src/main/java/org/apache/pulsar/broker/PulsarService.java         | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfigurationUtils.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfigurationUtils.java
index 8401723..c47b8ca 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfigurationUtils.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfigurationUtils.java
@@ -83,7 +83,7 @@ public class ServiceConfigurationUtils {
 
     /**
      * Gets the internal advertised listener for broker-to-broker communication.
-     * @return an advertised listener
+     * @return a non-null advertised listener
      */
     public static AdvertisedListener getInternalListener(ServiceConfiguration config) {
         Map<String, AdvertisedListener> result = MultipleListenerValidator
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 c897f15..6b59862 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
@@ -1411,7 +1411,7 @@ public class PulsarService implements AutoCloseable, ShutdownService {
      */
     protected String brokerUrl(ServiceConfiguration config) {
         AdvertisedListener internalListener = ServiceConfigurationUtils.getInternalListener(config);
-        return internalListener != null && internalListener.getBrokerServiceUrl() != null
+        return internalListener.getBrokerServiceUrl() != null
                 ? internalListener.getBrokerServiceUrl().toString() : null;
     }
 
@@ -1424,7 +1424,7 @@ public class PulsarService implements AutoCloseable, ShutdownService {
      */
     public String brokerUrlTls(ServiceConfiguration config) {
         AdvertisedListener internalListener = ServiceConfigurationUtils.getInternalListener(config);
-        return internalListener != null && internalListener.getBrokerServiceUrlTls() != null
+        return internalListener.getBrokerServiceUrlTls() != null
                 ? internalListener.getBrokerServiceUrlTls().toString() : null;
     }