jeho0815 commented on a change in pull request #745: [SCB-636] change config
mapping machanism
URL:
https://github.com/apache/incubator-servicecomb-java-chassis/pull/745#discussion_r193643678
##########
File path:
foundations/foundation-config/src/main/java/org/apache/servicecomb/config/ConfigMapping.java
##########
@@ -17,20 +17,43 @@
package org.apache.servicecomb.config;
-import java.io.InputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
+import org.apache.commons.configuration.Configuration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* Created by on 2017/1/5.
*/
public final class ConfigMapping {
private static Map<String, Object> configMap = null;
+ private static final Logger LOGGER =
LoggerFactory.getLogger(ConfigMapping.class);
+
static {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
- InputStream is = loader.getResourceAsStream("mapping.yaml");
- configMap = YAMLUtil.yaml2Properties(is);
+ List<URL> urlList = new ArrayList<>();
+ configMap = new HashMap<String, Object>();
+ Enumeration<URL> urls;
+ try {
+ urls = loader.getResources("mapping.yaml");
+ while (urls.hasMoreElements()) {
+ urlList.add(urls.nextElement());
+ }
+ for (URL url : urlList) {
+ configMap.putAll(YAMLUtil.yaml2Properties(url.openStream()));
Review comment:
yes, i have read the source, i don't find no code to close the stream, but
their demo code do not close the stream. Today i write a demo, if i do not
close the stream , the stream will be leak.

so add an api document to explain this.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services