You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@storm.apache.org by vesense <gi...@git.apache.org> on 2017/12/05 09:47:30 UTC

[GitHub] storm pull request #2445: STORM-2843: [Flux] properties file not found when ...

GitHub user vesense opened a pull request:

    https://github.com/apache/storm/pull/2445

    STORM-2843: [Flux] properties file not found when loading resources...

    …from classpath

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/vesense/storm STORM-2843

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/storm/pull/2445.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #2445
    
----
commit c144f73e853db28dba7f6bdee7a9490100f019bd
Author: Xin Wang <xi...@apache.org>
Date:   2017-12-05T09:45:36Z

    STORM-2843: properties file not found when loading resources from classpath

----


---

[GitHub] storm pull request #2445: STORM-2843: [Flux] properties file not found when ...

Posted by vesense <gi...@git.apache.org>.
Github user vesense commented on a diff in the pull request:

    https://github.com/apache/storm/pull/2445#discussion_r157729717
  
    --- Diff: flux/flux-core/src/main/java/org/apache/storm/flux/parser/FluxParser.java ---
    @@ -39,51 +39,57 @@
     
         private FluxParser(){}
     
    -    // TODO refactor input stream processing (see parseResource() method).
         public static TopologyDef parseFile(String inputFile, boolean dumpYaml, boolean processIncludes,
         	String propertiesFile, boolean envSub) throws IOException {
    -   
    +
             FileInputStream in = new FileInputStream(inputFile);
    -        TopologyDef topology = parseInputStream(in, dumpYaml, processIncludes, propertiesFile, envSub);
    +        InputStream propertiesIn = null;
    +        if (propertiesFile != null) {
    +            propertiesIn = new FileInputStream(propertiesFile);
    +        }
    +        TopologyDef topology = parseInputStream(in, dumpYaml, processIncludes, propertiesIn, propertiesFile, envSub);
             in.close();
    -        
    +
             return topology;
         }
     
         public static TopologyDef parseResource(String resource, boolean dumpYaml, boolean processIncludes,
         	String propertiesFile, boolean envSub) throws IOException {
             
             InputStream in = FluxParser.class.getResourceAsStream(resource);
    -        TopologyDef topology = parseInputStream(in, dumpYaml, processIncludes, propertiesFile, envSub);
    +        InputStream propertiesIn = null;
    +        if (propertiesFile != null) {
    +            propertiesIn = FluxParser.class.getResourceAsStream(propertiesFile);
    +        }
    +        TopologyDef topology = parseInputStream(in, dumpYaml, processIncludes, propertiesIn, propertiesFile, envSub);
    --- End diff --
    
    Make sense. Yaml file and included yaml file should share the same properties instance. PR for master and 1.x are updated. Please take a look again.


---

[GitHub] storm issue #2445: STORM-2843: [Flux] properties file not found when loading...

Posted by vesense <gi...@git.apache.org>.
Github user vesense commented on the issue:

    https://github.com/apache/storm/pull/2445
  
    @HeartSaVioR PR updated. Could you take a look again?


---

[GitHub] storm pull request #2445: STORM-2843: [Flux] properties file not found when ...

Posted by HeartSaVioR <gi...@git.apache.org>.
Github user HeartSaVioR commented on a diff in the pull request:

    https://github.com/apache/storm/pull/2445#discussion_r155708774
  
    --- Diff: flux/flux-core/src/main/java/org/apache/storm/flux/parser/FluxParser.java ---
    @@ -39,51 +39,57 @@
     
         private FluxParser(){}
     
    -    // TODO refactor input stream processing (see parseResource() method).
         public static TopologyDef parseFile(String inputFile, boolean dumpYaml, boolean processIncludes,
         	String propertiesFile, boolean envSub) throws IOException {
    -   
    +
             FileInputStream in = new FileInputStream(inputFile);
    -        TopologyDef topology = parseInputStream(in, dumpYaml, processIncludes, propertiesFile, envSub);
    +        InputStream propertiesIn = null;
    +        if (propertiesFile != null) {
    +            propertiesIn = new FileInputStream(propertiesFile);
    +        }
    +        TopologyDef topology = parseInputStream(in, dumpYaml, processIncludes, propertiesIn, propertiesFile, envSub);
             in.close();
    -        
    +
             return topology;
         }
     
         public static TopologyDef parseResource(String resource, boolean dumpYaml, boolean processIncludes,
         	String propertiesFile, boolean envSub) throws IOException {
             
             InputStream in = FluxParser.class.getResourceAsStream(resource);
    -        TopologyDef topology = parseInputStream(in, dumpYaml, processIncludes, propertiesFile, envSub);
    +        InputStream propertiesIn = null;
    +        if (propertiesFile != null) {
    +            propertiesIn = FluxParser.class.getResourceAsStream(propertiesFile);
    +        }
    +        TopologyDef topology = parseInputStream(in, dumpYaml, processIncludes, propertiesIn, propertiesFile, envSub);
    --- End diff --
    
    There's a corner case here:
    
    1. `--resource` option is provided hence this method called.
    2. yaml file has an include statement which sets resource as `false`.
    3. `parseFile` is called which doesn't handle propertiesFile as resource.
    
    So it needs more fine-grained approach regarding dealing with propertiesFile.
    
    If my understanding is right, given that we only read and don't modify properties file after loading it, we could just create Properties instance and pass it instead of passing properties file name. Makes sense?


---

[GitHub] storm pull request #2445: STORM-2843: [Flux] properties file not found when ...

Posted by vesense <gi...@git.apache.org>.
Github user vesense closed the pull request at:

    https://github.com/apache/storm/pull/2445


---

[GitHub] storm issue #2445: STORM-2843: [Flux] properties file not found when loading...

Posted by vesense <gi...@git.apache.org>.
Github user vesense commented on the issue:

    https://github.com/apache/storm/pull/2445
  
    @HeartSaVioR Created new PR for this.


---