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-2529: Sqoop2: findbugs: Fix warning in tools module
Date Tue, 25 Aug 2015 15:58:58 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 826e5cc77 -> afa865e3b


SQOOP-2529: Sqoop2: findbugs: Fix warning in tools module

(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/afa865e3
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/afa865e3
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/afa865e3

Branch: refs/heads/sqoop2
Commit: afa865e3b8e84564f96a32700cc681c4339b15cf
Parents: 826e5cc
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Tue Aug 25 08:58:37 2015 -0700
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Tue Aug 25 08:58:37 2015 -0700

----------------------------------------------------------------------
 .../sqoop/tools/tool/RepositoryDumpTool.java    |  6 +++--
 .../sqoop/tools/tool/RepositoryLoadTool.java    | 23 +++++---------------
 2 files changed, 10 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/afa865e3/tools/src/main/java/org/apache/sqoop/tools/tool/RepositoryDumpTool.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/sqoop/tools/tool/RepositoryDumpTool.java b/tools/src/main/java/org/apache/sqoop/tools/tool/RepositoryDumpTool.java
index 6cb6210..42bcbd5 100644
--- a/tools/src/main/java/org/apache/sqoop/tools/tool/RepositoryDumpTool.java
+++ b/tools/src/main/java/org/apache/sqoop/tools/tool/RepositoryDumpTool.java
@@ -17,9 +17,11 @@
  */
 package org.apache.sqoop.tools.tool;
 
+
 import java.io.BufferedWriter;
-import java.io.FileWriter;
+import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.OutputStreamWriter;
 import java.util.Iterator;
 import java.util.List;
 
@@ -73,7 +75,7 @@ public class RepositoryDumpTool extends ConfiguredTool {
         skipSensitive = false;
       }
 
-      BufferedWriter output = new BufferedWriter(new FileWriter(outputFileName));
+      BufferedWriter output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFileName),
"UTF-8"));
       LOG.info("Writing JSON repository dump to file " + outputFileName);
       dump(skipSensitive).writeJSONString(output);
       output.flush();

http://git-wip-us.apache.org/repos/asf/sqoop/blob/afa865e3/tools/src/main/java/org/apache/sqoop/tools/tool/RepositoryLoadTool.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/sqoop/tools/tool/RepositoryLoadTool.java b/tools/src/main/java/org/apache/sqoop/tools/tool/RepositoryLoadTool.java
index 3cbfcf0..244683d 100644
--- a/tools/src/main/java/org/apache/sqoop/tools/tool/RepositoryLoadTool.java
+++ b/tools/src/main/java/org/apache/sqoop/tools/tool/RepositoryLoadTool.java
@@ -92,13 +92,12 @@ public class RepositoryLoadTool extends ConfiguredTool {
       String inputFileName = line.getOptionValue('i');
 
       LOG.info("Reading JSON from file" + inputFileName);
-      InputStream input = new FileInputStream(inputFileName);
-      String jsonTxt = IOUtils.toString(input, Charsets.UTF_8);
-      JSONObject json = JSONUtils.parse(jsonTxt);
-      boolean res = load(json);
-      input.close();
-      return res;
-
+      try (InputStream input = new FileInputStream(inputFileName)) {
+        String jsonTxt = IOUtils.toString(input, Charsets.UTF_8);
+        JSONObject json = JSONUtils.parse(jsonTxt);
+        boolean res = load(json);
+        return res;
+      }
     } catch (FileNotFoundException e) {
       LOG.error("Repository dump file not found:", e);
       System.out.println("Input file not found. Please check Server logs for details.");
@@ -465,14 +464,4 @@ public class RepositoryLoadTool extends ConfiguredTool {
 
     return submissionsJsonArray;
   }
-
-  private JSONArray updateIdUsingMap(JSONArray jsonArray, HashMap<Long, Long> idMap,
String fieldName) {
-    for (Object obj : jsonArray) {
-      JSONObject object = (JSONObject) obj;
-
-      object.put(fieldName, idMap.get(object.get(fieldName)));
-    }
-
-    return jsonArray;
-  }
 }


Mime
View raw message