wujimin commented on a change in pull request #2103:
URL:
https://github.com/apache/servicecomb-java-chassis/pull/2103#discussion_r536488735
##########
File path:
service-registry/registry-service-center/src/test/java/org/apache/servicecomb/serviceregistry/client/LocalServiceRegistryClientImpl.java
##########
@@ -94,10 +95,16 @@ public LocalServiceRegistryClientImpl(Map<String, Object>
data) {
}
private void initFromData(InputStream is) {
- Yaml yaml = new Yaml();
- @SuppressWarnings("unchecked")
- Map<String, Object> data = yaml.loadAs(is, Map.class);
- initFromData(data);
+ try {
+ Map<String, Object> data = YAMLUtil.yaml2Properties(is);
+ initFromData(data);
+ } finally {
+ try {
+ is.close();
+ } catch (IOException e) {
+ LOGGER.error("", e);
+ }
+ }
Review comment:
创建stream的地方用try-with-resource,应该更合适
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]