zjncs opened a new pull request, #11138:
URL: https://github.com/apache/rocketmq/pull/11138
### Motivation
A gRPC client that calls `ReceiveMessage` before any settings were cached
(or after its settings were cleaned up) made `getClientSettings` return null,
and the following `settings.getClientType()` threw a `NullPointerException`
which the catch block turned into an opaque `INTERNAL_SERVER_ERROR` response.
`ClientActivity.heartbeat` already guards this case with
`UNRECOGNIZED_CLIENT_TYPE`.
### Modifications
Apply the same guard in `receiveMessage` so the client gets a meaningful
code.
### Verification
Fail-before (new test, run against the unpatched code):
```
ReceiveMessageActivityTest#testReceiveMessageWithoutClientSettings
java.lang.AssertionError: expected:<UNRECOGNIZED_CLIENT_TYPE> but
was:<INTERNAL_SERVER_ERROR>
ReceiveMessageActivityTest.testReceiveMessageWithoutClientSettings:447
(root cause: NullPointerException on "Settings.getClientType()" because
"settings" is null)
```
Pass-after:
```
Tests run: 10, Failures: 0, Errors: 0, Skipped: 0 --
ReceiveMessageActivityTest
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]