BewareMyPower opened a new pull request #9782:
URL: https://github.com/apache/pulsar/pull/9782


   ### Motivation
   
   If user set incorrect `brokerClientTlsEnabled` config, the 
`PulsarService#getAdminClient` would throw NPE and the error logs is not clear. 
For example, start a standalone pulsar with `brokerClientTlsEnabled=true`, some 
admin APIs that don't involve `PulsarService#getAdminClient` work well, however 
some admin APIs like `GET /admin/v2/non-persistent/:tenant/:namespace` will 
thrown NPE with following logs:
   
   ```
   org.apache.pulsar.broker.PulsarServerException: 
java.lang.NullPointerException
        at 
org.apache.pulsar.broker.PulsarService.getAdminClient(PulsarService.java:1193)
        at 
org.apache.pulsar.broker.admin.v2.NonPersistentTopics.getList(NonPersistentTopics.java:273)
   ```
   
   After this PR, the logs became:
   
   ```
   org.apache.pulsar.broker.PulsarServerException: 
java.lang.IllegalArgumentException: adminApiUrl is null, 
isBrokerClientTlsEnabled: true, webServiceAddressTls: null, webServiceAddress: 
http://localhost:8080
   ```
   
   ### Modifications
   
   - Check if `adminApiUrl` is null in `PulsarService#getAdminClient` and give 
a human readable error message.
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.
   
   This change is a trivial rework / code cleanup without any test coverage.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to