ThePrez / ServiceCommander-IBMi

Service Commander for IBM i
Apache License 2.0
40 stars 12 forks source link

Bug/ngnix config 182 #185

Closed ajshedivy closed 1 year ago

ajshedivy commented 1 year ago

Explain the reasoning for this pull request. For instance, is it for a new feature, bug fix, code style/cleanup, or something else? If fixing an open issue, please link to it here.

fixes bug #182

Any additional comments/context?

From slack:

Essentially, the bug stems from the way we grab the property value pairs from the config file. The behavior I'm seeing is that in NginxConfNode.open we parse the pairs using regex:

 final String property = curStr.replaceAll("\\s.*", "");
 final String value = curStr.replaceFirst("^[^\\s]*\\s+", "");

which returns the same string for both property and value if no value is given. so in our case, if our cluster.conf looks like:

    location /basic_status {
      stub_status;
    }

the property and value will both be "stub_status". (Is that actually what the regex should return, or is that a bug in of itself?). The "simplest" fix that does not change the underlying parsing is to just check if the property and value are equal (assuming that this will always be true if no directive is given) and write out the key accordingly. I have this fix working such that the duplicated value is no longer written.

Current discussion

We discussed how we should use Pattern and Matcher objects to parse the property-value line in the config file. We can then check if the value is ever null or empty which would indicate a non value directive was given

ThePrez commented 1 year ago

Fixes #182