From 3a97976eae02023f5f8feebf8132fad7b24fffd2 Mon Sep 17 00:00:00 2001 From: Xu Cang Date: Sun, 22 Jul 2018 23:40:17 -0700 Subject: [PATCH] HBASE-20744 Address FindBugs warnings in branch-1 minor fix Signed-off-by: tedyu --- .../hbase/io/encoding/EncodedDataBlock.java | 6 +++++- .../metrics2/lib/MetricsExecutorImpl.java | 2 +- .../hbase/quotas/RegionServerQuotaManager.java | 17 +++-------------- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/EncodedDataBlock.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/EncodedDataBlock.java index 192c84d1bb8..6959edd367c 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/EncodedDataBlock.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/EncodedDataBlock.java @@ -255,7 +255,7 @@ public class EncodedDataBlock { } BufferGrabbingByteArrayOutputStream stream = new BufferGrabbingByteArrayOutputStream(); baos.writeTo(stream); - this.dataBlockEncoder.endBlockEncoding(encodingCtx, out, stream.ourBytes); + this.dataBlockEncoder.endBlockEncoding(encodingCtx, out, stream.getOurBytes()); } catch (IOException e) { throw new RuntimeException(String.format( "Bug in encoding part of algorithm %s. " + @@ -268,6 +268,10 @@ public class EncodedDataBlock { private static class BufferGrabbingByteArrayOutputStream extends ByteArrayOutputStream { private byte[] ourBytes; + private synchronized byte[] getOurBytes() { + return ourBytes; + } + @Override public synchronized void write(byte[] b, int off, int len) { this.ourBytes = b; diff --git a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/metrics2/lib/MetricsExecutorImpl.java b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/metrics2/lib/MetricsExecutorImpl.java index c3816097416..57b199f4861 100644 --- a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/metrics2/lib/MetricsExecutorImpl.java +++ b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/metrics2/lib/MetricsExecutorImpl.java @@ -48,7 +48,7 @@ public class MetricsExecutorImpl implements MetricsExecutor { private enum ExecutorSingleton { INSTANCE; - private final ScheduledExecutorService scheduler = new ScheduledThreadPoolExecutor(1, + private final transient ScheduledExecutorService scheduler = new ScheduledThreadPoolExecutor(1, new ThreadPoolExecutorThreadFactory("HBase-Metrics2-")); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/RegionServerQuotaManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/RegionServerQuotaManager.java index 21f206ab6f8..89ae3f5c053 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/RegionServerQuotaManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/RegionServerQuotaManager.java @@ -190,21 +190,10 @@ public class RegionServerQuotaManager { + e.getMessage()); // Depending on whether we are supposed to throw a retryable IO exeption or not, choose // the correct exception type to (re)throw - if (e instanceof ThrottlingException) { - if (useRetryableThrottlingException) { - throw new RpcThrottlingException(e.getMessage()); - } else { - throw e; - } - } else if (e instanceof RpcThrottlingException) { - if (useRetryableThrottlingException) { - throw e; - } else { - throw new ThrottlingException(e.getMessage()); - } - } else { - LOG.warn("Unexpected exception from quota check", e); + if (useRetryableThrottlingException) { throw e; + } else { + throw new ThrottlingException(e.getMessage()); } } return quota;