diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/JitterScheduledThreadPoolExecutorImpl.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/JitterScheduledThreadPoolExecutorImpl.java index 7e7239e6805..c330fa75cf2 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/JitterScheduledThreadPoolExecutorImpl.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/JitterScheduledThreadPoolExecutorImpl.java @@ -92,6 +92,19 @@ public class JitterScheduledThreadPoolExecutorImpl extends ScheduledThreadPoolEx return wrapped.compareTo(o); } + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + return obj instanceof Delayed? compareTo((Delayed)obj) == 0: false; + } + + @Override + public int hashCode() { + return this.wrapped.hashCode(); + } + @Override public void run() { wrapped.run(); @@ -123,5 +136,4 @@ public class JitterScheduledThreadPoolExecutorImpl extends ScheduledThreadPoolEx return wrapped.get(timeout, unit); } } - } diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/ProcedureInfo.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/ProcedureInfo.java index 0cd4103fa02..11264cda533 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/ProcedureInfo.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/ProcedureInfo.java @@ -35,7 +35,7 @@ import org.apache.hadoop.hbase.util.NonceKey; */ @InterfaceAudience.Public @InterfaceStability.Evolving -public class ProcedureInfo { +public class ProcedureInfo implements Cloneable { private final long procId; private final String procName; private final String procOwner; @@ -72,6 +72,8 @@ public class ProcedureInfo { this.result = result; } + @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="CN_IDIOM_NO_SUPER_CALL", + justification="Intentional; calling super class clone doesn't make sense here.") public ProcedureInfo clone() { return new ProcedureInfo( procId, procName, procOwner, procState, parentId, exception, lastUpdate, startTime, result); diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/trace/SpanReceiverHost.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/trace/SpanReceiverHost.java index b90d191e6f5..2d9c398dad8 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/trace/SpanReceiverHost.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/trace/SpanReceiverHost.java @@ -42,10 +42,11 @@ public class SpanReceiverHost { private Configuration conf; private boolean closed = false; + @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="SE_BAD_FIELD") private static enum SingletonHolder { INSTANCE; Object lock = new Object(); - SpanReceiverHost host = null; + SpanReceiverHost host = null; // FindBugs: SE_BAD_FIELD } public static SpanReceiverHost getInstance(Configuration conf) { diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/types/CopyOnWriteArrayMap.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/types/CopyOnWriteArrayMap.java index 41056b2fa2b..8de39aec7c7 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/types/CopyOnWriteArrayMap.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/types/CopyOnWriteArrayMap.java @@ -27,6 +27,7 @@ import java.util.Comparator; import java.util.Iterator; import java.util.Map; import java.util.NavigableSet; +import java.util.NoSuchElementException; import java.util.Set; import java.util.SortedSet; import java.util.concurrent.ConcurrentNavigableMap; @@ -693,8 +694,10 @@ public class CopyOnWriteArrayMap extends AbstractMap } @Override + @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="EQ_ALWAYS_FALSE", + justification="Intentional") public boolean equals(Object o) { - return false; + return false; // FindBugs: Causes EQ_ALWAYS_FALSE. Suppressed. } @Override @@ -771,7 +774,12 @@ public class CopyOnWriteArrayMap extends AbstractMap } @Override + @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="IT_NO_SUCH_ELEMENT", + justification="Intentional") public Entry next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } return holder.entries[index++]; } diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferUtils.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferUtils.java index 6f348bc91a7..ef3d368218a 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferUtils.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferUtils.java @@ -32,6 +32,7 @@ import org.apache.hadoop.io.WritableUtils; * Utility functions for working with byte buffers, such as reading/writing * variable-length long numbers. */ +@SuppressWarnings("restriction") @InterfaceAudience.Public @InterfaceStability.Evolving public final class ByteBufferUtils { diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/DNS.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/DNS.java index d105a34ff98..4b9e87f4ae3 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/DNS.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/DNS.java @@ -25,6 +25,8 @@ import org.apache.hadoop.hbase.classification.InterfaceAudience; * Wrapper around Hadoop's DNS class to hide reflection. */ @InterfaceAudience.Private +@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="REC_CATCH_EXCEPTION", + justification="If exception, presume HAS_NEW_DNS_GET_DEFAULT_HOST_API false") public final class DNS { private static boolean HAS_NEW_DNS_GET_DEFAULT_HOST_API; private static Method GET_DEFAULT_HOST_METHOD; @@ -35,7 +37,7 @@ public final class DNS { .getMethod("getDefaultHost", String.class, String.class, boolean.class); HAS_NEW_DNS_GET_DEFAULT_HOST_API = true; } catch (Exception e) { - HAS_NEW_DNS_GET_DEFAULT_HOST_API = false; + HAS_NEW_DNS_GET_DEFAULT_HOST_API = false; // FindBugs: Causes REC_CATCH_EXCEPTION. Suppressed } } diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/DynamicClassLoader.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/DynamicClassLoader.java index c1194ca805f..bc86358ab93 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/DynamicClassLoader.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/DynamicClassLoader.java @@ -99,7 +99,9 @@ public class DynamicClassLoader extends ClassLoaderBase { } } - private void initTempDir(final Configuration conf) { + // FindBugs: Making synchronized to avoid IS2_INCONSISTENT_SYNC complaints about + // remoteDirFs and jarModifiedTime being part synchronized protected. + private synchronized void initTempDir(final Configuration conf) { jarModifiedTime = new HashMap(); String localDirPath = conf.get( LOCAL_DIR_KEY, DEFAULT_LOCAL_DIR) + DYNAMIC_JARS_DIR; diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/PrettyPrinter.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/PrettyPrinter.java index 2b599677c58..5f927ccce2a 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/PrettyPrinter.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/PrettyPrinter.java @@ -30,6 +30,8 @@ public class PrettyPrinter { NONE } + @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="DM_BOXED_PRIMITIVE_FOR_PARSING", + justification="I don't get what FB is complaining about") public static String format(final String value, final Unit unit) { StringBuilder human = new StringBuilder(); switch (unit) { diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Threads.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Threads.java index 5e76fffd502..ef8fe4397be 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Threads.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Threads.java @@ -266,8 +266,8 @@ public class Threads { t.setUncaughtExceptionHandler(LOGGING_EXCEPTION_HANDLER); } - private static Method printThreadInfoMethod = null; - private static boolean printThreadInfoMethodWithPrintStream = true; + private static Method PRINT_THREAD_INFO_METHOD = null; + private static boolean PRINT_THREAD_INFO_METHOD_WITH_PRINTSTREAM = true; /** * Print all of the thread's information and stack traces. Wrapper around Hadoop's method. @@ -275,31 +275,30 @@ public class Threads { * @param stream the stream to * @param title a string title for the stack trace */ - public static void printThreadInfo(PrintStream stream, String title) { - - if (printThreadInfoMethod == null) { + public static synchronized void printThreadInfo(PrintStream stream, String title) { + if (PRINT_THREAD_INFO_METHOD == null) { try { // Hadoop 2.7+ declares printThreadInfo(PrintStream, String) - printThreadInfoMethod = ReflectionUtils.class.getMethod("printThreadInfo", + PRINT_THREAD_INFO_METHOD = ReflectionUtils.class.getMethod("printThreadInfo", PrintStream.class, String.class); } catch (NoSuchMethodException e) { // Hadoop 2.6 and earlier declares printThreadInfo(PrintWriter, String) - printThreadInfoMethodWithPrintStream = false; + PRINT_THREAD_INFO_METHOD_WITH_PRINTSTREAM = false; try { - printThreadInfoMethod = ReflectionUtils.class.getMethod("printThreadInfo", + PRINT_THREAD_INFO_METHOD = ReflectionUtils.class.getMethod("printThreadInfo", PrintWriter.class, String.class); } catch (NoSuchMethodException e1) { throw new RuntimeException("Cannot find method. Check hadoop jars linked", e1); } } - printThreadInfoMethod.setAccessible(true); + PRINT_THREAD_INFO_METHOD.setAccessible(true); } try { - if (printThreadInfoMethodWithPrintStream) { - printThreadInfoMethod.invoke(null, stream, title); + if (PRINT_THREAD_INFO_METHOD_WITH_PRINTSTREAM) { + PRINT_THREAD_INFO_METHOD.invoke(null, stream, title); } else { - printThreadInfoMethod.invoke(null, new PrintWriter(stream), title); + PRINT_THREAD_INFO_METHOD.invoke(null, new PrintWriter(stream), title); } } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { throw new RuntimeException(e.getCause()); diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/UnsafeAccess.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/UnsafeAccess.java index 1a3460795cd..1a0b0e97131 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/UnsafeAccess.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/UnsafeAccess.java @@ -32,6 +32,8 @@ import sun.misc.Unsafe; @InterfaceAudience.Private @InterfaceStability.Evolving +@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="REC_CATCH_EXCEPTION", + justification="If exception, presume unaligned") public final class UnsafeAccess { private static final Log LOG = LogFactory.getLog(UnsafeAccess.class); @@ -66,7 +68,7 @@ public final class UnsafeAccess { m.setAccessible(true); unaligned = (boolean) m.invoke(null); } catch (Exception e) { - unaligned = false; + unaligned = false; // FindBugs: Causes REC_CATCH_EXCEPTION. Suppressed. } } else{ BYTE_ARRAY_BASE_OFFSET = -1;