-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
modify properties file to yaml file. #255
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
final HashMap<String, String> propsMap = extractPropsMap(inputStream); | ||
try (InputStream in = classLoader.getResourceAsStream(CONFIG_FILE)) { | ||
if (in != null) { | ||
final Map<String, String> propsMap = extractPropsMap(in); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- for CONFIG_FILE has been changed to 'agent.yaml', maybe the parse method should not be the
extractPropsMap
which is used to parse property file. - the
agent.yaml
is not exist, could you help to generate it.
restore
# Conflicts: # build/src/main/resources/agent.yaml # config/src/main/java/com/megaease/easeagent/config/ConfigFactory.java
return new GlobalConfigs(map); | ||
try (FileInputStream in = new FileInputStream(file)) { | ||
Map<String, String> map; | ||
if (file.getName().contains(".properties")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better as follows:
if (file.getName().endsWith(".properties")) {
////
} else if (file.getName().endsWith(".yaml") || file.getName().endsWith(".yml")) {
///
} else {
LOGGER.warn("can not load config file: {}", file.getAbsolutePath());
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private static boolean checkYaml(String filename) {
return filename.endsWith(".yaml") || filename.endsWith(".yml");
}
private static GlobalConfigs loadFromClasspath(ClassLoader classLoader, String file) {
try (InputStream in = classLoader.getResourceAsStream(file)) {
if (in != null) {
Map<String, String> map;
if (checkYaml(file)) {
try {
map = new YamlReader().load(in).compress();
} catch (ParserException e) {
LOGGER.warn("Wrong Yaml format, load config file failure: {}", file);
map = Collections.emptyMap();
}
} else {
map = extractPropsMap(in);
}
return new GlobalConfigs(map);
}
} catch (IOException e) {
LOGGER.warn("Load config file:{} by classloader:{} failure: {}", file, classLoader.toString(), e);
}
return new GlobalConfigs(Collections.emptyMap());
}
default properties needs to be included
No description provided.