sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject sqoop git commit: SQOOP-2484: Sqoop2: Findbugs: Fix resource leak problem in SqoopConfiguration and ConnectorManagerUtils
Date Tue, 18 Aug 2015 15:53:29 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 354a6969e -> 7ce9f67f7


SQOOP-2484: Sqoop2: Findbugs: Fix resource leak problem in SqoopConfiguration and ConnectorManagerUtils

(Colin Ma via Jarek Jarcec Cecho)


Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/7ce9f67f
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/7ce9f67f
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/7ce9f67f

Branch: refs/heads/sqoop2
Commit: 7ce9f67f711b722d8ce52bc12a1ab85d64390759
Parents: 354a696
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Tue Aug 18 08:52:30 2015 -0700
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Tue Aug 18 08:52:30 2015 -0700

----------------------------------------------------------------------
 .../org/apache/sqoop/connector/ConnectorManagerUtils.java   | 6 +++---
 .../main/java/org/apache/sqoop/core/SqoopConfiguration.java | 9 ++++-----
 2 files changed, 7 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/7ce9f67f/core/src/main/java/org/apache/sqoop/connector/ConnectorManagerUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/connector/ConnectorManagerUtils.java b/core/src/main/java/org/apache/sqoop/connector/ConnectorManagerUtils.java
index 7402c5a..522ed08 100644
--- a/core/src/main/java/org/apache/sqoop/connector/ConnectorManagerUtils.java
+++ b/core/src/main/java/org/apache/sqoop/connector/ConnectorManagerUtils.java
@@ -71,12 +71,12 @@ public class ConnectorManagerUtils {
   }
 
   static boolean isConnectorJar(File file) {
-    try {
+    try (JarFile jarFile = new JarFile(file)) {
       @SuppressWarnings("resource")
-      JarEntry entry = new JarFile(file).getJarEntry(ConfigurationConstants.FILENAME_CONNECTOR_PROPERTIES);
+      JarEntry entry = jarFile.getJarEntry(ConfigurationConstants.FILENAME_CONNECTOR_PROPERTIES);
       return entry != null;
     } catch (IOException e) {
       throw new RuntimeException(e);
     }
   }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/sqoop/blob/7ce9f67f/core/src/main/java/org/apache/sqoop/core/SqoopConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/core/SqoopConfiguration.java b/core/src/main/java/org/apache/sqoop/core/SqoopConfiguration.java
index 49f139c..8f9c445 100644
--- a/core/src/main/java/org/apache/sqoop/core/SqoopConfiguration.java
+++ b/core/src/main/java/org/apache/sqoop/core/SqoopConfiguration.java
@@ -129,9 +129,7 @@ public class SqoopConfiguration implements Reconfigurable {
     }
 
     Properties bootstrapProperties = new Properties();
-    InputStream bootstrapPropStream = null;
-    try {
-      bootstrapPropStream = new FileInputStream(bootstrapConfig);
+    try (InputStream bootstrapPropStream = new FileInputStream(bootstrapConfig)) {
       bootstrapProperties.load(bootstrapPropStream);
     } catch (IOException ex) {
       throw new SqoopException(
@@ -267,11 +265,12 @@ public class SqoopConfiguration implements Reconfigurable {
 
   private synchronized void configureLogging() {
     Properties props = new Properties();
-    for (String key : config.keySet()) {
+    for (Map.Entry<String, String> entry : config.entrySet()) {
+      String key = entry.getKey();
       if (key.startsWith(ConfigurationConstants.PREFIX_LOG_CONFIG)) {
         String logConfigKey = key.substring(
             ConfigurationConstants.PREFIX_GLOBAL_CONFIG.length());
-        props.put(logConfigKey, config.get(key));
+        props.put(logConfigKey, entry.getValue());
       }
     }
 


Mime
View raw message