Details about the known misuse from the MUBench dataset.
Description: | Map.get() may return null. |
Fix Description: |
Check for null. (see diff) |
Violation Types: |
- missing/condition/null_check
|
In File: | org/jfree/chart/plot/CategoryPlot.java |
In Method: | removeDomainMarker(int, Marker, Layer, boolean) |
Code with Misuse: |
class CategoryPlot {
/**
* Removes a marker for a specific dataset/renderer and, if requested,
* sends a {@link PlotChangeEvent} to all registered listeners.
*
* @param index the dataset/renderer index.
* @param marker the marker.
* @param layer the layer (foreground or background).
*
* @return A boolean indicating whether or not the marker was actually
* removed.
*
* @since 1.0.10
*/
public boolean removeDomainMarker(int index, Marker marker, Layer layer,
boolean notify) {
ArrayList markers;
if (layer == Layer.FOREGROUND) {
markers = (ArrayList) this.foregroundDomainMarkers.get(new Integer(
index));
}
else {
markers = (ArrayList) this.backgroundDomainMarkers.get(new Integer(
index));
}
boolean removed = markers.remove(marker);
if (removed && notify) {
fireChangeEvent();
}
return removed;
}
}
|
Code with Pattern(s): |
class CheckMarkersForNull {
void pattern(Map domainMarkers, int index, Marker marker) {
ArrayList markers = (ArrayList) domainMarkers.get(new Integer(index));
if (markers != null) {
markers.remove(marker);
}
}
}
|