SpotBugs Report

Project Information

Project: ActiveMQ :: ConnectionFactory

SpotBugs version: 4.8.3

Code analyzed:



Metrics

34 lines of code analyzed, in 1 classes, in 1 packages.

Metric Total Density*
High Priority Warnings 2 58.82
Medium Priority Warnings 2 58.82
Total Warnings 4 117.65

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



Contents

Summary

Warning Type Number
Performance Warnings 4
Total 4

Warnings

Click on a warning row to see full context information.

Performance Warnings

Code Warning
Bx Boxing/unboxing to parse a primitive org.apache.activemq.osgi.cf.ConnectionFactoryProvider.create(ComponentContext)
Bx Boxing/unboxing to parse a primitive org.apache.activemq.osgi.cf.ConnectionFactoryProvider.create(ComponentContext)
Bx org.apache.activemq.osgi.cf.ConnectionFactoryProvider.create(ComponentContext) invokes inefficient new Integer(String) constructor; use Integer.valueOf(String) instead
Bx org.apache.activemq.osgi.cf.ConnectionFactoryProvider.create(ComponentContext) invokes inefficient new Long(String) constructor; use Long.valueOf(String) instead

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.

DM_NUMBER_CTOR: Method invokes inefficient Number constructor; use static valueOf instead

Using new Integer(int) is guaranteed to always result in a new object whereas Integer.valueOf(int) allows caching of values to be done by the compiler, class library, or JVM. Using of cached values avoids object allocation and the code will be faster.

Values between -128 and 127 are guaranteed to have corresponding cached instances and using valueOf is approximately 3.5 times faster than using constructor. For values outside the constant range the performance of both styles is the same.

Unless the class must be compatible with JVMs predating Java 5, use either autoboxing or the valueOf() method when creating instances of Long, Integer, Short, Character, and Byte.