shaofengshi commented on a change in pull request #262: KYLIN-3597 Improve code 
smell
URL: https://github.com/apache/kylin/pull/262#discussion_r221114826
 
 

 ##########
 File path: 
source-kafka/src/main/java/org/apache/kylin/source/kafka/config/KafkaConsumerProperties.java
 ##########
 @@ -101,24 +100,22 @@ public static Properties 
extractKafkaConfigToProperties(Configuration configurat
     private Properties loadKafkaConsumerProperties() {
         File propFile = getKafkaConsumerFile();
         if (propFile == null || !propFile.exists()) {
-            logger.warn("fail to locate " + KAFKA_CONSUMER_FILE + ", use empty 
kafka consumer properties");
+            logger.warn("fail to locate {}, use empty kafka consumer 
properties", KAFKA_CONSUMER_FILE);
             return new Properties();
         }
         Properties properties = new Properties();
-        try {
-            FileInputStream is = new FileInputStream(propFile);
+        try (FileInputStream is = new FileInputStream(propFile)) {
             Configuration conf = new Configuration();
             conf.addResource(is);
             properties.putAll(extractKafkaConfigToProperties(conf));
-            IOUtils.closeQuietly(is);
 
             File propOverrideFile = new File(propFile.getParentFile(), 
propFile.getName() + ".override");
             if (propOverrideFile.exists()) {
-                FileInputStream ois = new FileInputStream(propOverrideFile);
-                Configuration oconf = new Configuration();
-                oconf.addResource(ois);
-                properties.putAll(extractKafkaConfigToProperties(oconf));
-                IOUtils.closeQuietly(ois);
+                try (FileInputStream ois = new 
FileInputStream(propOverrideFile)) {
+                    Configuration oconf = new Configuration();
+                    oconf.addResource(ois);
+                    properties.putAll(extractKafkaConfigToProperties(oconf));
+                }
             }
         } catch (IOException e) {
             throw new RuntimeException(e);
 
 Review comment:
   The same as previous comment.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to