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

    https://github.com/apache/nifi/pull/704#discussion_r71884169
  
    --- Diff: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/cluster/ZooKeeperClientConfig.java
 ---
    @@ -93,4 +101,42 @@ private static int getTimePeriod(final Properties 
properties, final String prope
                 return (int) FormatUtils.getTimeDuration(defaultValue, 
TimeUnit.MILLISECONDS);
             }
         }
    +
    +    /**
    +     * Takes a given connect string and splits it by ',' character. For 
each
    +     * split result trims whitespace then splits by ':' character. For each
    +     * secondary split if a single value is returned it is trimmed and 
then the
    +     * default zookeeper 2181 is append by adding ":2181". If two values 
are
    +     * returned then the second value is evaluated to ensure it contains 
only
    +     * digits and if not then the entry is skipped. If more than two 
values are
    +     * returned the entry is skipped. Each entry is trimmed and if empty 
the
    +     * entry is skipped. After all splits are cleaned then they are all 
appended
    +     * back together demarcated by "," and the full string is returned.
    +     *
    +     * @param connectString the string to clean
    +     * @return cleaned connect string guaranteed to be non null but could 
be
    +     * empty
    +     */
    +    public static String cleanConnectString(final String connectString) {
    +        final String nospaces = 
StringUtils.deleteWhitespace(connectString);
    +        final String hostPortPairs[] = StringUtils.split(nospaces, ",", 
100);
    +        final List<String> cleanedEntries = new 
ArrayList<>(hostPortPairs.length);
    +        for (final String pair : hostPortPairs) {
    +            final String pairSplits[] = StringUtils.split(pair, ":", 3);
    +            if (pairSplits.length > 2) {
    +                continue; //skip it
    --- End diff --
    
    In these cases, where we have received an invalid configuration, I would be 
much more inclined to throw an Exception than to simply ignore the value. At a 
minimum, I think we need to log a warning message indicating that we are 
skipping the value that the user provided us.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to