[ 
https://issues.apache.org/jira/browse/STORM-1532?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15141284#comment-15141284
 ] 

ASF GitHub Bot commented on STORM-1532:
---------------------------------------

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

    https://github.com/apache/storm/pull/1094#discussion_r52494730
  
    --- Diff: storm-core/src/jvm/org/apache/storm/utils/Utils.java ---
    @@ -330,7 +330,11 @@ public static Map readCommandLineOpts() {
             Map ret = new HashMap();
             String commandOptions = System.getProperty("storm.options");
             if (commandOptions != null) {
    -            String[] configs = commandOptions.split(",");
    +            /*
    +             below regex uses negative lookahead to not split in the 
middle of
    +             json objects '{}' or json arrays '[]'
    +              */
    +            String[] configs = 
commandOptions.split(",(?![^\\[\\]{}]*(]|}))");
    --- End diff --
    
    The regex works only for valid JSON strings.
    
    With the current storm.cmd script, valid json strings were not parsed 
properly so one could not pass a list (for e.g. drpc.servers) from windows. I 
couldn't figure out a way to url-encode from storm.cmd so I came up with the 
regex that works for valid JSONs. 
    
    The change should not affect the parsing of the storm.options sent via the 
python script since the url-encoded values would not contain `[, {, ] or }` and 
will not be touched by the regex.
    
    Agree this is not the ideal fix that handles all the cases but lets one 
pass valid json in storm.cmd in windows which is currently broken. If there are 
any alternatives to get the options working in windows l can try to explore.


> Fix readCommandLineOpts to parse JSON correctly
> -----------------------------------------------
>
>                 Key: STORM-1532
>                 URL: https://issues.apache.org/jira/browse/STORM-1532
>             Project: Apache Storm
>          Issue Type: Bug
>            Reporter: Arun Mahadevan
>            Assignee: Arun Mahadevan
>
> Utils.readCommandLineOpts does a split on "," so it does not correctly parse 
> values passed as json object or json arrays.
> Tested by passing 
> -c drpc.servers=[\"host1\", \"host2\"]  in storm jar command and it fails 
> with an exception,
> Exception in thread "main" java.lang.IllegalArgumentException: Field 
> DRPC_SERVERS must be an Iterable but was a class java.lang.String



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to