{"action":"created","comment":{"url":"https://api.github.com/repos/apache/zookeeper/pulls/comments/60177430","id":60177430,"diff_hunk":"@@ -0,0 +1,230 @@\n+/**\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements.  See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership.  The ASF licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License.  You may obtain a copy of the License at\n+ *\n+ *     http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+package org.apache.zookeeper.common;\n+\n+import java.io.File;\n+import java.io.FileInputStream;\n+import java.io.IOException;\n+import java.util.HashMap;\n+import java.util.Map;\n+import java.util.Map.Entry;\n+import java.util.Properties;\n+\n+import org.apache.zookeeper.Environment;\n+import org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException;\n+import org.apache.zookeeper.server.util.VerifyingFileFactory;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+/**\n+ * This class is a base class for the configurations of both client and server.\n+ * It supports reading client configuration from both system properties and\n+ * configuration file. A user can override any system property by calling\n+ * {@link #setProperty(String, String)}.\n+ */\n+public class ZKConfig {\n+\n+    private static final Logger LOG = LoggerFactory.getLogger(ZKConfig.class);\n+    @SuppressWarnings(\"deprecation\")\n+    public static final String SSL_KEYSTORE_LOCATION = X509Util.SSL_KEYSTORE_LOCATION;\n+    @SuppressWarnings(\"deprecation\")\n+    public static final String SSL_KEYSTORE_PASSWD = X509Util.SSL_KEYSTORE_PASSWD;\n+    @SuppressWarnings(\"deprecation\")\n+    public static final String SSL_TRUSTSTORE_LOCATION = X509Util.SSL_TRUSTSTORE_LOCATION;\n+    @SuppressWarnings(\"deprecation\")\n+    public static final String SSL_TRUSTSTORE_PASSWD = X509Util.SSL_TRUSTSTORE_PASSWD;\n+    @SuppressWarnings(\"deprecation\")\n+    public static final String SSL_AUTHPROVIDER = X509Util.SSL_AUTHPROVIDER;\n+    public static final String JUTE_MAXBUFFER = \"jute.maxbuffer\";\n+    /**\n+     * Path to a kinit binary: {@value}. Defaults to\n+     * <code>\"/usr/bin/kinit\"</code>\n+     */\n+    public static final String KINIT_COMMAND = \"zookeeper.kinit\";\n+    public static final String JGSS_NATIVE = \"sun.security.jgss.native\";\n+\n+    private Map<String, String> properties = new HashMap<String, String>();\n+\n+    /**\n+     * properties, which are common to both client and server, are initialized\n+     * from system properties\n+     */\n+    public ZKConfig() {\n+        init();\n+    }\n+\n+    /**\n+     * @param configPath\n+     *            Configuration file path\n+     * @throws ConfigException\n+     *             if failed to load configuration properties\n+     */\n+\n+    public ZKConfig(String configPath) throws ConfigException {\n+        this(new File(configPath));\n+    }\n+\n+    /**\n+     *\n+     * @param configFile\n+     *            Configuration file\n+     * @throws ConfigException\n+     *             if failed to load configuration properties\n+     */\n+    public ZKConfig(File configFile) throws ConfigException {\n+        init();\n+        addConfiguration(configFile);\n+    }\n+\n+    private void init() {\n+        /**\n+         * backward compatibility for all currently available client properties\n+         */\n+        handleBackwardCompatibility();\n+    }\n+\n+    /**\n+     * Now onwards client code will use properties from this class but older\n+     * clients still be setting properties through system properties. So to make\n+     * this change backward compatible we should set old system properties in\n+     * this configuration.\n+     */\n+    protected void handleBackwardCompatibility() {\n+        properties.put(SSL_KEYSTORE_LOCATION, System.getProperty(SSL_KEYSTORE_LOCATION));\n+        properties.put(SSL_KEYSTORE_PASSWD, System.getProperty(SSL_KEYSTORE_PASSWD));\n+        properties.put(SSL_TRUSTSTORE_LOCATION, System.getProperty(SSL_TRUSTSTORE_LOCATION));\n+        properties.put(SSL_TRUSTSTORE_PASSWD, System.getProperty(SSL_TRUSTSTORE_PASSWD));\n+        properties.put(SSL_AUTHPROVIDER, System.getProperty(SSL_AUTHPROVIDER));\n+        properties.put(JUTE_MAXBUFFER, System.getProperty(JUTE_MAXBUFFER));\n+        properties.put(KINIT_COMMAND, System.getProperty(KINIT_COMMAND));\n+        properties.put(JGSS_NATIVE, System.getProperty(JGSS_NATIVE));\n+    }\n+\n+    /**\n+     * Get the property value\n+     *\n+     * @param name\n+     * @return property value\n+     */\n+    public String getProperty(String name) {\n+        return properties.get(name);\n+    }\n+\n+    /**\n+     * Get the property value, if it is null return default value\n+     *\n+     * @param name\n+     *            Property name\n+     * @param defaultValue\n+     * @return\n+     */\n+    public String getProperty(String name, String defaultValue) {\n+        String value = properties.get(name);\n+        if (value == null) {\n+            return defaultValue;\n+        } else {\n+            return value;\n+        }\n+    }\n+\n+    /**\n+     * Return the value of \"java.security.auth.login.config\" system property\n+     *\n+     * @return value\n+     */\n+    public String getJaasConfKey() {\n+        return System.getProperty(Environment.JAAS_CONF_KEY);\n+    }\n+\n+    /**\n+     * Set the property value\n+     *\n+     * @param name\n+     * @param value\n+     */\n+    public void setProperty(String key, String value) {\n+        if (null == key) {\n+            throw new IllegalArgumentException(\"property key is null.\");\n+        }\n+        String oldValue = properties.put(key, value);","path":"src/java/main/org/apache/zookeeper/common/ZKConfig.java","position":165,"original_position":165,"commit_id":"d309769d71dd165c4dddf5baa184f0c5be6d9e3c","original_commit_id":"d309769d71dd165c4dddf5baa184f0c5be6d9e3c","user":{"login":"arshadmohammad","id":5720433,"avatar_url":"https://avatars.githubusercontent.com/u/5720433?v=3","gravatar_id":"","url":"https://api.github.com/users/arshadmohammad","html_url":"https://github.com/arshadmohammad","followers_url":"https://api.github.com/users/arshadmohammad/followers","following_url":"https://api.github.com/users/arshadmohammad/following{/other_user}","gists_url":"https://api.github.com/users/arshadmohammad/gists{/gist_id}","starred_url":"https://api.github.com/users/arshadmohammad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arshadmohammad/subscriptions","organizations_url":"https://api.github.com/users/arshadmohammad/orgs","repos_url":"https://api.github.com/users/arshadmohammad/repos","events_url":"https://api.github.com/users/arshadmohammad/events{/privacy}","received_events_url":"https://api.github.com/users/arshadmohammad/received_events","type":"User","site_admin":false},"body":"Invalid comment, \r\nIf fixed, it will break the functionality completely.","created_at":"2016-04-19T06:13:47Z","updated_at":"2016-04-19T06:13:47Z","html_url":"https://github.com/apache/zookeeper/pull/59#discussion_r60177430","pull_request_url":"https://api.github.com/repos/apache/zookeeper/pulls/59","_links":{"self":{"href":"https://api.github.com/repos/apache/zookeeper/pulls/comments/60177430"},"html":{"href":"https://github.com/apache/zookeeper/pull/59#discussion_r60177430"},"pull_request":{"href":"https://api.github.com/repos/apache/zookeeper/pulls/59"}}},"pull_request":{"url":"https://api.github.com/repos/apache/zookeeper/pulls/59","id":63939098,"html_url":"https://github.com/apache/zookeeper/pull/59","diff_url":"https://github.com/apache/zookeeper/pull/59.diff","patch_url":"https://github.com/apache/zookeeper/pull/59.patch","issue_url":"https://api.github.com/repos/apache/zookeeper/issues/59","number":59,"state":"open","locked":false,"title":"ZOOKEEPER-2139:Support multiple ZooKeeper client, with different configurations, in a single JVM","user":{"login":"arshadmohammad","id":5720433,"avatar_url":"https://avatars.githubusercontent.com/u/5720433?v=3","gravatar_id":"","url":"https://api.github.com/users/arshadmohammad","html_url":"https://github.com/arshadmohammad","followers_url":"https://api.github.com/users/arshadmohammad/followers","following_url":"https://api.github.com/users/arshadmohammad/following{/other_user}","gists_url":"https://api.github.com/users/arshadmohammad/gists{/gist_id}","starred_url":"https://api.github.com/users/arshadmohammad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arshadmohammad/subscriptions","organizations_url":"https://api.github.com/users/arshadmohammad/orgs","repos_url":"https://api.github.com/users/arshadmohammad/repos","events_url":"https://api.github.com/users/arshadmohammad/events{/privacy}","received_events_url":"https://api.github.com/users/arshadmohammad/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-03-23T19:27:00Z","updated_at":"2016-04-19T06:13:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f35418131f1e1b0395670bd55615a5cb41ec662b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/zookeeper/pulls/59/commits","review_comments_url":"https://api.github.com/repos/apache/zookeeper/pulls/59/comments","review_comment_url":"https://api.github.com/repos/apache/zookeeper/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/zookeeper/issues/59/comments","statuses_url":"https://api.github.com/repos/apache/zookeeper/statuses/d309769d71dd165c4dddf5baa184f0c5be6d9e3c","head":{"label":"arshadmohammad:ZOOKEEPER-2139","ref":"ZOOKEEPER-2139","sha":"d309769d71dd165c4dddf5baa184f0c5be6d9e3c","user":{"login":"arshadmohammad","id":5720433,"avatar_url":"https://avatars.githubusercontent.com/u/5720433?v=3","gravatar_id":"","url":"https://api.github.com/users/arshadmohammad","html_url":"https://github.com/arshadmohammad","followers_url":"https://api.github.com/users/arshadmohammad/followers","following_url":"https://api.github.com/users/arshadmohammad/following{/other_user}","gists_url":"https://api.github.com/users/arshadmohammad/gists{/gist_id}","starred_url":"https://api.github.com/users/arshadmohammad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arshadmohammad/subscriptions","organizations_url":"https://api.github.com/users/arshadmohammad/orgs","repos_url":"https://api.github.com/users/arshadmohammad/repos","events_url":"https://api.github.com/users/arshadmohammad/events{/privacy}","received_events_url":"https://api.github.com/users/arshadmohammad/received_events","type":"User","site_admin":false},"repo":{"id":54577911,"name":"zookeeper","full_name":"arshadmohammad/zookeeper","owner":{"login":"arshadmohammad","id":5720433,"avatar_url":"https://avatars.githubusercontent.com/u/5720433?v=3","gravatar_id":"","url":"https://api.github.com/users/arshadmohammad","html_url":"https://github.com/arshadmohammad","followers_url":"https://api.github.com/users/arshadmohammad/followers","following_url":"https://api.github.com/users/arshadmohammad/following{/other_user}","gists_url":"https://api.github.com/users/arshadmohammad/gists{/gist_id}","starred_url":"https://api.github.com/users/arshadmohammad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arshadmohammad/subscriptions","organizations_url":"https://api.github.com/users/arshadmohammad/orgs","repos_url":"https://api.github.com/users/arshadmohammad/repos","events_url":"https://api.github.com/users/arshadmohammad/events{/privacy}","received_events_url":"https://api.github.com/users/arshadmohammad/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/arshadmohammad/zookeeper","description":"Mirror of Apache Hadoop ZooKeeper","fork":true,"url":"https://api.github.com/repos/arshadmohammad/zookeeper","forks_url":"https://api.github.com/repos/arshadmohammad/zookeeper/forks","keys_url":"https://api.github.com/repos/arshadmohammad/zookeeper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/arshadmohammad/zookeeper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/arshadmohammad/zookeeper/teams","hooks_url":"https://api.github.com/repos/arshadmohammad/zookeeper/hooks","issue_events_url":"https://api.github.com/repos/arshadmohammad/zookeeper/issues/events{/number}","events_url":"https://api.github.com/repos/arshadmohammad/zookeeper/events","assignees_url":"https://api.github.com/repos/arshadmohammad/zookeeper/assignees{/user}","branches_url":"https://api.github.com/repos/arshadmohammad/zookeeper/branches{/branch}","tags_url":"https://api.github.com/repos/arshadmohammad/zookeeper/tags","blobs_url":"https://api.github.com/repos/arshadmohammad/zookeeper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/arshadmohammad/zookeeper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/arshadmohammad/zookeeper/git/refs{/sha}","trees_url":"https://api.github.com/repos/arshadmohammad/zookeeper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/arshadmohammad/zookeeper/statuses/{sha}","languages_url":"https://api.github.com/repos/arshadmohammad/zookeeper/languages","stargazers_url":"https://api.github.com/repos/arshadmohammad/zookeeper/stargazers","contributors_url":"https://api.github.com/repos/arshadmohammad/zookeeper/contributors","subscribers_url":"https://api.github.com/repos/arshadmohammad/zookeeper/subscribers","subscription_url":"https://api.github.com/repos/arshadmohammad/zookeeper/subscription","commits_url":"https://api.github.com/repos/arshadmohammad/zookeeper/commits{/sha}","git_commits_url":"https://api.github.com/repos/arshadmohammad/zookeeper/git/commits{/sha}","comments_url":"https://api.github.com/repos/arshadmohammad/zookeeper/comments{/number}","issue_comment_url":"https://api.github.com/repos/arshadmohammad/zookeeper/issues/comments{/number}","contents_url":"https://api.github.com/repos/arshadmohammad/zookeeper/contents/{+path}","compare_url":"https://api.github.com/repos/arshadmohammad/zookeeper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/arshadmohammad/zookeeper/merges","archive_url":"https://api.github.com/repos/arshadmohammad/zookeeper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/arshadmohammad/zookeeper/downloads","issues_url":"https://api.github.com/repos/arshadmohammad/zookeeper/issues{/number}","pulls_url":"https://api.github.com/repos/arshadmohammad/zookeeper/pulls{/number}","milestones_url":"https://api.github.com/repos/arshadmohammad/zookeeper/milestones{/number}","notifications_url":"https://api.github.com/repos/arshadmohammad/zookeeper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/arshadmohammad/zookeeper/labels{/name}","releases_url":"https://api.github.com/repos/arshadmohammad/zookeeper/releases{/id}","deployments_url":"https://api.github.com/repos/arshadmohammad/zookeeper/deployments","created_at":"2016-03-23T17:00:22Z","updated_at":"2016-03-23T17:00:29Z","pushed_at":"2016-04-06T17:28:56Z","git_url":"git://github.com/arshadmohammad/zookeeper.git","ssh_url":"git@github.com:arshadmohammad/zookeeper.git","clone_url":"https://github.com/arshadmohammad/zookeeper.git","svn_url":"https://github.com/arshadmohammad/zookeeper","homepage":null,"size":23866,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"trunk"}},"base":{"label":"apache:trunk","ref":"trunk","sha":"7b3b2d7560b142ea780ac28721b5c866d8937a91","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":160999,"name":"zookeeper","full_name":"apache/zookeeper","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/zookeeper","description":"Mirror of Apache Hadoop ZooKeeper","fork":false,"url":"https://api.github.com/repos/apache/zookeeper","forks_url":"https://api.github.com/repos/apache/zookeeper/forks","keys_url":"https://api.github.com/repos/apache/zookeeper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/zookeeper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/zookeeper/teams","hooks_url":"https://api.github.com/repos/apache/zookeeper/hooks","issue_events_url":"https://api.github.com/repos/apache/zookeeper/issues/events{/number}","events_url":"https://api.github.com/repos/apache/zookeeper/events","assignees_url":"https://api.github.com/repos/apache/zookeeper/assignees{/user}","branches_url":"https://api.github.com/repos/apache/zookeeper/branches{/branch}","tags_url":"https://api.github.com/repos/apache/zookeeper/tags","blobs_url":"https://api.github.com/repos/apache/zookeeper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/zookeeper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/zookeeper/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/zookeeper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/zookeeper/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/zookeeper/languages","stargazers_url":"https://api.github.com/repos/apache/zookeeper/stargazers","contributors_url":"https://api.github.com/repos/apache/zookeeper/contributors","subscribers_url":"https://api.github.com/repos/apache/zookeeper/subscribers","subscription_url":"https://api.github.com/repos/apache/zookeeper/subscription","commits_url":"https://api.github.com/repos/apache/zookeeper/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/zookeeper/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/zookeeper/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/zookeeper/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/zookeeper/contents/{+path}","compare_url":"https://api.github.com/repos/apache/zookeeper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/zookeeper/merges","archive_url":"https://api.github.com/repos/apache/zookeeper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/zookeeper/downloads","issues_url":"https://api.github.com/repos/apache/zookeeper/issues{/number}","pulls_url":"https://api.github.com/repos/apache/zookeeper/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/zookeeper/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/zookeeper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/zookeeper/labels{/name}","releases_url":"https://api.github.com/repos/apache/zookeeper/releases{/id}","deployments_url":"https://api.github.com/repos/apache/zookeeper/deployments","created_at":"2009-03-27T15:41:56Z","updated_at":"2016-04-18T21:16:34Z","pushed_at":"2016-04-13T10:46:05Z","git_url":"git://github.com/apache/zookeeper.git","ssh_url":"git@github.com:apache/zookeeper.git","clone_url":"https://github.com/apache/zookeeper.git","svn_url":"https://github.com/apache/zookeeper","homepage":null,"size":43161,"stargazers_count":1594,"watchers_count":1594,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1198,"mirror_url":"git://git.apache.org/zookeeper.git","open_issues_count":47,"forks":1198,"open_issues":47,"watchers":1594,"default_branch":"trunk"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/zookeeper/pulls/59"},"html":{"href":"https://github.com/apache/zookeeper/pull/59"},"issue":{"href":"https://api.github.com/repos/apache/zookeeper/issues/59"},"comments":{"href":"https://api.github.com/repos/apache/zookeeper/issues/59/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/zookeeper/pulls/59/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/zookeeper/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/zookeeper/pulls/59/commits"},"statuses":{"href":"https://api.github.com/repos/apache/zookeeper/statuses/d309769d71dd165c4dddf5baa184f0c5be6d9e3c"}}}}