You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "yao-wenbin (via GitHub)" <gi...@apache.org> on 2023/08/21 07:58:44 UTC

[GitHub] [rocketmq] yao-wenbin opened a new pull request, #7217: [ISSUE #7171] add misspell check in configuration during broker startup.

yao-wenbin opened a new pull request, #7217:
URL: https://github.com/apache/rocketmq/pull/7217

   
   
   <!-- Please make sure the target branch is right. In most case, the target branch should be `develop`. -->
   
   ### Which Issue(s) This PR Fixes
   
   #7171 improve the use experience for user.
   
   <!-- Please ensure that the related issue has already been created, and [link this pull request to that issue using keywords](<https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword>) to ensure automatic closure. -->
   
   Fixes #issue_id
   
   ### Brief Description
   
   by add misspell check during load configuration file.
   when user's configuration file has incorrect properties, they will get clearly warning log in console.
   such as below:
   <img width="1171" alt="image" src="https://github.com/apache/rocketmq/assets/67348866/57859d36-c94b-4b0d-81bf-ea57343a1ec9">
   
   <img width="1455" alt="image" src="https://github.com/apache/rocketmq/assets/67348866/dcbd1a39-b27a-467e-b6ca-9ad9591ae4fe">
   
   <!-- Write a brief description for your pull request to help the maintainer understand the reasons behind your changes. -->
   
   ### How Did You Test This Change?
   
   <!-- In order to ensure the code quality of Apache RocketMQ, we expect every pull request to have undergone thorough testing. -->
   
   add misspell check before loading properties to config entity. you can see the detail by files change tab.
   ```


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


Re: [PR] [ISSUE #7171] add misspell check in configuration during broker startup. [rocketmq]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #7217:
URL: https://github.com/apache/rocketmq/pull/7217#issuecomment-2309061030

   This PR was closed because it has been inactive for 3 days since being marked as stale.


-- 
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] yao-wenbin commented on a diff in pull request #7217: [ISSUE #7171] add misspell check in configuration during broker startup.

Posted by "yao-wenbin (via GitHub)" <gi...@apache.org>.
yao-wenbin commented on code in PR #7217:
URL: https://github.com/apache/rocketmq/pull/7217#discussion_r1301067843


##########
common/src/main/java/org/apache/rocketmq/common/MixAll.java:
##########
@@ -518,4 +520,25 @@ public static boolean isSysConsumerGroupForNoColdReadLimit(String consumerGroup)
         }
         return false;
     }
+
+    public static Set<String> invalidProperties(Properties properties, Object... objects) {
+        if (objects == null || objects.length == 0) {
+            return null;
+        }
+        Set<String> propertyNames = properties.stringPropertyNames();
+
+        Set<String> fieldNames = new HashSet<>();
+        for (Object obj : objects) {
+            Method[] methods = obj.getClass().getMethods();
+            for (Method method : methods) {
+                String mn = method.getName();
+                if (mn.startsWith("get")) {
+                    // get getter's field name and to camel name.
+                    fieldNames.add(mn.substring(3, 4).toLowerCase() +  mn.substring(4));
+                }
+            }
+        }
+
+        return Sets.difference(propertyNames, fieldNames);

Review Comment:
   I'm a little confused. The difference method  only return a set of property in property name set (which is user configure) but not in field names set (which is RocketMQ Configuration Item). So I think it will correctly record the invalid property name set in user's configuration file.
   I write some test case in ``MixAllTest.java``, It would be  better explain that when logging will be missed if you could give me some clearly test case.~



-- 
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 #7217: [ISSUE #7171] add misspell check in configuration during broker startup.

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #7217:
URL: https://github.com/apache/rocketmq/pull/7217#issuecomment-1686034763

   ## [Codecov](https://app.codecov.io/gh/apache/rocketmq/pull/7217?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   > Merging [#7217](https://app.codecov.io/gh/apache/rocketmq/pull/7217?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (ec9995d) into [develop](https://app.codecov.io/gh/apache/rocketmq/commit/72d796f2b20b3ec6aebca8c004d9275d7c749a95?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (72d796f) will **increase** coverage by `0.02%`.
   > The diff coverage is `78.94%`.
   
   ```diff
   @@              Coverage Diff              @@
   ##             develop    #7217      +/-   ##
   =============================================
   + Coverage      42.46%   42.49%   +0.02%     
     Complexity      9353     9353              
   =============================================
     Files           1149     1149              
     Lines          82111    82130      +19     
     Branches       10703    10707       +4     
   =============================================
   + Hits           34868    34900      +32     
   + Misses         42882    42846      -36     
   - Partials        4361     4384      +23     
   ```
   
   
   | [Files Changed](https://app.codecov.io/gh/apache/rocketmq/pull/7217?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [...java/org/apache/rocketmq/broker/BrokerStartup.java](https://app.codecov.io/gh/apache/rocketmq/pull/7217?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-YnJva2VyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9icm9rZXIvQnJva2VyU3RhcnR1cC5qYXZh) | `43.03% <75.00%> (+37.29%)` | :arrow_up: |
   | [...c/main/java/org/apache/rocketmq/common/MixAll.java](https://app.codecov.io/gh/apache/rocketmq/pull/7217?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9jb21tb24vTWl4QWxsLmphdmE=) | `40.89% <81.81%> (+1.90%)` | :arrow_up: |
   
   ... and [34 files with indirect coverage changes](https://app.codecov.io/gh/apache/rocketmq/pull/7217/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   :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=apache)
   


-- 
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] joeCarf commented on a diff in pull request #7217: [ISSUE #7171] add misspell check in configuration during broker startup.

Posted by "joeCarf (via GitHub)" <gi...@apache.org>.
joeCarf commented on code in PR #7217:
URL: https://github.com/apache/rocketmq/pull/7217#discussion_r1301389441


##########
common/src/main/java/org/apache/rocketmq/common/MixAll.java:
##########
@@ -518,4 +520,25 @@ public static boolean isSysConsumerGroupForNoColdReadLimit(String consumerGroup)
         }
         return false;
     }
+
+    public static Set<String> invalidProperties(Properties properties, Object... objects) {
+        if (objects == null || objects.length == 0) {
+            return null;
+        }
+        Set<String> propertyNames = properties.stringPropertyNames();
+
+        Set<String> fieldNames = new HashSet<>();
+        for (Object obj : objects) {
+            Method[] methods = obj.getClass().getMethods();
+            for (Method method : methods) {
+                String mn = method.getName();
+                if (mn.startsWith("get")) {
+                    // get getter's field name and to camel name.
+                    fieldNames.add(mn.substring(3, 4).toLowerCase() +  mn.substring(4));
+                }
+            }
+        }
+
+        return Sets.difference(propertyNames, fieldNames);

Review Comment:
   Gotcha!there are tests failures, plz fix it :)
   <img width="1270" alt="image" src="https://github.com/apache/rocketmq/assets/52153761/5489eb96-f0a9-4bd1-943d-452642772770">
   



##########
common/src/main/java/org/apache/rocketmq/common/MixAll.java:
##########
@@ -518,4 +520,25 @@ public static boolean isSysConsumerGroupForNoColdReadLimit(String consumerGroup)
         }
         return false;
     }
+
+    public static Set<String> invalidProperties(Properties properties, Object... objects) {
+        if (objects == null || objects.length == 0) {
+            return null;
+        }
+        Set<String> propertyNames = properties.stringPropertyNames();
+
+        Set<String> fieldNames = new HashSet<>();
+        for (Object obj : objects) {
+            Method[] methods = obj.getClass().getMethods();
+            for (Method method : methods) {
+                String mn = method.getName();
+                if (mn.startsWith("get")) {
+                    // get getter's field name and to camel name.
+                    fieldNames.add(mn.substring(3, 4).toLowerCase() +  mn.substring(4));
+                }
+            }
+        }
+
+        return Sets.difference(propertyNames, fieldNames);

Review Comment:
   Gotcha!there are tests failures, plz fix it :)
   <img width="1270" alt="image" src="https://github.com/apache/rocketmq/assets/52153761/5489eb96-f0a9-4bd1-943d-452642772770">
   



-- 
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] yao-wenbin commented on a diff in pull request #7217: [ISSUE #7171] add misspell check in configuration during broker startup.

Posted by "yao-wenbin (via GitHub)" <gi...@apache.org>.
yao-wenbin commented on code in PR #7217:
URL: https://github.com/apache/rocketmq/pull/7217#discussion_r1301067843


##########
common/src/main/java/org/apache/rocketmq/common/MixAll.java:
##########
@@ -518,4 +520,25 @@ public static boolean isSysConsumerGroupForNoColdReadLimit(String consumerGroup)
         }
         return false;
     }
+
+    public static Set<String> invalidProperties(Properties properties, Object... objects) {
+        if (objects == null || objects.length == 0) {
+            return null;
+        }
+        Set<String> propertyNames = properties.stringPropertyNames();
+
+        Set<String> fieldNames = new HashSet<>();
+        for (Object obj : objects) {
+            Method[] methods = obj.getClass().getMethods();
+            for (Method method : methods) {
+                String mn = method.getName();
+                if (mn.startsWith("get")) {
+                    // get getter's field name and to camel name.
+                    fieldNames.add(mn.substring(3, 4).toLowerCase() +  mn.substring(4));
+                }
+            }
+        }
+
+        return Sets.difference(propertyNames, fieldNames);

Review Comment:
   I'm a little confused. The difference method  only return a set of property in property name set (which is user configure) but not in field names set (which is RocketMQ Configuration Item). So I think it will correctly record the invalid property name set in user's configuration file.
   I have some test case in ``MixAllTest.java``, It would be  better explain that when logging will be missed if you could give me some clearly test case.~



-- 
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] joeCarf commented on a diff in pull request #7217: [ISSUE #7171] add misspell check in configuration during broker startup.

Posted by "joeCarf (via GitHub)" <gi...@apache.org>.
joeCarf commented on code in PR #7217:
URL: https://github.com/apache/rocketmq/pull/7217#discussion_r1300974924


##########
common/src/main/java/org/apache/rocketmq/common/MixAll.java:
##########
@@ -518,4 +520,25 @@ public static boolean isSysConsumerGroupForNoColdReadLimit(String consumerGroup)
         }
         return false;
     }
+
+    public static Set<String> invalidProperties(Properties properties, Object... objects) {
+        if (objects == null || objects.length == 0) {
+            return null;
+        }
+        Set<String> propertyNames = properties.stringPropertyNames();
+
+        Set<String> fieldNames = new HashSet<>();
+        for (Object obj : objects) {
+            Method[] methods = obj.getClass().getMethods();
+            for (Method method : methods) {
+                String mn = method.getName();
+                if (mn.startsWith("get")) {
+                    // get getter's field name and to camel name.
+                    fieldNames.add(mn.substring(3, 4).toLowerCase() +  mn.substring(4));
+                }
+            }
+        }
+
+        return Sets.difference(propertyNames, fieldNames);

Review Comment:
   I think it may miss logging when propertyNames not contains all fieldNames



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


Re: [PR] [ISSUE #7171] add misspell check in configuration during broker startup. [rocketmq]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #7217:
URL: https://github.com/apache/rocketmq/pull/7217#issuecomment-2305944955

   This PR is stale because it has been open for 365 days with no activity. It will be closed in 3 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this PR.


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


Re: [PR] [ISSUE #7171] add misspell check in configuration during broker startup. [rocketmq]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #7217: [ISSUE #7171] add misspell check in configuration during broker startup. 
URL: https://github.com/apache/rocketmq/pull/7217


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