kezhuw commented on code in PR #2306:
URL: https://github.com/apache/zookeeper/pull/2306#discussion_r2617051194


##########
zookeeper-server/src/main/java/org/apache/zookeeper/common/ZKConfig.java:
##########
@@ -215,16 +215,39 @@ public void setProperty(String key, String value) {
      *
      * @param configPath path to Configuration file.
      */
-    @SuppressWarnings("deprecation")
     public void addConfiguration(Path configPath) throws ConfigException {
-        addConfiguration(configPath.toFile());
+        Path absoluteConfigPath = configPath.toAbsolutePath();
+        LOG.info("Reading configuration from: {}", absoluteConfigPath);
+        try {
+            File configFile = (new 
VerifyingFileFactory.Builder(LOG).warnForRelativePath()
+                                                               
.failForNonExistingPath()
+                                                               
.build()).validate(configPath.toFile());
+            Properties cfg = new Properties();
+            try (FileInputStream in = new FileInputStream(configFile)) {
+                cfg.load(in);
+            }
+            parseProperties(cfg);
+        } catch (IOException | IllegalArgumentException e) {
+            LOG.error("Error while configuration from: {}", 
absoluteConfigPath, e);
+            String msg = "Error while processing " + absoluteConfigPath;
+            try {
+                Class<?> clazz = 
Class.forName("org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException");

Review Comment:
   The decoupling is known to break something. This pr tried to break 
compilation while keeping runtime compatibility.
   
   > we could just get rid of it.
   
   I think it is viable given that the runtime error(a.k.a. 
`NoClassDefFoundError`) is so noticable. I would like to update this pr to this 
direction. I think we can upgrade ZOOKEEPER-4970 to deprecate 
`QuorumPeerConfig.ConfigException` also.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to