Skip to content

Commit

Permalink
Remove redundant null check for getInternalListener (apache#12474)
Browse files Browse the repository at this point in the history
### 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.
  • Loading branch information
BewareMyPower authored and eolivelli committed Nov 29, 2021
1 parent 94875e8 commit e26a614
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static String getAppliedAdvertisedAddress(ServiceConfiguration configurat

/**
* 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1412,7 +1412,7 @@ public TransactionBufferClient getTransactionBufferClient() {
*/
protected String brokerUrl(ServiceConfiguration config) {
AdvertisedListener internalListener = ServiceConfigurationUtils.getInternalListener(config);
return internalListener != null && internalListener.getBrokerServiceUrl() != null
return internalListener.getBrokerServiceUrl() != null
? internalListener.getBrokerServiceUrl().toString() : null;
}

Expand All @@ -1425,7 +1425,7 @@ public static String brokerUrl(String host, int port) {
*/
public String brokerUrlTls(ServiceConfiguration config) {
AdvertisedListener internalListener = ServiceConfigurationUtils.getInternalListener(config);
return internalListener != null && internalListener.getBrokerServiceUrlTls() != null
return internalListener.getBrokerServiceUrlTls() != null
? internalListener.getBrokerServiceUrlTls().toString() : null;
}

Expand Down

0 comments on commit e26a614

Please sign in to comment.