FindBugs Report

Project Information

Project: Apache HBase - Server

FindBugs version: 3.1.0-RC3

Code analyzed:



Metrics

109629 lines of code analyzed, in 2044 classes, in 68 packages.

Metric Total Density*
High Priority Warnings 4 0.04
Medium Priority Warnings 20 0.18
Total Warnings 24 0.22

(* Defects per Thousand lines of non-commenting source statements)



Contents

Summary

Warning Type Number
Bad practice Warnings 3
Correctness Warnings 7
Multithreaded correctness Warnings 4
Performance Warnings 2
Dodgy code Warnings 8
Total 24

Warnings

Click on a warning row to see full context information.

Bad practice Warnings

Code Warning
Eq org.apache.hadoop.hbase.regionserver.MemStoreFlusher$WakeupFlushThread defines compareTo(Object) and uses Object.equals()
NP org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.preCheckAndDeleteAfterRowLock(byte[], byte[], byte[], CompareOperator, ByteArrayComparable, Delete) has Boolean return type and returns explicit null
NP org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.preCheckAndPutAfterRowLock(byte[], byte[], byte[], CompareOperator, ByteArrayComparable, Put) has Boolean return type and returns explicit null

Correctness Warnings

Code Warning
NP bestAnyRegion could be null and is guaranteed to be dereferenced in org.apache.hadoop.hbase.regionserver.MemStoreFlusher.flushOneForGlobalPressure()
NP Possible null pointer dereference of nextWriter in org.apache.hadoop.hbase.regionserver.wal.AsyncFSWAL.doReplaceWriter(Path, Path, WALProvider$AsyncWriter)
NP Possible null pointer dereference of commandLine in org.apache.hadoop.hbase.util.compaction.MajorCompactor.main(String[]) on exception path
RCN Nullcheck of parentHRI at line 442 of value previously dereferenced in org.apache.hadoop.hbase.master.assignment.SplitTableRegionProcedure.prepareSplitRegion(MasterProcedureEnv)
RCN Nullcheck of bestFlushableRegion at line 172 of value previously dereferenced in org.apache.hadoop.hbase.regionserver.MemStoreFlusher.flushOneForGlobalPressure()
RCN Nullcheck of bestRegionReplica at line 214 of value previously dereferenced in org.apache.hadoop.hbase.regionserver.MemStoreFlusher.flushOneForGlobalPressure()
RCN Nullcheck of regionToFlush at line 172 of value previously dereferenced in org.apache.hadoop.hbase.regionserver.MemStoreFlusher.flushOneForGlobalPressure()

Multithreaded correctness Warnings

Code Warning
IS Inconsistent synchronization of org.apache.hadoop.hbase.ipc.RpcServer.authManager; locked 50% of time
IS Inconsistent synchronization of org.apache.hadoop.hbase.master.ClusterStatusPublisher.connected; locked 50% of time
IS Inconsistent synchronization of org.apache.hadoop.hbase.master.replication.RefreshPeerProcedure.targetServer; locked 57% of time
LI Incorrect lazy initialization of static field org.apache.hadoop.hbase.replication.regionserver.ReplicationSyncUp.conf in org.apache.hadoop.hbase.replication.regionserver.ReplicationSyncUp.main(String[])

Performance Warnings

Code Warning
Bx Boxing/unboxing to parse a primitive org.apache.hadoop.hbase.master.cleaner.CleanerChore.calculatePoolSize(String)
Bx Boxing/unboxing to parse a primitive org.apache.hadoop.hbase.util.compaction.MajorCompactor.main(String[])

Dodgy code Warnings

Code Warning
DB org.apache.hadoop.hbase.regionserver.CompactingMemStore.initInmemoryFlushSize(Configuration) uses the same code for two branches
DLS Dead store to startTime in org.apache.hadoop.hbase.master.assignment.AssignmentManager.processofflineServersWithOnlineRegions()
DLS Dead store to hostname in new org.apache.hadoop.hbase.regionserver.RSRpcServices(HRegionServer, RSRpcServices$LogDelegate)
SF Switch statement found in org.apache.hadoop.hbase.regionserver.HRegion.startRegionOperation(Region$Operation) where default case is missing
ST Write to static field org.apache.hadoop.hbase.master.cleaner.CleanerChore.chorePool from instance method new org.apache.hadoop.hbase.master.cleaner.CleanerChore(String, int, Stoppable, Configuration, FileSystem, Path, String, Map)
ST Write to static field org.apache.hadoop.hbase.master.cleaner.CleanerChore.chorePoolSize from instance method new org.apache.hadoop.hbase.master.cleaner.CleanerChore(String, int, Stoppable, Configuration, FileSystem, Path, String, Map)
ST Write to static field org.apache.hadoop.hbase.master.cleaner.CleanerChore.chorePoolSize from instance method org.apache.hadoop.hbase.master.cleaner.CleanerChore.onConfigurationChange(Configuration)
UC Useless object stored in variable toStartup of method org.apache.hadoop.hbase.replication.regionserver.ReplicationSourceManager.refreshSources(String)

Details

