pavlukhin commented on a change in pull request #7566: IGNITE-12832 Add user 
attributes support to control.sh
URL: https://github.com/apache/ignite/pull/7566#discussion_r399744612
 
 

 ##########
 File path: 
modules/core/src/main/java/org/apache/ignite/internal/commandline/CommonArgParser.java
 ##########
 @@ -336,4 +369,70 @@ private String securityWarningMessage(String password) {
 
         return String.format(pwdArgWarnFmt, password, password);
     }
+
+    /**
+     * Extracts user properties from property string or file.
+     *
+     * @param userPropStr {@code String} Property string.
+     * @param userPropPath {@code String} Property file path.
+     */
+    private Map<String, String> userProperties(String userPropStr, String 
userPropPath){
+        Map<String, String> res = parsePropertiesFromString(userPropStr);
+
+        parsePropertiesFromFile(userPropPath).forEach(res::putIfAbsent);
+
+        return res;
+    }
+
+    /**
+     * Extracts user properties from attribute string.
+     *
+     * @param propStr {@code String} Attribute string.
+     */
+    private Map<String, String> parsePropertiesFromString(String propStr) {
+        Map<String, String> res = new HashMap<>();
+
+        if(propStr == null)
+            return res;
+
+        final int partsOfPropStr = 2;
+
+        for (String prop : propStr.split(",")) {
+            if (!prop.contains("="))
+                throw new RuntimeException(String.format("Failed to parse 
property %s", prop));
 
 Review comment:
   Is it common to use `RuntimeException` in control utility code to handle 
input exceptions? Applicable to `parsePropertiesFromFile` method as well. What 
will user see in case of such input exceptions? It might be useful to write 
tests checking it.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to