HBASE-27236 Clean up error-prone warnings in hbase-hbtop (#4649)

Signed-off-by: Duo Zhang <zhangduo@apache.org>
This commit is contained in:
Andrew Purtell 2022-07-26 18:04:14 -07:00 committed by GitHub
parent 0c4263a18b
commit 234cdf7b69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 15 additions and 4 deletions

View File

@ -36,6 +36,7 @@ import org.apache.yetus.audience.InterfaceAudience;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hbase.thirdparty.com.google.common.base.Splitter;
import org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine;
import org.apache.hbase.thirdparty.org.apache.commons.cli.DefaultParser;
import org.apache.hbase.thirdparty.org.apache.commons.cli.HelpFormatter;
@ -119,6 +120,7 @@ public class HBTop extends Configured implements Tool {
try {
delay = Integer.parseInt(commandLine.getOptionValue("delay"));
} catch (NumberFormatException ignored) {
// Deliberately ignored, we handle the issue below.
}
if (delay < 1) {
@ -163,7 +165,7 @@ public class HBTop extends Configured implements Tool {
}
if (commandLine.hasOption("fields")) {
String[] fields = commandLine.getOptionValue("fields").split(",");
Iterable<String> fields = Splitter.on(',').split(commandLine.getOptionValue("fields"));
initialFields = new ArrayList<>();
for (String field : fields) {
Optional<FieldInfo> fieldInfo = initialMode.getFieldInfos().stream()
@ -177,7 +179,7 @@ public class HBTop extends Configured implements Tool {
}
if (commandLine.hasOption("filters")) {
String[] filters = commandLine.getOptionValue("filters").split(",");
Iterable<String> filters = Splitter.on(',').split(commandLine.getOptionValue("filters"));
List<Field> fields = initialMode.getFieldInfos().stream().map(FieldInfo::getField)
.collect(Collectors.toList());
for (String filter : filters) {

View File

@ -31,6 +31,7 @@ import org.apache.yetus.audience.InterfaceAudience;
* Represents a display mode in the top screen.
*/
@InterfaceAudience.Private
@SuppressWarnings("ImmutableEnumChecker")
public enum Mode {
NAMESPACE("Namespace", "Record per Namespace", new NamespaceModeStrategy()),
TABLE("Table", "Record per Table", new TableModeStrategy()),

View File

@ -115,6 +115,7 @@ public final class RegionModeStrategy implements ModeStrategy {
elements.length == 4 ? Integer.valueOf(Bytes.toString(elements[3])).toString() : "";
region = RegionInfo.encodeRegionName(regionMetrics.getRegionName());
} catch (IOException ignored) {
// Exception deliberately ignored
}
builder.put(Field.NAMESPACE, namespaceName);

View File

@ -61,6 +61,7 @@ public interface TerminalPrinter {
return this;
}
@SuppressWarnings("AnnotateFormatMethod")
default TerminalPrinter printFormat(String format, Object... args) {
print(String.format(format, args));
return this;

View File

@ -112,7 +112,10 @@ public class KeyPressGenerator {
} else {
Thread.sleep(20);
}
} catch (InterruptedException ignored) {
} catch (InterruptedException e) {
// Restore interrupt status
Thread.currentThread().interrupt();
done = true;
} catch (IOException e) {
LOGGER.error("Caught an exception", e);
done = true;

View File

@ -213,7 +213,9 @@ public class TerminalImpl implements Terminal {
try {
process.waitFor();
} catch (InterruptedException ignored) {
} catch (InterruptedException e) {
// Restore interrupt status
Thread.currentThread().interrupt();
}
int exitValue = process.exitValue();

View File

@ -114,6 +114,7 @@ public final class TestUtils {
.build();
}
@SuppressWarnings("JavaUtilDate")
private static RegionMetrics createRegionMetrics(String regionName, long readRequestCount,
long filteredReadRequestCount, long writeRequestCount, Size storeFileSize,
Size uncompressedStoreFileSize, int storeFileCount, Size memStoreSize, float locality,