tju-yxq opened a new issue, #1392:
URL: https://github.com/apache/rocketmq-dashboard/issues/1392

   ## Bug Report
   
   ### Before Creating the Bug Report
   
   - [x] I found a bug, not just asking a question, which should be created in 
[GitHub Discussions](https://github.com/apache/rocketmq/discussions).
   - [x] I have searched the [GitHub 
Issues](https://github.com/apache/rocketmq/issues) and [GitHub 
Discussions](https://github.com/apache/rocketmq/discussions) of this repository 
and believe that this is not a duplicate.
   - [x] I have confirmed that this bug belongs to the current repository, not 
other repositories of RocketMQ.
   
   ### Runtime platform environment
   
   OS: Ubuntu 20.04 / Any OS running RocketMQ Studio
   
   ### RocketMQ version
   
   branch: rocketmq-studio
   version: 5.3.2+
   Git commit id: f727341
   
   ### JDK Version
   
   OpenJDK 21
   
   ### Describe the Bug
   
   `RocketMQAdminClientImpl.updateTopic()` updates the broker-side topic 
configuration (queue counts and permission) but **does not persist `topicType` 
or `remark` changes to the database**. When a user updates a topic's type 
(e.g., from `NORMAL` to a Lite Topic type) or changes the remark/description, 
the broker config is updated successfully, but the Studio database record 
retains the old values. The UI then displays stale topic type and remark 
information.
   
   The `UpdateTopicDTO` explicitly accepts `type` and `remark` fields, and the 
`createTopic` method persists both. However, `updateTopic` only persists 
`writeQueues`, `readQueues`, `perm`, and `updatedAt`:
   
   ```java
   // updateTopic - DB update section (line ~190):
   if (existing != null) {
       existing.setWriteQueueNums(writeQueues);   // updated
       existing.setReadQueueNums(readQueues);     // updated
       existing.setPerm(topicConfig.getPerm());   // updated
       existing.setUpdatedAt(LocalDateTime.now()); // updated
       // MISSING: existing.setTopicType(...)
       // MISSING: existing.setRemark(...)
       topicMapper.updateById(existing);
   }
   ```
   
   Compare with `createTopic`, which correctly sets both fields:
   ```java
   // createTopic - DB persistence (line ~175):
   entity.setTopicType(topic.getType() != null ? topic.getType().name() : 
"NORMAL");
   if (StringUtils.hasText(topic.getRemark())) {
       entity.setRemark(topic.getRemark());
   }
   ```
   
   ### Steps to Reproduce
   
   1. Create a topic with type `NORMAL` and remark `"test topic"`.
   2. Open the topic edit dialog in RocketMQ Studio.
   3. Change the topic type to a different value (if supported by the UI) and 
update the remark to `"updated remark"`.
   4. Submit the update.
   5. Refresh the topic list and observe: the remark still shows `"test topic"` 
and the type still shows `NORMAL`.
   6. Verify on the broker that the queue count and permission changes were 
applied (they were, because the broker API call succeeded).
   
   ### What Did You Expect to See?
   
   The database record should reflect the updated `topicType` and `remark` 
values after a successful `updateTopic` call, matching the behavior of 
`createTopic`.
   
   ### What Did You See Instead?
   
   The database record keeps the original `topicType` and `remark` values. Only 
`writeQueues`, `readQueues`, `perm`, and `updatedAt` are updated.
   
   ### Additional Context
   
   **Affected file**: 
`server/src/main/java/org/apache/rocketmq/studio/provider/apache/RocketMQAdminClientImpl.java`,
 method `updateTopic()` at approximately line 185.
   
   **Also**: The `sendMessage` method has a dead variable `fullTopic` (line 
~327) that is computed but never used:
   ```java
   String fullTopic = tag.isEmpty() ? topic : topic + ":" + tag;  // never used
   Message msg = new Message(topic, tag, key, 
body.getBytes(StandardCharsets.UTF_8));
   ```
   This should be removed to avoid confusion.
   
   ### Fix suggestion
   
   In the `updateTopic` method, add `topicType` and `remark` updates to the DB 
record:
   
   ```java
   if (existing != null) {
       existing.setWriteQueueNums(writeQueues);
       existing.setReadQueueNums(readQueues);
       existing.setPerm(topicConfig.getPerm());
       if (topic.getType() != null) {
           existing.setTopicType(topic.getType().name());
       }
       if (StringUtils.hasText(topic.getRemark())) {
           existing.setRemark(topic.getRemark());
       }
       existing.setUpdatedAt(LocalDateTime.now());
       topicMapper.updateById(existing);
   }
   ```
   
   This adds approximately 6 lines to the existing update block. No existing 
logic is deleted - the current `setWriteQueues`, `setReadQueues`, `setPerm`, 
and `setUpdatedAt` calls are preserved.
   


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