Github user srdo commented on a diff in the pull request: https://github.com/apache/storm/pull/2566#discussion_r170418510 --- Diff: storm-client/src/jvm/org/apache/storm/utils/Utils.java --- @@ -1570,4 +1588,60 @@ 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 readZip() throws IOException { + try (ZipFile zipFile = new ZipFile(f)) { + readArchive(zipFile); + } + return this; + } + + public JarConfigReader readJar() throws IOException { + try (JarFile jarFile = new JarFile(f)) { + readArchive(jarFile); + } + return this; + } + + private void readArchive(ZipFile zipFile) throws IOException { + Enumeration<? extends ZipEntry> zipEnums = zipFile.entries(); + while (zipEnums.hasMoreElements()) { + ZipEntry entry = zipEnums.nextElement(); + if (!entry.isDirectory()) { + if (defaultsConf == null && entry.getName().equals("defaults.yaml")) { + try (InputStream in = zipFile.getInputStream(entry); InputStreamReader isr = new InputStreamReader(in)) { --- End diff -- Nit: Since you're not using the in variable, you could builder the isr in one step
---