Github user srdo commented on a diff in the pull request:

    https://github.com/apache/storm/pull/2566#discussion_r170301964
  
    --- Diff: storm-client/src/jvm/org/apache/storm/utils/Utils.java ---
    @@ -1570,4 +1574,49 @@ public static boolean isLocalhostAddress(String 
address) {
             }
             return result;
         }
    +
    +    private static class JarConfigReader {
    +        private Yaml yaml;
    +        private Map<String, Object> defaultsConf;
    +        private Map<String, Object> stormConf;
    +        private File f;
    +
    +        public JarConfigReader(Yaml yaml, Map<String, Object> 
defaultsConf, Map<String, Object> stormConf, File f) {
    +            this.yaml = yaml;
    +            this.defaultsConf = defaultsConf;
    +            this.stormConf = stormConf;
    +            this.f = f;
    +        }
    +
    +        public Map<String, Object> getDefaultsConf() {
    +            return defaultsConf;
    +        }
    +
    +        public Map<String, Object> getStormConf() {
    +            return stormConf;
    +        }
    +
    +        public JarConfigReader invoke() throws IOException {
    +            try (JarFile jarFile = new JarFile(f)) {
    +                Enumeration<JarEntry> jarEnums = jarFile.entries();
    +                while (jarEnums.hasMoreElements()) {
    +                    JarEntry entry = jarEnums.nextElement();
    +                    if (!entry.isDirectory()) {
    +                        if (defaultsConf == null && 
entry.getName().equals("defaults.yaml")) {
    +                            try (InputStream in = 
jarFile.getInputStream(entry)) {
    +                                defaultsConf = (Map<String, Object>) 
yaml.load(new InputStreamReader(in));
    +                            }
    +                        }
    +
    +                        if (stormConf == null && 
entry.getName().equals("storm.yaml")) {
    +                            try (InputStream in = 
jarFile.getInputStream(entry)) {
    +                                stormConf = (Map<String, Object>) 
yaml.load(new InputStreamReader(in));
    --- End diff --
    
    Nit: Consider moving the InputStreamReader into the try-with-resources, so 
it also gets closed.


---

Reply via email to