Repository navigation
fix(topic): allow a blank update to clear the persisted topic remark - #4275
Merged
lizhimins merged 1 commit intoSep 15, 2026
Merged
Conversation
RockteMQ-AI
approved these changes
Sep 13, 2026
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
Fix for topic remark not being cleared when a blank value is submitted. This PR also introduces an important semantic distinction: null remark = omitted (keep stored value), blank remark = explicitly cleared.
Review
Correctness ✅
- The
clearRemarkflag correctly distinguishes between omitted (null) and explicitly cleared (blank) remarks. - When
clearRemarkis true, the entity field is set to null (skipped byupdateById), then an explicitUpdateWrapperSET NULL follows — same pattern as #3342, #4276, #4277. - The response fix (
topic.setRemark(existing.getRemark())) ensures the returned VO reflects the persisted state, preventing the UI from displaying stale data.
Tests ✅
- Two new tests cover both the clear path (blank remark → null in DB) and the no-op path (omitted remark → stored value retained).
- ArgumentCaptor assertions verify the exact SQL and parameter values.
Code quality ✅
- Clear inline comments explaining the null-vs-blank semantics and the MyBatis-Plus workaround.
- The response fix is a thoughtful addition that prevents UI confusion.
LGTM.
`RocketMQAdminClientImpl.updateTopic` only wrote the cached row's remark when the submitted value
had text:
if (StringUtils.hasText(topic.getRemark())) {
existing.setRemark(topic.getRemark());
}
so a blank submission behaved exactly like an omitted one. `TopicVO.remark` / `UpdateTopicDTO.remark`
are plain nullable strings with no validation and there is no separate clear flag (unlike
`clearApiKey` / `clearDingtalkSigningSecret` in general settings), so a blank remark is the only way
a caller can say "this topic has no remark" - and that value was discarded. The `rmq_instance_topic`
row therefore keeps the previous remark while the endpoint answers 200, and the topic list shows the
old text again on the next load.
Clearing the column is a two-part change. `updateById` omits null entity fields
(`FieldStrategy.NOT_NULL`), the same mechanism already handled for the ACL user/rule columns in
apache#3342, so the cleared remark is assigned explicitly instead of relying on the entity write. An
omitted remark still keeps the stored value, which is the partial-update behaviour the existing
comment in this method describes.
The response now reports the persisted remark instead of the submitted one, so a clear and an
omitted value cannot be reported as a state the database does not hold.
`RocketMQAdminClientImplTest` pins both directions: a blank remark clears the column through an
explicit assignment (and the returned topic is empty), while an omitted remark keeps the stored value
and issues no assignment at all.
Fixes apache#4272
Signed-off-by: btlqql <2977859784@qq.com>
(cherry picked from commit 925958f)
lizhimins
force-pushed
the
codex/btl-topic-remark-clear
branch
from
September 15, 2026 12:25
925958f to
86447a8
Compare
7 tasks done
4 tasks done
4 tasks done
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.
What is the purpose of the change
POST /api/topics/updatecould not remove a topic's stored remark.RocketMQAdminClientImpl.updateTopiconly wrote the cached row when the submitted value had text:so a blank submission behaved exactly like an omitted one.
TopicVO.remark/UpdateTopicDTO.remarkare plain nullable strings with no validation and there is no separate clear flag (unlikeclearApiKey/clearDingtalkSigningSecretin general settings), so a blank remark is the only way a caller can say "this topic has no remark" — and that value was discarded. Thermq_instance_topicrow kept the previous remark while the endpoint answered 200, so the topic list showed the old text again on the next load.Clearing is a two-part change.
updateByIdomits null entity fields (FieldStrategy.NOT_NULL, noupdate-strategyoverride inapplication.yml), which is the mechanism already handled for the ACL user/rule columns in #3342, so the cleared remark is assigned explicitly instead of relying on the entity write. An omitted remark still keeps the stored value, which is the partial-update behaviour the existing comment in this method describes.The response now reports the persisted remark rather than the submitted one, so a clear and an omitted value cannot be reported as a state the database does not hold.
Brief changelog
RocketMQAdminClientImpl.updateTopic: treat a submitted blank remark as a clear (keep the stored value only when the remark isnull), and assignremarkexplicitly through anUpdateWrapperwhen it is cleared, becauseupdateByIdskips null entity fields.TopicVO.RocketMQAdminClientImplTest: two new cases — a blank remark clears the column and returns an empty remark; an omitted remark keeps the stored value and issues no extra assignment.Verification
Red first, on the unmodified implementation with only the new tests added:
...:638isverify(topicMapper).update(isNull(), captor.capture())(no assignment was issued, so the column was never cleared);...:664is the returned topic still carrying the submittednullinstead of the persisted remark.Green after the change:
Whole backend suite on this branch (
mvn -f server/pom.xml -B -DskipITs test):Tests run: 2153, Failures: 5, Errors: 5, Skipped: 0. I also ran the same command on the unmodified base commit6c24d2ed:Tests run: 2151, Failures: 5, Errors: 5with the identical 10 failing test ids — 8 need a POSIXshCLI that this Windows machine does not have (CliAgentProviderTest,ClaudeCodeAgentProviderTest) and 2 areAuthCorsIntegrationTest.shouldRejectNonAdminMutationBeforeControllerExecution/shouldStillRejectAnonymousProtectedRequests, which also fail on the base and are aligned separately in #4217. No other test moved.The DB path itself was not exercised end to end here (no MySQL in this environment); the regression test asserts the assignment that the fix issues, in the same style as the accepted ACL fix in #3342.
Fixes #4272