Program: 93326
Project: 93326
Buggy source:
/** 
 * Called when a job needs to be executed.
 * @param rendererJob the job that should be executed.
 */
public TileBitmap executeJob(RendererJob rendererJob){
  final int tileSize=rendererJob.tile.tileSize;
  final byte zoomLevel=rendererJob.tile.zoomLevel;
  this.currentLabels=new LinkedList<MapElementContainer>();
  this.currentWayLabels=new HashSet<MapElementContainer>();
  XmlRenderTheme jobTheme=rendererJob.xmlRenderTheme;
  if (!jobTheme.equals(this.previousJobTheme)) {
    this.renderTheme=getRenderTheme(jobTheme,rendererJob.displayModel);
    if (this.renderTheme == null) {
      this.previousJobTheme=null;
      return null;
    }
    this.ways=createWayLists();
    this.previousJobTheme=jobTheme;
  }
  setScaleStrokeWidth(zoomLevel);
  this.renderTheme.scaleTextSize(rendererJob.textScale);
  if (this.mapDatabase != null) {
    MapReadResult mapReadResult=this.mapDatabase.readMapData(rendererJob.tile);
    processReadMapData(ways,mapReadResult,rendererJob.tile);
  }
  TileBitmap bitmap=null;
  if (!rendererJob.labelsOnly) {
    bitmap=this.graphicFactory.createTileBitmap(tileSize,rendererJob.hasAlpha);
    this.canvasRasterer.setCanvasBitmap(bitmap);
    if (rendererJob.displayModel.getBackgroundColor() != this.renderTheme.getMapBackground()) {
      this.canvasRasterer.fill(rendererJob.hasAlpha ? 0 : this.renderTheme.getMapBackground());
    }
    this.canvasRasterer.drawWays(ways,rendererJob.tile);
  }
  if (renderLabels) {
    Set<MapElementContainer> labelsToDraw=new HashSet<MapElementContainer>();
    Set<Tile> neighbours=rendererJob.tile.getNeighbours();
    Iterator<Tile> tileIterator=neighbours.iterator();
    Set<MapElementContainer> undrawableElements=new HashSet<MapElementContainer>();
    while (tileIterator.hasNext()) {
      Tile neighbour=tileIterator.next();
      if (tileCache.containsKey(rendererJob.otherTile(neighbour))) {
        labelsToDraw.addAll(tileDependencies.getOverlappingElements(neighbour,rendererJob.tile));
        for (        MapElementContainer current : currentLabels) {
          if (current.intersects(neighbour.getBoundaryAbsolute())) {
            undrawableElements.add(current);
          }
        }
        tileIterator.remove();
      }
 else {
        tileDependencies.removeTileData(neighbour);
      }
    }
    currentLabels.removeAll(undrawableElements);
    List<MapElementContainer> currentElementsOrdered=LayerUtil.collisionFreeOrdered(currentLabels);
    Iterator<MapElementContainer> currentMapElementsIterator=currentElementsOrdered.iterator();
    while (currentMapElementsIterator.hasNext()) {
      MapElementContainer current=currentMapElementsIterator.next();
      for (      MapElementContainer label : labelsToDraw) {
        if (label.clashesWith(current)) {
          currentMapElementsIterator.remove();
          break;
        }
      }
    }
    labelsToDraw.addAll(currentElementsOrdered);
    for (    Tile tile : neighbours) {
      tileDependencies.removeTileData(rendererJob.tile,tile);
      for (      MapElementContainer element : labelsToDraw) {
        if (element.intersects(tile.getBoundaryAbsolute())) {
          tileDependencies.addOverlappingElement(rendererJob.tile,tile,element);
        }
      }
    }
    this.canvasRasterer.drawMapElements(currentWayLabels,rendererJob.tile);
    this.canvasRasterer.drawMapElements(labelsToDraw,rendererJob.tile);
  }
 else {
    this.labelStore.storeMapItems(rendererJob.tile,this.currentLabels);
  }
  for (int i=this.ways.size() - 1; i >= 0; --i) {
    List<List<ShapePaintContainer>> innerWayList=this.ways.get(i);
    for (int j=innerWayList.size() - 1; j >= 0; --j) {
      innerWayList.get(j).clear();
    }
  }
  return bitmap;
}

