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>
This commit is contained in:
Duo Zhang 2021-03-12 14:34:10 +08:00 committed by GitHub
parent 7386fb6e1f
commit 876fec1648
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 7 deletions

View File

@ -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));

View File

@ -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;