DM_BOXED_PRIMITIVE_FOR_PARSING: Boxing/unboxing to parse a primitive

A boxed primitive is created from a String, just to extract the unboxed primitive value. It is more efficient to just call the static parseXXX method.

DB_DUPLICATE_BRANCHES: Method uses the same code for two branches

This method uses the same code to implement two branches of a conditional branch. Check to ensure that this isn't a coding mistake.

DLS_DEAD_LOCAL_STORE: Dead store to local variable

This instruction assigns a value to a local variable, but the value is not read or used in any subsequent instruction. Often, this indicates an error, because the value computed is never used.

Note that Sun's javac compiler often generates dead stores for final local variables. Because FindBugs is a bytecode-based tool, there is no easy way to eliminate these false positives.

EQ_COMPARETO_USE_OBJECT_EQUALS: Class defines compareTo(...) and uses Object.equals()

This class defines a compareTo(...) method but inherits its equals() method from java.lang.Object. Generally, the value of compareTo should return zero if and only if equals returns true. If this is violated, weird and unpredictable failures will occur in classes such as PriorityQueue. In Java 5 the PriorityQueue.remove method uses the compareTo method, while in Java 6 it uses the equals method.

From the JavaDoc for the compareTo method in the Comparable interface:

It is strongly recommended, but not strictly required that (x.compareTo(y)==0) == (x.equals(y)). Generally speaking, any class that implements the Comparable interface and violates this condition should clearly indicate this fact. The recommended language is "Note: this class has a natural ordering that is inconsistent with equals."

IS2_INCONSISTENT_SYNC: Inconsistent synchronization

The fields of this class appear to be accessed inconsistently with respect to synchronization.  This bug report indicates that the bug pattern detector judged that

A typical bug matching this bug pattern is forgetting to synchronize one of the methods in a class that is intended to be thread-safe.

You can select the nodes labeled "Unsynchronized access" to show the code locations where the detector believed that a field was accessed without synchronization.

Note that there are various sources of inaccuracy in this detector; for example, the detector cannot statically detect all situations in which a lock is held.  Also, even when the detector is accurate in distinguishing locked vs. unlocked accesses, the code in question may still be correct.

LI_LAZY_INIT_STATIC: Incorrect lazy initialization of static field

This method contains an unsynchronized lazy initialization of a non-volatile static field. Because the compiler or processor may reorder instructions, threads are not guaranteed to see a completely initialized object, if the method can be called by multiple threads. You can make the field volatile to correct the problem. For more information, see the Java Memory Model web site.

NP_BOOLEAN_RETURN_NULL: Method with Boolean return type returns explicit null

A method that returns either Boolean.TRUE, Boolean.FALSE or null is an accident waiting to happen. This method can be invoked as though it returned a value of type boolean, and the compiler will insert automatic unboxing of the Boolean value. If a null value is returned, this will result in a NullPointerException.

NP_GUARANTEED_DEREF: Null value is guaranteed to be dereferenced

There is a statement or branch that if executed guarantees that a value is null at this point, and that value that is guaranteed to be dereferenced (except on forward paths involving runtime exceptions).

Note that a check such as if (x == null) throw new NullPointerException(); is treated as a dereference of x.

NP_NULL_ON_SOME_PATH: Possible null pointer dereference

There is a branch of statement that, if executed, guarantees that a null value will be dereferenced, which would generate a NullPointerException when the code is executed. Of course, the problem might be that the branch or statement is infeasible and that the null pointer exception can't ever be executed; deciding that is beyond the ability of FindBugs.

NP_NULL_ON_SOME_PATH_EXCEPTION: Possible null pointer dereference in method on exception path

A reference value which is null on some exception control path is dereferenced here.  This may lead to a NullPointerException when the code is executed.  Note that because FindBugs currently does not prune infeasible exception paths, this may be a false warning.

Also note that FindBugs considers the default case of a switch statement to be an exception path, since the default case is often infeasible.

RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE: Nullcheck of value previously dereferenced

A value is checked here to see whether it is null, but this value can't be null because it was previously dereferenced and if it were null a null pointer exception would have occurred at the earlier dereference. Essentially, this code and the previous dereference disagree as to whether this value is allowed to be null. Either the check is redundant or the previous dereference is erroneous.

SF_SWITCH_NO_DEFAULT: Switch statement found where default case is missing

This method contains a switch statement where default case is missing. Usually you need to provide a default case.

Because the analysis only looks at the generated bytecode, this warning can be incorrect triggered if the default case is at the end of the switch statement and the switch statement doesn't contain break statements for other cases.

ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD: Write to static field from instance method

This instance method writes to a static field. This is tricky to get correct if multiple instances are being manipulated, and generally bad practice.

UC_USELESS_OBJECT: Useless object created

Our analysis shows that this object is useless. It's created and modified, but its value never go outside of the method or produce any side-effect. Either there is a mistake and object was intended to be used or it can be removed.

This analysis rarely produces false-positives. Common false-positive cases include:

- This object used to implicitly throw some obscure exception.

- This object used as a stub to generalize the code.

- This object used to hold strong references to weak/soft-referenced objects.