utilizing sonar, or findbug, report above error message for this code.
public static void updateQuotation(String symbol, RawQuotation newValue) {
if (quotations == null) {
quotations = new HashMap();
}
quotations.put(symbol, newValue);
}
quotations is a static variable.
what findbug suggesting is actually about thread safety.
Incorrect lazy initialization and update of static field
This method contains an unsynchronized lazy initialization of a static field. After the field is set, the object stored into that location is further accessed. The setting of the field is visible to other threads as soon as it is set. If the futher accesses in the method that set the field serve to initialize the object, then you have a very serious multithreading bug, unless something else prevents any other thread from accessing the stored object until it is fully initialized.