You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by hx...@apache.org on 2019/02/01 15:19:07 UTC
[incubator-iotdb] branch master updated: fix problem discovered by
sonar
This is an automated email from the ASF dual-hosted git repository.
hxd pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 7e78ce4 fix problem discovered by sonar
new 70db28d Merge pull request #36 from MyXOF/fix_sonar_cli_xuyi
7e78ce4 is described below
commit 7e78ce4b49f90d0f447006c422d939d9c193f365
Author: xuyi556677@163.com <xu...@163.com>
AuthorDate: Tue Jan 29 13:55:53 2019 +0800
fix problem discovered by sonar
---
.../main/java/org/apache/iotdb/cli/tool/CsvTestDataGen.java | 8 +++++---
.../src/main/java/org/apache/iotdb/cli/tool/ExportCsv.java | 12 +++++-------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/CsvTestDataGen.java b/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/CsvTestDataGen.java
index 24b288d..ea7cfce 100644
--- a/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/CsvTestDataGen.java
+++ b/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/CsvTestDataGen.java
@@ -25,6 +25,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
+@Deprecated
public class CsvTestDataGen {
private static String[] iso = {
@@ -40,6 +41,7 @@ public class CsvTestDataGen {
"1971,,1,pass,1,1",
"1972,,2,pass,,", "1973-01-01T08:00:00.003+08:00,,3,pass,,", "1974,4,,,4,4"};
private static BufferedWriter bw = null;
+ private static final String USER_DIR = "user.dir";
/**
* generate iso.csv data.
@@ -47,7 +49,7 @@ public class CsvTestDataGen {
* @return path
*/
public static String isoDataGen() {
- String path = System.getProperties().getProperty("user.dir") + "/src/test/resources/iso.csv";
+ String path = System.getProperties().getProperty(USER_DIR) + "/src/test/resources/iso.csv";
File file = new File(path);
try {
@@ -81,7 +83,7 @@ public class CsvTestDataGen {
*/
public static String defaultLongDataGen() {
String path =
- System.getProperties().getProperty("user.dir") + "/src/test/resources/defaultLong.csv";
+ System.getProperties().getProperty(USER_DIR) + "/src/test/resources/defaultLong.csv";
File file = new File(path);
try {
if (!file.exists()) {
@@ -115,7 +117,7 @@ public class CsvTestDataGen {
*/
public static String userSelfDataGen() {
String path =
- System.getProperties().getProperty("user.dir") + "/src/test/resources/userSelfDefine.csv";
+ System.getProperties().getProperty(USER_DIR) + "/src/test/resources/userSelfDefine.csv";
File file = new File(path);
try {
if (!file.exists()) {
diff --git a/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/ExportCsv.java b/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/ExportCsv.java
index 51ea6b0..47b7435 100644
--- a/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/ExportCsv.java
+++ b/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/ExportCsv.java
@@ -98,7 +98,7 @@ public class ExportCsv extends AbstractCsvTool {
try {
parseBasicParams(commandLine, reader);
- parseSpecialParams(commandLine, reader);
+ parseSpecialParams(commandLine);
if (!checkTimeFormat()) {
return;
}
@@ -148,7 +148,7 @@ public class ExportCsv extends AbstractCsvTool {
}
}
- private static void parseSpecialParams(CommandLine commandLine, ConsoleReader reader)
+ private static void parseSpecialParams(CommandLine commandLine)
throws ArgsErrorException {
targetDirectory = checkRequiredArg(TARGET_FILE_ARGS, TARGET_FILE_NAME, commandLine);
timeFormat = commandLine.getOptionValue(TIME_FORMAT_ARGS);
@@ -244,11 +244,9 @@ public class ExportCsv extends AbstractCsvTool {
final String path = targetDirectory + DUMP_FILE_NAME + index + ".csv";
try {
File tf = new File(path);
- if (!tf.exists()) {
- if (!tf.createNewFile()) {
- System.out.println("[ERROR] Could not create target file for sql statement: " + sql);
- return;
- }
+ if (!tf.exists() && !tf.createNewFile()) {
+ System.out.println("[ERROR] Could not create target file for sql statement: " + sql);
+ return;
}
writer = new BufferedWriter(new FileWriter(tf));
} catch (IOException e) {