srdo commented on a change in pull request #3155: STORM-3066: Implement support 
for using list elements in properties in FluxParser
URL: https://github.com/apache/storm/pull/3155#discussion_r339687789
 
 

 ##########
 File path: 
flux/flux-core/src/main/java/org/apache/storm/flux/parser/FluxParser.java
 ##########
 @@ -139,37 +149,49 @@ public static Properties parseProperties(String 
propertiesFile, boolean resource
         return properties;
     }
 
-    private static TopologyDef loadYaml(Yaml yaml, InputStream in, Properties 
properties, boolean envSubstitution) throws IOException {
-        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+    private static TopologyDef loadYaml(Yaml yaml, InputStream in, Properties 
properties, boolean envSubstitution) {
         LOG.info("loading YAML from input stream...");
-        int b = -1;
-        while ((b = in.read()) != -1) {
-            bos.write(b);
-        }
+        StringBuilder bos = new StringBuilder();
+        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
 
-        // TODO substitution implementation is not exactly efficient or kind 
to memory...
-        String str = bos.toString();
-        // properties file substitution
-        if (properties != null) {
-            LOG.info("Performing property substitution.");
-            for (Object key : properties.keySet()) {
-                str = str.replace("${" + key + "}", 
properties.getProperty((String)key));
+        reader.lines().forEach(line -> {
 
 Review comment:
   This is minor, but I'm wondering if this could be made slightly easier to 
read using `.map` and `.collect` along with the `joining` Collector 
https://docs.oracle.com/javase/8/docs/api/java/util/stream/Collectors.html#joining--
   
   That way you wouldn't have to add the new line to the StringBuilder 
manually, and there'd be less to do in the `else`-cases where things aren't 
matched.

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to