You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@eventmesh.apache.org by "sanskar-thakur (via GitHub)" <gi...@apache.org> on 2023/03/01 17:18:01 UTC

[GitHub] [incubator-eventmesh] sanskar-thakur opened a new pull request, #3320: [ISSUE #3084] Reliance on default encoding[FileLoad]

sanskar-thakur opened a new pull request, #3320:
URL: https://github.com/apache/incubator-eventmesh/pull/3320

   Fixes #3084 .
   
   ### Modifications
   
   1. Specified charset with input-stream-reader API.
   2. Used try-with-resources and handled io stream close.
   
   ### Documentation
   
   - Does this pull request introduce a new feature? **(no)**
   - If yes, how is the feature documented? **(not applicable)**
   - If a feature is not applicable for documentation, explain why? **(bug fix)**
   - If a feature is not documented yet in this PR, please create a followup issue for adding the documentation **(not applicable)**
   


-- 
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: dev-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org


[GitHub] [incubator-eventmesh] Alonexc commented on a diff in pull request #3320: [ISSUE #3084] Reliance on default encoding[FileLoad]

Posted by "Alonexc (via GitHub)" <gi...@apache.org>.
Alonexc commented on code in PR #3320:
URL: https://github.com/apache/incubator-eventmesh/pull/3320#discussion_r1123967910


