You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2021/03/12 07:02:45 UTC
[hbase] branch branch-2 updated: HBASE-25657 Fix spotbugs warnings
after upgrading spotbugs to 4.x (#3041)
This is an automated email from the ASF dual-hosted git repository.
zhangduo pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2 by this push:
new aafbbc2 HBASE-25657 Fix spotbugs warnings after upgrading spotbugs to 4.x (#3041)
aafbbc2 is described below
commit aafbbc2456e5974736f34b88f5463809fb58bff9
Author: Duo Zhang <zh...@apache.org>
AuthorDate: Fri Mar 12 14:34:10 2021 +0800
HBASE-25657 Fix spotbugs warnings after upgrading spotbugs to 4.x (#3041)
Signed-off-by: meiyi <my...@gmail.com>
Signed-off-by: stack <st...@apache.org>
---
.../java/org/apache/hadoop/hbase/rest/client/Client.java | 16 ++++++++++------
.../apache/hadoop/hbase/master/cleaner/CleanerChore.java | 2 +-
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/Client.java b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/Client.java
index 47700aa..76f8ab1 100644
--- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/Client.java
+++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/Client.java
@@ -19,6 +19,7 @@
package org.apache.hadoop.hbase.rest.client;
+import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -28,6 +29,7 @@ import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+import java.nio.file.Files;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
@@ -156,15 +158,17 @@ public class Client {
String type = trustStoreType.orElse(KeyStore.getDefaultType());
KeyStore trustStore;
- try(FileInputStream inputStream = new FileInputStream(new File(trustStorePath))) {
+ try {
trustStore = KeyStore.getInstance(type);
- trustStore.load(inputStream, password);
} catch (KeyStoreException e) {
- throw new ClientTrustStoreInitializationException(
- "Invalid trust store type: " + type, e);
+ throw new ClientTrustStoreInitializationException("Invalid trust store type: " + type, e);
+ }
+ try (InputStream inputStream =
+ new BufferedInputStream(Files.newInputStream(new File(trustStorePath).toPath()))) {
+ trustStore.load(inputStream, password);
} catch (CertificateException | NoSuchAlgorithmException | IOException e) {
- throw new ClientTrustStoreInitializationException(
- "Trust store load error: " + trustStorePath, e);
+ throw new ClientTrustStoreInitializationException("Trust store load error: " + trustStorePath,
+ e);
}
initialize(cluster, true, Optional.of(trustStore));
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/CleanerChore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/CleanerChore.java
index a8f6798..4ae428d 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/CleanerChore.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/CleanerChore.java
@@ -120,7 +120,7 @@ public abstract class CleanerChore<T extends FileCleanerDelegate> extends Schedu
} else if (poolSize.matches("0.[0-9]+|1.0")) {
// if poolSize is a double, return poolSize * availableProcessors;
// Ensure that we always return at least one.
- int computedThreads = (int) (AVAIL_PROCESSORS * Double.valueOf(poolSize));
+ int computedThreads = (int) (AVAIL_PROCESSORS * Double.parseDouble(poolSize));
if (computedThreads < 1) {
LOG.debug("Computed {} threads for CleanerChore, using 1 instead", computedThreads);
return 1;