btlqql opened a new pull request, #4275:
URL: https://github.com/apache/rocketmq-dashboard/pull/4275

   ## What is the purpose of the change
   
   `POST /api/topics/update` could not remove a topic's stored remark. 
`RocketMQAdminClientImpl.updateTopic` only wrote the cached row when the 
submitted value had text:
   
   ```java
   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 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. `updateById` omits null entity fields 
(`FieldStrategy.NOT_NULL`, no `update-strategy` override in `application.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 is `null`), and assign 
`remark` explicitly through an `UpdateWrapper` when it is cleared, because 
`updateById` skips null entity fields.
   - Echo the persisted remark back on the returned `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:
   
   ```
   mvn -f server/pom.xml -B -DskipITs -Dtest=RocketMQAdminClientImplTest 
-DfailIfNoTests=false test
   [ERROR] Tests run: 48, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 
2.480 s <<< FAILURE! -- in 
org.apache.rocketmq.studio.provider.apache.RocketMQAdminClientImplTest
   [ERROR]   
RocketMQAdminClientImplTest.updateTopicClearsTheStoredRemarkWhenTheRequestSubmitsABlankRemark:638
   [ERROR]   
RocketMQAdminClientImplTest.updateTopicKeepsTheStoredRemarkWhenTheRequestOmitsIt:664
   [INFO] BUILD FAILURE
   ```
   
   `...:638` is `verify(topicMapper).update(isNull(), captor.capture())` (no 
assignment was issued, so the column was never cleared); `...:664` is the 
returned topic still carrying the submitted `null` instead of the persisted 
remark.
   
   Green after the change:
   
   ```
   mvn -f server/pom.xml -B -DskipITs -Dtest=RocketMQAdminClientImplTest 
-DfailIfNoTests=false test
   [INFO] Tests run: 48, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 
2.455 s -- in 
org.apache.rocketmq.studio.provider.apache.RocketMQAdminClientImplTest
   [INFO] BUILD SUCCESS
   ```
   
   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 commit `6c24d2ed`: `Tests run: 2151, 
Failures: 5, Errors: 5` with the identical 10 failing test ids — 8 need a POSIX 
`sh` CLI that this Windows machine does not have (`CliAgentProviderTest`, 
`ClaudeCodeAgentProviderTest`) and 2 are 
`AuthCorsIntegrationTest.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


-- 
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]

Reply via email to