You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by GitBox <gi...@apache.org> on 2023/01/05 01:45:06 UTC

[GitHub] [rocketmq] Oliverwqcwrw opened a new pull request, #5826: [ISSUE #5825] Enhance readability

Oliverwqcwrw opened a new pull request, #5826:
URL: https://github.com/apache/rocketmq/pull/5826

   **Make sure set the target branch to `develop`**
   
   ## What is the purpose of the change
   
   Close #5825 
   
   ## Brief changelog
   
   Enhance readability
   
   ## Verifying this change
   
   XXXX
   
   Follow this checklist to help us incorporate your contribution quickly and easily. Notice, `it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR`.
   
   - [x] Make sure there is a [Github issue](https://github.com/apache/rocketmq/issues) filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue. 
   - [x] Format the pull request title like `[ISSUE #123] Fix UnknownException when host config not exist`. Each commit in the pull request should have a meaningful subject line and body.
   - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
   - [x] Write necessary unit-test(over 80% coverage) to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in [test module](https://github.com/apache/rocketmq/tree/master/test).
   - [x] Run `mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyle` to make sure basic checks pass. Run `mvn clean install -DskipITs` to make sure unit-test pass. Run `mvn clean test-compile failsafe:integration-test`  to make sure integration-test pass.
   - [ ] If this contribution is large, please file an [Apache Individual Contributor License Agreement](http://www.apache.org/licenses/#clas).
   


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] shy-share commented on a diff in pull request #5826: [ISSUE #5825] Enhance Message body readability

Posted by GitBox <gi...@apache.org>.
shy-share commented on code in PR #5826:
URL: https://github.com/apache/rocketmq/pull/5826#discussion_r1062124326


##########
common/src/main/java/org/apache/rocketmq/common/message/Message.java:
##########
@@ -210,7 +210,7 @@ public String toString() {
             "topic='" + topic + '\'' +
             ", flag=" + flag +
             ", properties=" + properties +
-            ", body=" + Arrays.toString(body) +
+            ", body=" + (body != null ? new String(body, StandardCharsets.UTF_8) : "") +

Review Comment:
   > The message body may be very large and compressed or serialized. It's better not to print the message body in `toString` function.
   
   Wasn't it also printed before this modification? Do you mean to delete this directly



-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] Oliverwqcwrw closed pull request #5826: [ISSUE #5825] Enhance Message body readability

Posted by "Oliverwqcwrw (via GitHub)" <gi...@apache.org>.
Oliverwqcwrw closed pull request #5826: [ISSUE #5825] Enhance Message body readability
URL: https://github.com/apache/rocketmq/pull/5826


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] shy-share commented on a diff in pull request #5826: [ISSUE #5825] Enhance Message body readability

Posted by GitBox <gi...@apache.org>.
shy-share commented on code in PR #5826:
URL: https://github.com/apache/rocketmq/pull/5826#discussion_r1062277906


##########
common/src/main/java/org/apache/rocketmq/common/message/Message.java:
##########
@@ -210,7 +210,7 @@ public String toString() {
             "topic='" + topic + '\'' +
             ", flag=" + flag +
             ", properties=" + properties +
-            ", body=" + Arrays.toString(body) +
+            ", body=" + (body != null ? new String(body, StandardCharsets.UTF_8) : "") +

Review Comment:
   Recommended print body size when body size more than 3000,otherwise, it is impossible to distinguish whether the body is empty just by looking at the log



-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] Oliverwqcwrw commented on a diff in pull request #5826: [ISSUE #5825] Enhance Message body readability

Posted by GitBox <gi...@apache.org>.
Oliverwqcwrw commented on code in PR #5826:
URL: https://github.com/apache/rocketmq/pull/5826#discussion_r1062130294


##########
common/src/main/java/org/apache/rocketmq/common/message/Message.java:
##########
@@ -210,7 +210,7 @@ public String toString() {
             "topic='" + topic + '\'' +
             ", flag=" + flag +
             ", properties=" + properties +
-            ", body=" + Arrays.toString(body) +
+            ", body=" + (body != null ? new String(body, StandardCharsets.UTF_8) : "") +

Review Comment:
   IMO, user can choose if to print message body,
   
   so we can provide a readable format when users need to print message body



-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] ShadowySpirits commented on a diff in pull request #5826: [ISSUE #5825] Enhance Message body readability

Posted by GitBox <gi...@apache.org>.
ShadowySpirits commented on code in PR #5826:
URL: https://github.com/apache/rocketmq/pull/5826#discussion_r1062093457


##########
common/src/main/java/org/apache/rocketmq/common/message/Message.java:
##########
@@ -210,7 +210,7 @@ public String toString() {
             "topic='" + topic + '\'' +
             ", flag=" + flag +
             ", properties=" + properties +
-            ", body=" + Arrays.toString(body) +
+            ", body=" + (body != null ? new String(body, StandardCharsets.UTF_8) : "") +

Review Comment:
   The message body may be very large and compressed or serialized. It's better not to print the message body in `toString` function.



-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] leizhiyuan commented on a diff in pull request #5826: [ISSUE #5825] Enhance Message body readability

Posted by GitBox <gi...@apache.org>.
leizhiyuan commented on code in PR #5826:
URL: https://github.com/apache/rocketmq/pull/5826#discussion_r1073296851


##########
common/src/main/java/org/apache/rocketmq/common/message/Message.java:
##########
@@ -228,4 +228,14 @@ public void setDeliverTimeMs(long timeMs) {
     public long getDeliverTimeMs() {
         return Long.parseLong(this.getUserProperty(MessageConst.PROPERTY_TIMER_DELIVER_MS));
     }
+
+    private String getBodyStr(byte[] body) {
+        if (body == null) {
+            return "body is null";
+        }
+        if (body.length > 3000) {

Review Comment:
   maybe a better way is use the first 3000 characters? 



-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] codecov-commenter commented on pull request #5826: [ISSUE #5825] Enhance Message body readability

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #5826:
URL: https://github.com/apache/rocketmq/pull/5826#issuecomment-1371713791

   # [Codecov](https://codecov.io/gh/apache/rocketmq/pull/5826?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#5826](https://codecov.io/gh/apache/rocketmq/pull/5826?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (60f9e47) into [develop](https://codecov.io/gh/apache/rocketmq/commit/b1d87f405e4e3511aebe0ce15603275e8e0da9ca?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b1d87f4) will **decrease** coverage by `0.04%`.
   > The diff coverage is `n/a`.
   
   ```diff
   @@              Coverage Diff              @@
   ##             develop    #5826      +/-   ##
   =============================================
   - Coverage      42.41%   42.36%   -0.05%     
   + Complexity      8229     8216      -13     
   =============================================
     Files           1060     1060              
     Lines          73393    73392       -1     
     Branches        9602     9602              
   =============================================
   - Hits           31128    31096      -32     
   - Misses         38352    38374      +22     
   - Partials        3913     3922       +9     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/rocketmq/pull/5826?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...va/org/apache/rocketmq/common/message/Message.java](https://codecov.io/gh/apache/rocketmq/pull/5826?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9jb21tb24vbWVzc2FnZS9NZXNzYWdlLmphdmE=) | `55.29% <ø> (+0.64%)` | :arrow_up: |
   | [...rg/apache/rocketmq/common/stats/StatsSnapshot.java](https://codecov.io/gh/apache/rocketmq/pull/5826?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9jb21tb24vc3RhdHMvU3RhdHNTbmFwc2hvdC5qYXZh) | `84.61% <0.00%> (-15.39%)` | :arrow_down: |
   | [...e/rocketmq/broker/longpolling/ManyPullRequest.java](https://codecov.io/gh/apache/rocketmq/pull/5826?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnJva2VyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9icm9rZXIvbG9uZ3BvbGxpbmcvTWFueVB1bGxSZXF1ZXN0LmphdmE=) | `61.53% <0.00%> (-15.39%)` | :arrow_down: |
   | [...tmq/broker/longpolling/PullRequestHoldService.java](https://codecov.io/gh/apache/rocketmq/pull/5826?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnJva2VyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9icm9rZXIvbG9uZ3BvbGxpbmcvUHVsbFJlcXVlc3RIb2xkU2VydmljZS5qYXZh) | `56.86% <0.00%> (-6.87%)` | :arrow_down: |
   | [...org/apache/rocketmq/store/ha/WaitNotifyObject.java](https://codecov.io/gh/apache/rocketmq/pull/5826?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3RvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3N0b3JlL2hhL1dhaXROb3RpZnlPYmplY3QuamF2YQ==) | `80.35% <0.00%> (-5.36%)` | :arrow_down: |
   | [...va/org/apache/rocketmq/common/stats/StatsItem.java](https://codecov.io/gh/apache/rocketmq/pull/5826?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9jb21tb24vc3RhdHMvU3RhdHNJdGVtLmphdmE=) | `50.00% <0.00%> (-5.00%)` | :arrow_down: |
   | [...tmq/remoting/protocol/body/ConsumerConnection.java](https://codecov.io/gh/apache/rocketmq/pull/5826?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cmVtb3Rpbmcvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3JlbW90aW5nL3Byb3RvY29sL2JvZHkvQ29uc3VtZXJDb25uZWN0aW9uLmphdmE=) | `95.83% <0.00%> (-4.17%)` | :arrow_down: |
   | [...controller/impl/DefaultBrokerHeartbeatManager.java](https://codecov.io/gh/apache/rocketmq/pull/5826?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcm9ja2V0bXEvY29udHJvbGxlci9pbXBsL0RlZmF1bHRCcm9rZXJIZWFydGJlYXRNYW5hZ2VyLmphdmE=) | `82.27% <0.00%> (-3.80%)` | :arrow_down: |
   | [...org/apache/rocketmq/common/stats/StatsItemSet.java](https://codecov.io/gh/apache/rocketmq/pull/5826?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9jb21tb24vc3RhdHMvU3RhdHNJdGVtU2V0LmphdmE=) | `41.79% <0.00%> (-2.99%)` | :arrow_down: |
   | [...ent/impl/consumer/DefaultLitePullConsumerImpl.java](https://codecov.io/gh/apache/rocketmq/pull/5826?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2xpZW50L3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9jbGllbnQvaW1wbC9jb25zdW1lci9EZWZhdWx0TGl0ZVB1bGxDb25zdW1lckltcGwuamF2YQ==) | `68.75% <0.00%> (-1.10%)` | :arrow_down: |
   | ... and [10 more](https://codecov.io/gh/apache/rocketmq/pull/5826?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] caigy commented on a diff in pull request #5826: [ISSUE #5825] Enhance Message body readability

Posted by GitBox <gi...@apache.org>.
caigy commented on code in PR #5826:
URL: https://github.com/apache/rocketmq/pull/5826#discussion_r1062135784


##########
common/src/main/java/org/apache/rocketmq/common/message/Message.java:
##########
@@ -210,7 +210,7 @@ public String toString() {
             "topic='" + topic + '\'' +
             ", flag=" + flag +
             ", properties=" + properties +
-            ", body=" + Arrays.toString(body) +
+            ", body=" + (body != null ? new String(body, StandardCharsets.UTF_8) : "") +

Review Comment:
   > IMO, user can choose if to print message body,
   > 
   > so we can provide a readable format when users need to print message body
   
   +1. Maybe we can check the size of message body first and only print the message body if the size is small.



-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] ShadowySpirits commented on a diff in pull request #5826: [ISSUE #5825] Enhance Message body readability

Posted by GitBox <gi...@apache.org>.
ShadowySpirits commented on code in PR #5826:
URL: https://github.com/apache/rocketmq/pull/5826#discussion_r1062137437


##########
common/src/main/java/org/apache/rocketmq/common/message/Message.java:
##########
@@ -210,7 +210,7 @@ public String toString() {
             "topic='" + topic + '\'' +
             ", flag=" + flag +
             ", properties=" + properties +
-            ", body=" + Arrays.toString(body) +
+            ", body=" + (body != null ? new String(body, StandardCharsets.UTF_8) : "") +

Review Comment:
   > > The message body may be very large and compressed or serialized. It's better not to print the message body in `toString` function.
   > 
   > Wasn't it also printed before this modification? Do you mean to delete this directly
   
   Maybe print body size instead.



-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] Oliverwqcwrw commented on a diff in pull request #5826: [ISSUE #5825] Enhance Message body readability

Posted by GitBox <gi...@apache.org>.
Oliverwqcwrw commented on code in PR #5826:
URL: https://github.com/apache/rocketmq/pull/5826#discussion_r1062198930


##########
common/src/main/java/org/apache/rocketmq/common/message/Message.java:
##########
@@ -210,7 +210,7 @@ public String toString() {
             "topic='" + topic + '\'' +
             ", flag=" + flag +
             ", properties=" + properties +
-            ", body=" + Arrays.toString(body) +
+            ", body=" + (body != null ? new String(body, StandardCharsets.UTF_8) : "") +

Review Comment:
   > > IMO, user can choose if to print message body,
   > > so we can provide a readable format when users need to print message body
   > 
   > +1. Maybe we can check the size of message body first and only print the message body if the size is small.
   
   Good idea, I have limited the length to 3000 at present,WDYT :-)



-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] Oliverwqcwrw commented on pull request #5826: [ISSUE #5825] Enhance Message body readability

Posted by GitBox <gi...@apache.org>.
Oliverwqcwrw commented on PR #5826:
URL: https://github.com/apache/rocketmq/pull/5826#issuecomment-1371998678

   > Recommended print body size when body size more than 3000,otherwise, it is impossible to distinguish whether the body is empty just by looking at the log
   
   done


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] ni-ze commented on a diff in pull request #5826: [ISSUE #5825] Enhance Message body readability

Posted by GitBox <gi...@apache.org>.
ni-ze commented on code in PR #5826:
URL: https://github.com/apache/rocketmq/pull/5826#discussion_r1063034257


##########
common/src/main/java/org/apache/rocketmq/common/message/Message.java:
##########
@@ -210,7 +210,7 @@ public String toString() {
             "topic='" + topic + '\'' +
             ", flag=" + flag +
             ", properties=" + properties +
-            ", body=" + Arrays.toString(body) +
+            ", body=" + (body != null ? new String(body, StandardCharsets.UTF_8) : "") +

Review Comment:
   Do not print body is better, because the serialize of body is unknown.



-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org