You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@eventmesh.apache.org by "Alonexc (via GitHub)" <gi...@apache.org> on 2023/03/03 02:31:40 UTC
[GitHub] [incubator-eventmesh] Alonexc commented on a diff in pull request #3320: [ISSUE #3084] Reliance on default encoding[FileLoad]
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:

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