mirror of
https://github.com/apache/sqoop.git
synced 2025-05-12 23:11:43 +08:00
SQOOP-2529: Sqoop2: findbugs: Fix warning in tools module
(Colin Ma via Jarek Jarcec Cecho)
This commit is contained in:
parent
826e5cc774
commit
afa865e3b8
@ -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 boolean runToolWithConfiguration(String[] arguments) {
|
||||
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();
|
||||
|
@ -92,13 +92,12 @@ public boolean runToolWithConfiguration(String[] arguments) {
|
||||
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 @@ private JSONArray updateJobIdUsingName(JSONArray submissionsJsonArray) {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user