##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/config/FileLoad.java:
##########
@@ -68,9 +72,28 @@ class PropertiesFileLoad implements FileLoad {
         public <T> T getConfig(ConfigInfo configInfo) throws IOException {
             final Properties properties = new Properties();
             if (StringUtils.isNotBlank(configInfo.getResourceUrl())) {
-                properties.load(new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(configInfo.getResourceUrl()))));
+                try (InputStreamReader reader = new InputStreamReader(
+                    Objects.requireNonNull(getClass().getResourceAsStream(configInfo.getResourceUrl())), Constants.DEFAULT_CHARSET)) {
+                    properties.load(new BufferedReader(reader));
+                }
             } else {
-                properties.load(new BufferedReader(new FileReader(configInfo.getFilePath())));
+                FileReader reader = null;
+                try {

Review Comment:
   Here you can also change to use try-with-resources, as well as specify the character set.
   I have a suggestion, how about you look at:
   ![image](https://user-images.githubusercontent.com/91315508/222616612-1f3ce3ba-804b-4827-a451-557188592f83.png)
   



-- 
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: dev-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org


[GitHub] [incubator-eventmesh] xwm1992 merged pull request #3320: [ISSUE #3084] Reliance on default encoding[FileLoad]

Posted by "xwm1992 (via GitHub)" <gi...@apache.org>.
xwm1992 merged PR #3320:
URL: https://github.com/apache/incubator-eventmesh/pull/3320


-- 
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: dev-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org


[GitHub] [incubator-eventmesh] sanskar-thakur commented on a diff in pull request #3320: [ISSUE #3084] Reliance on default encoding[FileLoad]

Posted by "sanskar-thakur (via GitHub)" <gi...@apache.org>.
sanskar-thakur commented on code in PR #3320:
URL: https://github.com/apache/incubator-eventmesh/pull/3320#discussion_r1133122299


##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/config/FileLoad.java:
##########
@@ -68,9 +72,28 @@ class PropertiesFileLoad implements FileLoad {
         public <T> T getConfig(ConfigInfo configInfo) throws IOException {
             final Properties properties = new Properties();
             if (StringUtils.isNotBlank(configInfo.getResourceUrl())) {
-                properties.load(new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(configInfo.getResourceUrl()))));
+                try (InputStreamReader reader = new InputStreamReader(
+                    Objects.requireNonNull(getClass().getResourceAsStream(configInfo.getResourceUrl())), Constants.DEFAULT_CHARSET)) {
+                    properties.load(new BufferedReader(reader));
+                }
             } else {
-                properties.load(new BufferedReader(new FileReader(configInfo.getFilePath())));
+                FileReader reader = null;
+                try {

Review Comment:
   Agreed. Updated this code block with try-with-resources.



-- 
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: dev-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org


[GitHub] [incubator-eventmesh] xwm1992 commented on pull request #3320: [ISSUE #3084] Reliance on default encoding[FileLoad]

Posted by "xwm1992 (via GitHub)" <gi...@apache.org>.
xwm1992 commented on PR #3320:
URL: https://github.com/apache/incubator-eventmesh/pull/3320#issuecomment-1451601468

   <img width="1141" alt="image" src="https://user-images.githubusercontent.com/13237619/222395445-b9e5a7ff-6efa-44ed-86b9-5ff8deec2fa3.png">
   @sanskar-thakur please fix the ci check error, take care of package import order.


-- 
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: dev-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org


[GitHub] [incubator-eventmesh] codecov[bot] commented on pull request #3320: [ISSUE #3084] Reliance on default encoding[FileLoad]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #3320:
URL: https://github.com/apache/incubator-eventmesh/pull/3320#issuecomment-1464965925

   ## [Codecov](https://codecov.io/gh/apache/incubator-eventmesh/pull/3320?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 [#3320](https://codecov.io/gh/apache/incubator-eventmesh/pull/3320?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (89303fb) into [master](https://codecov.io/gh/apache/incubator-eventmesh/commit/6636e3af2ef130a47ecd3276e14aa34f0232b583?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (6636e3a) will **increase** coverage by `0.80%`.
   > The diff coverage is `23.54%`.
   
   > :exclamation: Current head 89303fb differs from pull request most recent head dd0ac82. Consider uploading reports for the commit dd0ac82 to get more accurate results
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #3320      +/-   ##
   ============================================
   + Coverage     13.09%   13.89%   +0.80%     
   - Complexity     1159     1435     +276     
   ============================================
     Files           550      635      +85     
     Lines         28718    31371    +2653     
     Branches       2854     3010     +156     
   ============================================
   + Hits           3761     4360     +599     
   - Misses        24632    26634    +2002     
   - Partials        325      377      +52     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-eventmesh/pull/3320?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...in/java/org/apache/eventmesh/common/Constants.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/3320?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXZlbnRtZXNoLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZXZlbnRtZXNoL2NvbW1vbi9Db25zdGFudHMuamF2YQ==) | `85.71% <ø> (ø)` | |
   | [...esh/common/protocol/grpc/protos/EventmeshGrpc.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/3320?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXZlbnRtZXNoLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZXZlbnRtZXNoL2NvbW1vbi9wcm90b2NvbC9ncnBjL3Byb3Rvcy9FdmVudG1lc2hHcnBjLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...tmesh/common/protocol/http/common/ProtocolKey.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/3320?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXZlbnRtZXNoLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZXZlbnRtZXNoL2NvbW1vbi9wcm90b2NvbC9odHRwL2NvbW1vbi9Qcm90b2NvbEtleS5qYXZh) | `0.00% <ø> (ø)` | |
   | [...pache/eventmesh/common/protocol/tcp/UserAgent.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/3320?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXZlbnRtZXNoLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZXZlbnRtZXNoL2NvbW1vbi9wcm90b2NvbC90Y3AvVXNlckFnZW50LmphdmE=) | `2.40% <0.00%> (-0.16%)` | :arrow_down: |
   | [...entmesh/connector/kafka/consumer/ConsumerImpl.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/3320?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXZlbnRtZXNoLWNvbm5lY3Rvci1wbHVnaW4vZXZlbnRtZXNoLWNvbm5lY3Rvci1rYWZrYS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZXZlbnRtZXNoL2Nvbm5lY3Rvci9rYWZrYS9jb25zdW1lci9Db25zdW1lckltcGwuamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [...sh/connector/kafka/consumer/KafkaConsumerImpl.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/3320?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXZlbnRtZXNoLWNvbm5lY3Rvci1wbHVnaW4vZXZlbnRtZXNoLWNvbm5lY3Rvci1rYWZrYS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZXZlbnRtZXNoL2Nvbm5lY3Rvci9rYWZrYS9jb25zdW1lci9LYWZrYUNvbnN1bWVySW1wbC5qYXZh) | `9.09% <0.00%> (ø)` | |
   | [.../connector/kafka/consumer/KafkaConsumerRunner.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/3320?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXZlbnRtZXNoLWNvbm5lY3Rvci1wbHVnaW4vZXZlbnRtZXNoLWNvbm5lY3Rvci1rYWZrYS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZXZlbnRtZXNoL2Nvbm5lY3Rvci9rYWZrYS9jb25zdW1lci9LYWZrYUNvbnN1bWVyUnVubmVyLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...sh/connector/kafka/producer/KafkaProducerImpl.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/3320?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXZlbnRtZXNoLWNvbm5lY3Rvci1wbHVnaW4vZXZlbnRtZXNoLWNvbm5lY3Rvci1rYWZrYS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZXZlbnRtZXNoL2Nvbm5lY3Rvci9rYWZrYS9wcm9kdWNlci9LYWZrYVByb2R1Y2VySW1wbC5qYXZh) | `8.69% <0.00%> (ø)` | |
   | [...h/connector/pulsar/client/PulsarClientWrapper.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/3320?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXZlbnRtZXNoLWNvbm5lY3Rvci1wbHVnaW4vZXZlbnRtZXNoLWNvbm5lY3Rvci1wdWxzYXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9jb25uZWN0b3IvcHVsc2FyL2NsaWVudC9QdWxzYXJDbGllbnRXcmFwcGVyLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...h/connector/pulsar/config/ClientConfiguration.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/3320?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXZlbnRtZXNoLWNvbm5lY3Rvci1wbHVnaW4vZXZlbnRtZXNoLWNvbm5lY3Rvci1wdWxzYXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9jb25uZWN0b3IvcHVsc2FyL2NvbmZpZy9DbGllbnRDb25maWd1cmF0aW9uLmphdmE=) | `66.66% <0.00%> (-13.34%)` | :arrow_down: |
   | ... and [121 more](https://codecov.io/gh/apache/incubator-eventmesh/pull/3320?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ... and [6 files with indirect coverage changes](https://codecov.io/gh/apache/incubator-eventmesh/pull/3320/indirect-changes?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: dev-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org