I was thinking that it would be good to add SpotBugs 
(https://spotbugs.github.io) into our build to help find bugs earlier in the 
life cycle.  SpotBugs is LGPL but as it is used only in the build and not to 
within this project, then this should be fine with Apache.

The motivation for adding this was from CASSANDRA-17178; the Simulator has 
issues with Serializable classes missing serialVersionUID (as we deal with 
ClassLoaders; this field is strongly recommend in general for all Serializable 
classes), but this project can add more value as there are a large collection 
of potential bugs to look out for; below are a few examples found.

* Number.valueOf vs Number.parse<size>.  In many parts of the code we do 
valueOf which returns a boxed value; we then unbox for the usage; this adds 
more garbage that isn’t needed
* Using Number.compareTo rather than primitive compare functions (causing 
boxing)
* Ignoring return value for functions that don’t have a side effect.  This 
happens in a few cases where we are building a StringBuilder where we call 
.toString but ignore the string… then call it later on
* use of putIfAbsent without looking at the return.  This was found in 
CacheService where we add the SSTable reader to the cache and assume we win the 
race and start using it… rather than using the object that won the race

Reply via email to