Skip to content

Commit f9d80f1

Browse files
committed
HBASE-25657 Fix spotbugs warnings after upgrading spotbugs to 4.x (#3041)
Signed-off-by: meiyi <myimeiyi@gmail.com> Signed-off-by: stack <stack@apache.org>
1 parent 5c149d1 commit f9d80f1

File tree

2 files changed

+11
-7
lines changed
  • hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client
  • hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner

2 files changed

+11
-7
lines changed

hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/Client.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package org.apache.hadoop.hbase.rest.client;
2121

22+
import java.io.BufferedInputStream;
2223
import java.io.ByteArrayInputStream;
2324
import java.io.ByteArrayOutputStream;
2425
import java.io.File;
@@ -28,6 +29,7 @@
2829
import java.net.URI;
2930
import java.net.URISyntaxException;
3031
import java.net.URL;
32+
import java.nio.file.Files;
3133
import java.security.KeyManagementException;
3234
import java.security.KeyStore;
3335
import java.security.KeyStoreException;
@@ -156,15 +158,17 @@ public Client(Cluster cluster, String trustStorePath,
156158
String type = trustStoreType.orElse(KeyStore.getDefaultType());
157159

158160
KeyStore trustStore;
159-
try(FileInputStream inputStream = new FileInputStream(new File(trustStorePath))) {
161+
try {
160162
trustStore = KeyStore.getInstance(type);
161-
trustStore.load(inputStream, password);
162163
} catch (KeyStoreException e) {
163-
throw new ClientTrustStoreInitializationException(
164-
"Invalid trust store type: " + type, e);
164+
throw new ClientTrustStoreInitializationException("Invalid trust store type: " + type, e);
165+
}
166+
try (InputStream inputStream =
167+
new BufferedInputStream(Files.newInputStream(new File(trustStorePath).toPath()))) {
168+
trustStore.load(inputStream, password);
165169
} catch (CertificateException | NoSuchAlgorithmException | IOException e) {
166-
throw new ClientTrustStoreInitializationException(
167-
"Trust store load error: " + trustStorePath, e);
170+
throw new ClientTrustStoreInitializationException("Trust store load error: " + trustStorePath,
171+
e);
168172
}
169173

170174
initialize(cluster, true, Optional.of(trustStore));

hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/CleanerChore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ static int calculatePoolSize(String poolSize) {
120120
} else if (poolSize.matches("0.[0-9]+|1.0")) {
121121
// if poolSize is a double, return poolSize * availableProcessors;
122122
// Ensure that we always return at least one.
123-
int computedThreads = (int) (AVAIL_PROCESSORS * Double.valueOf(poolSize));
123+
int computedThreads = (int) (AVAIL_PROCESSORS * Double.parseDouble(poolSize));
124124
if (computedThreads < 1) {
125125
LOG.debug("Computed {} threads for CleanerChore, using 1 instead", computedThreads);
126126
return 1;

0 commit comments

Comments
 (0)