FindBugs Report

Project Information

Project: Apache HBase - RSGroup

FindBugs version: 3.0.0

Code analyzed:



Metrics

1482 lines of code analyzed, in 13 classes, in 1 packages.

Metric Total Density*
High Priority Warnings 1 0.67
Medium Priority Warnings 5 3.37
Total Warnings 6 4.05

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



Contents

Summary

Warning Type Number
Multithreaded correctness Warnings 2
Performance Warnings 2
Dodgy code Warnings 2
Total 6

Warnings

Click on a warning row to see full context information.

Multithreaded correctness Warnings

Code Warning
SC new org.apache.hadoop.hbase.rsgroup.RSGroupInfoManagerImpl(MasterServices) invokes org.apache.hadoop.hbase.rsgroup.RSGroupInfoManagerImpl$RSGroupStartupWorker.start()
SWL org.apache.hadoop.hbase.rsgroup.RSGroupAdminServer.moveServers(Set, String) calls Thread.sleep() with a lock held

Performance Warnings

Code Warning
WMI org.apache.hadoop.hbase.rsgroup.RSGroupBasedLoadBalancer.correctAssignments(Map) makes inefficient use of keySet iterator instead of entrySet iterator
WMI org.apache.hadoop.hbase.rsgroup.RSGroupBasedLoadBalancer.getMisplacedRegions(Map) makes inefficient use of keySet iterator instead of entrySet iterator

Dodgy code Warnings

Code Warning
REC Exception is caught when Exception is not thrown in org.apache.hadoop.hbase.rsgroup.RSGroupInfoManagerImpl$RSGroupStartupWorker.waitForGroupTableOnline()
ST Write to static field org.apache.hadoop.hbase.rsgroup.RSGroupAdminEndpoint.groupInfoManager from instance method org.apache.hadoop.hbase.rsgroup.RSGroupAdminEndpoint.start(CoprocessorEnvironment)

Details

REC_CATCH_EXCEPTION: Exception is caught when Exception is not thrown

This method uses a try-catch block that catches Exception objects, but Exception is not thrown within the try block, and RuntimeException is not explicitly caught. It is a common bug pattern to say try { ... } catch (Exception e) { something } as a shorthand for catching a number of types of exception each of whose catch blocks is identical, but this construct also accidentally catches RuntimeException as well, masking potential bugs.

A better approach is to either explicitly catch the specific exceptions that are thrown, or to explicitly catch RuntimeException exception, rethrow it, and then catch all non-Runtime Exceptions, as shown below:

  try {
    ...
  } catch (RuntimeException e) {
    throw e;
  } catch (Exception e) {
    ... deal with all non-runtime exceptions ...
  }

SC_START_IN_CTOR: Constructor invokes Thread.start()

The constructor starts a thread. This is likely to be wrong if the class is ever extended/subclassed, since the thread will be started before the subclass constructor is started.

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.

SWL_SLEEP_WITH_LOCK_HELD: Method calls Thread.sleep() with a lock held

This method calls Thread.sleep() with a lock held. This may result in very poor performance and scalability, or a deadlock, since other threads may be waiting to acquire the lock. It is a much better idea to call wait() on the lock, which releases the lock and allows other threads to run.

WMI_WRONG_MAP_ITERATOR: Inefficient use of keySet iterator instead of entrySet iterator

This method accesses the value of a Map entry, using a key that was retrieved from a keySet iterator. It is more efficient to use an iterator on the entrySet of the map, to avoid the Map.get(key) lookup.