Repository navigation
[ISSUE #15225] Fix regression of #9461: NPE in ConfigRpcTransportClient.checkListenCache - #15226
Conversation
|
Thanks for your this PR. 🙏 感谢您提交的PR。 🙏 |
|
| Commit | Author | |
|---|---|---|
cd5928a |
sywu14 | sywu14@iflytek.com |
38513e2 |
sywu14 | sywu14@iflytek.com |
How to fix:
- Add your commit email to your GitHub account: https://github.com/settings/emails
- Or update your local git config to use an email already linked to GitHub:
git config user.name "Your GitHub Username" git config user.email "your-github-email@example.com" - Amend your commits and force-push:
git rebase -i HEAD~2 # mark commits as "edit" and amend author git push --force-with-lease
This check will re-run automatically after you push.
f328c42 to
b24d52d
Compare
|
The earlier "Commit Author Verification Failed" notice references obsolete SHAs 之前 bot 提示的 author email 校验失败是基于旧 commit (cd5928a / 38513e2) |
|
大概率 spotless会无法通过, 我有看到缩进被修改了。 |
…rver returns unknown key Reproduces the same bug class fixed by alibaba#9461: when the server returns a changeKey in ConfigChangeBatchListenResponse that has been concurrently removed from the local cacheMap (e.g. user has just called removeListener), the unsafe pre-dereference cacheMap.get().get(changeKey).isInitializing() throws NPE. The exception is swallowed by the surrounding catch (Throwable) and only surfaces as "Execute listen config change error" log noise, but the batch processing of the remaining changeKeys is silently aborted. The new test ClientWorkerTest#testCheckListenCacheSkipsRemovedKey asserts that no NPE-induced batch abort happens when the server returns an unknown changeKey. Without the fix the test fails because the swallowed NPE leaves the local cache's isInitializing() flag unchanged. Assisted-by: Claude Code Signed-off-by: wushiyuanmaimob <wushiyuanwork@outlook.com>
…nCache (re-introduces alibaba#9461) The original fix in alibaba#9461 (milestone 2.2.0, commit c8c64a1) moved the notify computation into refreshContentAndCheck so that the existing cache != null guard would protect both call sites. When the gRPC long- connection variant ConfigRpcTransportClient was introduced in 3.x, a fresh copy of refreshContentAndCheck(RpcClient, String, boolean) was added — its body has a defensive null-check, but the two callers re-introduced the unsafe pattern cacheMap.get().get(changeKey).isInitializing(), defeating the protection. Refactor refreshContentAndCheck(RpcClient, String, boolean) to refreshContentAndCheck(RpcClient, String) so notify = !cache.isInitializing() is computed inside the method, under the existing cache != null guard. Take a single cacheMap.get() snapshot to avoid duplicate volatile reads and replace containsKey + get double-lookup with a single get + null check. Assisted-by: Claude Code Signed-off-by: wushiyuanmaimob <wushiyuanwork@outlook.com>
b24d52d to
b27affa
Compare
Thanks for the heads-up. Spotless violations fixed locally and force-pushed. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
What is the purpose of the change
Fix a regression of PR #9461.
ConfigRpcTransportClient.checkListenCachemaythrow NullPointerException when the server returns a
changeKeyinConfigChangeBatchListenResponsethat has been concurrently removed fromthe local
cacheMap(e.g. user has just calledremoveListener).The unsafe pattern
cacheMap.get().get(changeKey).isInitializing()wasoriginally fixed in PR #9461 (milestone 2.2.0, commit c8c64a1) by moving
the
notifycomputation intorefreshContentAndCheckto share its existingnull-check. When the gRPC long-connection variant
ConfigRpcTransportClientwas introduced in 3.x, a fresh copy of
refreshContentAndCheck(RpcClient, String, boolean)was added — its body has a defensive null-check, but thetwo callers (lines 1125 and 1136 in 3.1.1) re-introduced the unsafe
pre-dereference, defeating the protection.
The NPE is currently swallowed by the surrounding
catch (Throwable)andonly surfaces as
Execute listen config change errorlog noise, but thebatch processing of remaining
changeKeys is aborted whenever it triggers.Brief changelog
ConfigRpcTransportClient.refreshContentAndCheck(RpcClient, String, boolean)torefreshContentAndCheck(RpcClient, String)—notify = !cache.isInitializing()is now computed inside the method,under the existing
cache != nullguard.cacheMap.get()snapshot to avoid duplicate volatile readsand replace
containsKey + getdouble-lookup with a singleget + null check.checkListenCacheaccordingly.ClientWorkerTest#testCheckListenCacheSkipsRemovedKeythat asserts no NPE-induced batch abort when the server returns an unknown
changeKey.Verifying this change
ClientWorkerTest#testCheckListenCacheSkipsRemovedKeyFAILS on
3.1.1(NPE aborts the listenCaches loop) and PASSES with thischange.
ClientWorkerTest#testExecuteConfigListenstill passes —confirming the simpler call signature is behavior-preserving on the happy
path.
ClientWorkerTest(28 tests): all pass.clientmodule (683 tests): all pass.mvn -B clean package apache-rat:check -Dmaven.test.skip=true -pl client -am✅mvn clean install -DskipITs -pl client -am✅mvn checkstyle:check -pl client✅mvn pmd:check -pl client✅Follow this checklist to help us incorporate your contribution quickly and easily:
[ISSUE #15225] Fix regression of #9461mvn -B clean package apache-rat:check -Dmaven.test.skip=trueto make sure basic checks pass. Runmvn clean install -DskipITsto make sure unit-test pass.Closes #15225