1
0

[HUDI-751] Fix some coding issues reported by FindBugs (#1470)

This commit is contained in:
Shaofeng Shi
2020-03-31 21:19:32 +08:00
committed by GitHub
parent 9ecf0ccfb2
commit 78b3194e82
31 changed files with 57 additions and 41 deletions

View File

@@ -120,7 +120,7 @@ public class RollbacksCommand implements CommandMarker {
/**
* An Active timeline containing only rollbacks.
*/
class RollbackTimeline extends HoodieActiveTimeline {
static class RollbackTimeline extends HoodieActiveTimeline {
public RollbackTimeline(HoodieTableMetaClient metaClient) {
super(metaClient, CollectionUtils.createImmutableSet(HoodieTimeline.ROLLBACK_EXTENSION));

View File

@@ -34,7 +34,7 @@ import java.util.Map;
@Component
public class SparkEnvCommand implements CommandMarker {
public static Map<String, String> env = new HashMap<String, String>();
public static Map<String, String> env = new HashMap<>();
@CliCommand(value = "set", help = "Set spark launcher env to cli")
public void setEnv(@CliOption(key = {"conf"}, help = "Env config to be set") final String confMap) {
@@ -49,8 +49,8 @@ public class SparkEnvCommand implements CommandMarker {
public String showAllEnv() {
String[][] rows = new String[env.size()][2];
int i = 0;
for (String key: env.keySet()) {
rows[i] = new String[]{key, env.get(key)};
for (Map.Entry<String, String> entry: env.entrySet()) {
rows[i] = new String[]{entry.getKey(), entry.getValue()};
i++;
}
return HoodiePrintHelper.print(new String[] {"key", "value"}, rows);

View File

@@ -131,9 +131,9 @@ public class StatsCommand implements CommandMarker {
}
List<Comparable[]> rows = new ArrayList<>();
for (String instantTime : commitHistoMap.keySet()) {
Snapshot s = commitHistoMap.get(instantTime).getSnapshot();
rows.add(printFileSizeHistogram(instantTime, s));
for (Map.Entry<String, Histogram> entry : commitHistoMap.entrySet()) {
Snapshot s = entry.getValue().getSnapshot();
rows.add(printFileSizeHistogram(entry.getKey(), s));
}
Snapshot s = globalHistogram.getSnapshot();
rows.add(printFileSizeHistogram("ALL", s));

View File

@@ -49,10 +49,9 @@ public class HiveUtil {
public static long countRecords(String jdbcUrl, HoodieTableMetaClient source, String dbName, String user, String pass)
throws SQLException {
Connection conn = HiveUtil.getConnection(jdbcUrl, user, pass);
ResultSet rs = null;
Statement stmt = conn.createStatement();
try {
try (Connection conn = HiveUtil.getConnection(jdbcUrl, user, pass);
Statement stmt = conn.createStatement()) {
// stmt.execute("set mapred.job.queue.name=<queue_name>");
stmt.execute("set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat");
stmt.execute("set hive.stats.autogather=false");
@@ -68,9 +67,6 @@ public class HiveUtil {
if (rs != null) {
rs.close();
}
if (stmt != null) {
stmt.close();
}
}
}
@@ -88,10 +84,9 @@ public class HiveUtil {
private static long countRecords(String jdbcUrl, HoodieTableMetaClient source, String srcDb, String startDateStr,
String endDateStr, String user, String pass) throws SQLException {
Connection conn = HiveUtil.getConnection(jdbcUrl, user, pass);
ResultSet rs = null;
Statement stmt = conn.createStatement();
try {
try (Connection conn = HiveUtil.getConnection(jdbcUrl, user, pass);
Statement stmt = conn.createStatement()) {
// stmt.execute("set mapred.job.queue.name=<queue_name>");
stmt.execute("set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat");
stmt.execute("set hive.stats.autogather=false");
@@ -106,9 +101,6 @@ public class HiveUtil {
if (rs != null) {
rs.close();
}
if (stmt != null) {
stmt.close();
}
}
}
}