Repository navigation
Add NPE check for PulsarService#getAdminClient - #9782
Merged
codelipenghui merged 3 commits intoMar 5, 2021
Merged
Conversation
eolivelli
approved these changes
Mar 3, 2021
eolivelli
left a comment
Contributor
There was a problem hiding this comment.
LGTM
I like we are fixing this kind of issues.
Users must never face an NPE, it is really something that is perceived as poor quality.
thank you @BewareMyPower
zymap
approved these changes
Mar 3, 2021
codelipenghui
approved these changes
Mar 3, 2021
Contributor
Author
|
/pulsarbot run-failure-checks |
merlimat
reviewed
Mar 4, 2021
…vice.java Co-authored-by: Matteo Merli <[email protected]>
Contributor
Author
|
/pulsarbot run-failure-checks |
wolfstudy
approved these changes
Mar 5, 2021
Member
|
/pulsarbot run-failure-checks |
lhotari
added a commit
to lhotari/pulsar
that referenced
this pull request
Mar 5, 2021
### 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 throw 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.
mlyahmed
pushed a commit
to mlyahmed/pulsar
that referenced
this pull request
Mar 5, 2021
### 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 throw 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.
merlimat
pushed a commit
that referenced
this pull request
Mar 5, 2021
### 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 throw 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.
mlyahmed
pushed a commit
to mlyahmed/pulsar
that referenced
this pull request
Mar 7, 2021
…9746) ### 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 throw 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.
codelipenghui
pushed a commit
that referenced
this pull request
Mar 23, 2021
### 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 throw 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. (cherry picked from commit c97ebb0)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
If user set incorrect
brokerClientTlsEnabledconfig, thePulsarService#getAdminClientwould throw NPE and the error logs is not clear. For example, start a standalone pulsar withbrokerClientTlsEnabled=true, some admin APIs that don't involvePulsarService#getAdminClientwork well, however some admin APIs likeGET /admin/v2/non-persistent/:tenant/:namespacewill throw NPE with following logs:After this PR, the logs became:
Modifications
adminApiUrlis null inPulsarService#getAdminClientand give a human readable error message.Verifying this change
This change is a trivial rework / code cleanup without any test coverage.