Fixed version (ground truth):
/** 
 * Called when a job needs to be executed.
 * @param rendererJob the job that should be executed.
 */
public TileBitmap executeJob(RendererJob rendererJob){
  final int tileSize=rendererJob.tile.tileSize;
  final byte zoomLevel=rendererJob.tile.zoomLevel;
  this.currentLabels=new LinkedList<MapElementContainer>();
  this.currentWayLabels=new HashSet<MapElementContainer>();
  XmlRenderTheme jobTheme=rendererJob.xmlRenderTheme;
  if (!jobTheme.equals(this.previousJobTheme)) {
    this.renderTheme=getRenderTheme(jobTheme,rendererJob.displayModel);
    if (this.renderTheme == null) {
      this.previousJobTheme=null;
      return null;
    }
    this.ways=createWayLists();
    this.previousJobTheme=jobTheme;
  }
  setScaleStrokeWidth(zoomLevel);
  this.renderTheme.scaleTextSize(rendererJob.textScale);
  if (this.mapDatabase != null) {
    MapReadResult mapReadResult=this.mapDatabase.readMapData(rendererJob.tile);
    processReadMapData(ways,mapReadResult,rendererJob.tile);
  }
  TileBitmap bitmap=null;
  if (!rendererJob.labelsOnly) {
    bitmap=this.graphicFactory.createTileBitmap(tileSize,rendererJob.hasAlpha);
    this.canvasRasterer.setCanvasBitmap(bitmap);
    if (!rendererJob.hasAlpha && rendererJob.displayModel.getBackgroundColor() != this.renderTheme.getMapBackground()) {
      this.canvasRasterer.fill(this.renderTheme.getMapBackground());
    }
    this.canvasRasterer.drawWays(ways,rendererJob.tile);
  }
  if (renderLabels) {
    Set<MapElementContainer> labelsToDraw=new HashSet<MapElementContainer>();
    Set<Tile> neighbours=rendererJob.tile.getNeighbours();
    Iterator<Tile> tileIterator=neighbours.iterator();
    Set<MapElementContainer> undrawableElements=new HashSet<MapElementContainer>();
    while (tileIterator.hasNext()) {
      Tile neighbour=tileIterator.next();
      if (tileCache.containsKey(rendererJob.otherTile(neighbour))) {
        labelsToDraw.addAll(tileDependencies.getOverlappingElements(neighbour,rendererJob.tile));
        for (        MapElementContainer current : currentLabels) {
          if (current.intersects(neighbour.getBoundaryAbsolute())) {
            undrawableElements.add(current);
          }
        }
        tileIterator.remove();
      }
 else {
        tileDependencies.removeTileData(neighbour);
      }
    }
    currentLabels.removeAll(undrawableElements);
    List<MapElementContainer> currentElementsOrdered=LayerUtil.collisionFreeOrdered(currentLabels);
    Iterator<MapElementContainer> currentMapElementsIterator=currentElementsOrdered.iterator();
    while (currentMapElementsIterator.hasNext()) {
      MapElementContainer current=currentMapElementsIterator.next();
      for (      MapElementContainer label : labelsToDraw) {
        if (label.clashesWith(current)) {
          currentMapElementsIterator.remove();
          break;
        }
      }
    }
    labelsToDraw.addAll(currentElementsOrdered);
    for (    Tile tile : neighbours) {
      tileDependencies.removeTileData(rendererJob.tile,tile);
      for (      MapElementContainer element : labelsToDraw) {
        if (element.intersects(tile.getBoundaryAbsolute())) {
          tileDependencies.addOverlappingElement(rendererJob.tile,tile,element);
        }
      }
    }
    this.canvasRasterer.drawMapElements(currentWayLabels,rendererJob.tile);
    this.canvasRasterer.drawMapElements(labelsToDraw,rendererJob.tile);
  }
 else {
    this.labelStore.storeMapItems(rendererJob.tile,this.currentLabels);
  }
  for (int i=this.ways.size() - 1; i >= 0; --i) {
    List<List<ShapePaintContainer>> innerWayList=this.ways.get(i);
    for (int j=innerWayList.size() - 1; j >= 0; --j) {
      innerWayList.get(j).clear();
    }
  }
  return bitmap;
}