nus-yam/ex-repair huggingface dataset:
Program: 90290
Project: 90290
Buggy source:
/** 
 * Calculates the zoom level that allows to display the   {@link BoundingBox} on aview with the  {@link Dimension} and tile size.
 * @param dimension the {@link Dimension} of the view
 * @param boundingBox the {@link BoundingBox} to display
 * @param tileSize the size of the tiles
 * @return the zoom level that allows to display the {@link BoundingBox} on aview with the  {@link Dimension} and tile size
 */
public static byte zoomForBounds(Dimension dimension,BoundingBox boundingBox,int tileSize){
  double dxMax=MercatorProjection.longitudeToPixelX(boundingBox.maxLongitude,(byte)0,tileSize) / tileSize;
  double dxMin=MercatorProjection.longitudeToPixelX(boundingBox.minLongitude,(byte)0,tileSize) / tileSize;
  double zoomX=Math.floor(-Math.log(3.8) * Math.log(Math.abs(dxMax - dxMin)) + dimension.width / tileSize);
  double dyMax=MercatorProjection.latitudeToPixelY(boundingBox.maxLatitude,(byte)0,tileSize) / tileSize;
  double dyMin=MercatorProjection.latitudeToPixelY(boundingBox.minLatitude,(byte)0,tileSize) / tileSize;
  double zoomY=Math.floor(-Math.log(3.8) * Math.log(Math.abs(dyMax - dyMin)) + dimension.height / tileSize);
  return (byte)Double.valueOf(Math.min(zoomX,zoomY)).intValue();
}

Fixed version (ground truth):
/** 
 * Calculates the zoom level that allows to display the   {@link BoundingBox} on aview with the  {@link Dimension} and tile size.
 * @param dimension the {@link Dimension} of the view
 * @param boundingBox the {@link BoundingBox} to display
 * @param tileSize the size of the tiles
 * @return the zoom level that allows to display the {@link BoundingBox} on aview with the  {@link Dimension} and tile size
 */
public static byte zoomForBounds(Dimension dimension,BoundingBox boundingBox,int tileSize){
  double dxMax=MercatorProjection.longitudeToPixelX(boundingBox.maxLongitude,(byte)0,tileSize) / tileSize;
  double dxMin=MercatorProjection.longitudeToPixelX(boundingBox.minLongitude,(byte)0,tileSize) / tileSize;
  double zoomX=Math.floor(-Math.log(3.8) * Math.log(Math.abs(dxMax - dxMin)) + (float)dimension.width / tileSize);
  double dyMax=MercatorProjection.latitudeToPixelY(boundingBox.maxLatitude,(byte)0,tileSize) / tileSize;
  double dyMin=MercatorProjection.latitudeToPixelY(boundingBox.minLatitude,(byte)0,tileSize) / tileSize;
  double zoomY=Math.floor(-Math.log(3.8) * Math.log(Math.abs(dyMax - dyMin)) + (float)dimension.height / tileSize);
  return (byte)Math.min(zoomX,zoomY);
}
Program: 90291
Project: 90291
Buggy source:
/** 
 * Get LatLong form Pixels.
 * @Author Stephan Brandt <stephan@contagt.com>
 */
public static LatLong fromPixels(double pixelX,double pixelY,byte zoomLevel,int tileSize){
  return new LatLong(pixelYToLatitude(pixelY,zoomLevel,tileSize),pixelXToLongitude(pixelX,zoomLevel,tileSize));
}

Fixed version (ground truth):
/** 
 * Get LatLong form Pixels.
 * @author Stephan Brandt <stephan@contagt.com>
 */
public static LatLong fromPixels(double pixelX,double pixelY,byte zoomLevel,int tileSize){
  return new LatLong(pixelYToLatitude(pixelY,zoomLevel,tileSize),pixelXToLongitude(pixelX,zoomLevel,tileSize));
}
Program: 90292
Project: 90292
Buggy source:
@Test public void latitudeToPixelYTest(){
  for (  int tileSize : TILE_SIZES) {
    for (byte zoomLevel=ZOOM_LEVEL_MIN; zoomLevel <= ZOOM_LEVEL_MAX; ++zoomLevel) {
      double pixelY=MercatorProjection.latitudeToPixelY(MercatorProjection.LATITUDE_MAX,zoomLevel,tileSize);
      Assert.assertEquals(0,pixelY,0);
      long mapSize=MercatorProjection.getMapSize(zoomLevel,tileSize);
      pixelY=MercatorProjection.latitudeToPixelY(0,zoomLevel,tileSize);
      Assert.assertEquals(mapSize / 2,pixelY,0);
      pixelY=MercatorProjection.latitudeToPixelY(MercatorProjection.LATITUDE_MIN,zoomLevel,tileSize);
      Assert.assertEquals(mapSize,pixelY,0);
    }
  }
}

Fixed version (ground truth):
@Test public void latitudeToPixelYTest(){
  for (  int tileSize : TILE_SIZES) {
    for (byte zoomLevel=ZOOM_LEVEL_MIN; zoomLevel <= ZOOM_LEVEL_MAX; ++zoomLevel) {
      double pixelY=MercatorProjection.latitudeToPixelY(MercatorProjection.LATITUDE_MAX,zoomLevel,tileSize);
      Assert.assertEquals(0,pixelY,0);
      long mapSize=MercatorProjection.getMapSize(zoomLevel,tileSize);
      pixelY=MercatorProjection.latitudeToPixelY(0,zoomLevel,tileSize);
      Assert.assertEquals((float)mapSize / 2,pixelY,0);
      pixelY=MercatorProjection.latitudeToPixelY(MercatorProjection.LATITUDE_MIN,zoomLevel,tileSize);
      Assert.assertEquals(mapSize,pixelY,0);
    }
  }
}
Program: 90293
Project: 90293
Buggy source:
@Test public void pixelXToLongitudeTest(){
  for (  int tileSize : TILE_SIZES) {
    for (byte zoomLevel=ZOOM_LEVEL_MIN; zoomLevel <= ZOOM_LEVEL_MAX; ++zoomLevel) {
      double longitude=MercatorProjection.pixelXToLongitude(0,zoomLevel,tileSize);
      Assert.assertEquals(LatLongUtils.LONGITUDE_MIN,longitude,0);
      long mapSize=MercatorProjection.getMapSize(zoomLevel,tileSize);
      longitude=MercatorProjection.pixelXToLongitude(mapSize / 2,zoomLevel,tileSize);
      Assert.assertEquals(0,longitude,0);
      longitude=MercatorProjection.pixelXToLongitude(mapSize,zoomLevel,tileSize);
      Assert.assertEquals(LatLongUtils.LONGITUDE_MAX,longitude,0);
    }
    verifyInvalidPixelXToLongitude(-1,(byte)0,tileSize);
    verifyInvalidPixelXToLongitude(tileSize + 1,(byte)0,tileSize);
  }
}

Fixed version (ground truth):
@Test public void pixelXToLongitudeTest(){
  for (  int tileSize : TILE_SIZES) {
    for (byte zoomLevel=ZOOM_LEVEL_MIN; zoomLevel <= ZOOM_LEVEL_MAX; ++zoomLevel) {
      double longitude=MercatorProjection.pixelXToLongitude(0,zoomLevel,tileSize);
      Assert.assertEquals(LatLongUtils.LONGITUDE_MIN,longitude,0);
      long mapSize=MercatorProjection.getMapSize(zoomLevel,tileSize);
      longitude=MercatorProjection.pixelXToLongitude((float)mapSize / 2,zoomLevel,tileSize);
      Assert.assertEquals(0,longitude,0);
      longitude=MercatorProjection.pixelXToLongitude(mapSize,zoomLevel,tileSize);
      Assert.assertEquals(LatLongUtils.LONGITUDE_MAX,longitude,0);
    }
    verifyInvalidPixelXToLongitude(-1,(byte)0,tileSize);
    verifyInvalidPixelXToLongitude(tileSize + 1,(byte)0,tileSize);
  }
}
Program: 90294
Project: 90294
Buggy source:
@Test public void longitudeToPixelXTest(){
  for (  int tileSize : TILE_SIZES) {
    for (byte zoomLevel=ZOOM_LEVEL_MIN; zoomLevel <= ZOOM_LEVEL_MAX; ++zoomLevel) {
      double pixelX=MercatorProjection.longitudeToPixelX(LatLongUtils.LONGITUDE_MIN,zoomLevel,tileSize);
      Assert.assertEquals(0,pixelX,0);
      long mapSize=MercatorProjection.getMapSize(zoomLevel,tileSize);
      pixelX=MercatorProjection.longitudeToPixelX(0,zoomLevel,tileSize);
      Assert.assertEquals(mapSize / 2,pixelX,0);
      pixelX=MercatorProjection.longitudeToPixelX(LatLongUtils.LONGITUDE_MAX,zoomLevel,tileSize);
      Assert.assertEquals(mapSize,pixelX,0);
    }
  }
}

Fixed version (ground truth):
@Test public void longitudeToPixelXTest(){
  for (  int tileSize : TILE_SIZES) {
    for (byte zoomLevel=ZOOM_LEVEL_MIN; zoomLevel <= ZOOM_LEVEL_MAX; ++zoomLevel) {
      double pixelX=MercatorProjection.longitudeToPixelX(LatLongUtils.LONGITUDE_MIN,zoomLevel,tileSize);
      Assert.assertEquals(0,pixelX,0);
      long mapSize=MercatorProjection.getMapSize(zoomLevel,tileSize);
      pixelX=MercatorProjection.longitudeToPixelX(0,zoomLevel,tileSize);
      Assert.assertEquals((float)mapSize / 2,pixelX,0);
      pixelX=MercatorProjection.longitudeToPixelX(LatLongUtils.LONGITUDE_MAX,zoomLevel,tileSize);
      Assert.assertEquals(mapSize,pixelX,0);
    }
  }
}
Program: 90295
Project: 90295
Buggy source:
@Test public void pixelYToLatitudeTest(){
  for (  int tileSize : TILE_SIZES) {
    for (byte zoomLevel=ZOOM_LEVEL_MIN; zoomLevel <= ZOOM_LEVEL_MAX; ++zoomLevel) {
      double latitude=MercatorProjection.pixelYToLatitude(0,zoomLevel,tileSize);
      Assert.assertEquals(MercatorProjection.LATITUDE_MAX,latitude,0);
      long mapSize=MercatorProjection.getMapSize(zoomLevel,tileSize);
      latitude=MercatorProjection.pixelYToLatitude(mapSize / 2,zoomLevel,tileSize);
      Assert.assertEquals(0,latitude,0);
      latitude=MercatorProjection.pixelYToLatitude(mapSize,zoomLevel,tileSize);
      Assert.assertEquals(MercatorProjection.LATITUDE_MIN,latitude,0);
    }
    verifyInvalidPixelYToLatitude(-1,(byte)0,tileSize);
    verifyInvalidPixelYToLatitude(tileSize + 1,(byte)0,tileSize);
  }
}

Fixed version (ground truth):
@Test public void pixelYToLatitudeTest(){
  for (  int tileSize : TILE_SIZES) {
    for (byte zoomLevel=ZOOM_LEVEL_MIN; zoomLevel <= ZOOM_LEVEL_MAX; ++zoomLevel) {
      double latitude=MercatorProjection.pixelYToLatitude(0,zoomLevel,tileSize);
      Assert.assertEquals(MercatorProjection.LATITUDE_MAX,latitude,0);
      long mapSize=MercatorProjection.getMapSize(zoomLevel,tileSize);
      latitude=MercatorProjection.pixelYToLatitude((float)mapSize / 2,zoomLevel,tileSize);
      Assert.assertEquals(0,latitude,0);
      latitude=MercatorProjection.pixelYToLatitude(mapSize,zoomLevel,tileSize);
      Assert.assertEquals(MercatorProjection.LATITUDE_MIN,latitude,0);
    }
    verifyInvalidPixelYToLatitude(-1,(byte)0,tileSize);
    verifyInvalidPixelYToLatitude(tileSize + 1,(byte)0,tileSize);
  }
}
Program: 90296
Project: 90296
Buggy source:
@Override public void setBitmapShader(org.mapsforge.core.graphics.Bitmap bitmap){
  if (bitmap == null) {
    return;
  }
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
  }
  this.paint.setColor(AndroidGraphicFactory.getColor(Color.WHITE));
  this.paint.setShader(new BitmapShader(AndroidGraphicFactory.getBitmap(bitmap),TileMode.REPEAT,TileMode.REPEAT));
}

Fixed version (ground truth):
@Override public void setBitmapShader(org.mapsforge.core.graphics.Bitmap bitmap){
  if (bitmap == null) {
    return;
  }
  if (!AndroidGraphicFactory.keepResourceBitmaps && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
    bitmap.incrementRefCount();
  }
  this.paint.setColor(AndroidGraphicFactory.getColor(Color.WHITE));
  this.paint.setShader(new BitmapShader(AndroidGraphicFactory.getBitmap(bitmap),TileMode.REPEAT,TileMode.REPEAT));
}
Program: 90297
Project: 90297
Buggy source:
/** 
 * Sets the maximum zoom level of the map. <p> The maximum possible zoom level of the MapView depends also on the current   {@link DatabaseRenderer}. For example, downloading map tiles may only be possible up to a certain zoom level. Setting a higher maximum zoom level has no effect in this case.
 * @param zoomLevelMax the maximum zoom level.
 * @throws IllegalArgumentException if the maximum zoom level is smaller than the current minimum zoom level.
 */
public void setZoomLevelMax(byte zoomLevelMax){
  if (zoomLevelMax < this.zoomLevelMin) {
    throw new IllegalArgumentException();
  }
  this.zoomLevelMax=zoomLevelMax;
}

Fixed version (ground truth):
/** 
 * Sets the maximum zoom level of the map. <p> The maximum possible zoom level of the MapView depends also on other elements. For example, downloading map tiles may only be possible up to a certain zoom level. Setting a higher maximum zoom level has no effect in this case.
 * @param zoomLevelMax the maximum zoom level.
 * @throws IllegalArgumentException if the maximum zoom level is smaller than the current minimum zoom level.
 */
public void setZoomLevelMax(byte zoomLevelMax){
  if (zoomLevelMax < this.zoomLevelMin) {
    throw new IllegalArgumentException();
  }
  this.zoomLevelMax=zoomLevelMax;
}
Program: 90299
Project: 90299
Buggy source:
private static Dimension calculateFrameBufferDimension(Dimension mapViewDimension,double overdrawFactor){
  int width=(int)(mapViewDimension.width * overdrawFactor);
  int height=(int)(mapViewDimension.height * overdrawFactor);
  if (useSquareFrameBuffer) {
    float aspectRatio=mapViewDimension.width / mapViewDimension.height;
    if (aspectRatio < maxAspectRatio && aspectRatio > maxAspectRatio / 1) {
      width=Math.max(width,height);
      height=width;
    }
  }
  return new Dimension(width,height);
}

Fixed version (ground truth):
private static Dimension calculateFrameBufferDimension(Dimension mapViewDimension,double overdrawFactor){
  int width=(int)(mapViewDimension.width * overdrawFactor);
  int height=(int)(mapViewDimension.height * overdrawFactor);
  if (useSquareFrameBuffer) {
    float aspectRatio=((float)mapViewDimension.width) / mapViewDimension.height;
    if (aspectRatio < maxAspectRatio && aspectRatio > maxAspectRatio / 1) {
      width=Math.max(width,height);
      height=width;
    }
  }
  return new Dimension(width,height);
}
Program: 90300
Project: 90300
Buggy source:
public TileDownloadLayer(TileCache tileCache,MapViewPosition mapViewPosition,TileSource tileSource,GraphicFactory graphicFactory){
  super(tileCache,mapViewPosition,graphicFactory.createMatrix(),tileSource.hasAlpha());
  if (tileSource == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.tileCache=tileCache;
  this.tileSource=tileSource;
  this.graphicFactory=graphicFactory;
}

Fixed version (ground truth):
public TileDownloadLayer(TileCache tileCache,MapViewPosition mapViewPosition,TileSource tileSource,GraphicFactory graphicFactory){
  super(tileCache,mapViewPosition,graphicFactory.createMatrix(),tileSource.hasAlpha());
  this.tileCache=tileCache;
  this.tileSource=tileSource;
  this.graphicFactory=graphicFactory;
}
Program: 90301
Project: 90301
Buggy source:
@Override public void onDestroy(){
  if (this.bitmap != null) {
    this.bitmap.decrementRefCount();
  }
}

Fixed version (ground truth):
@Override public synchronized void onDestroy(){
  if (this.bitmap != null) {
    this.bitmap.decrementRefCount();
  }
}
Program: 90302
Project: 90302
Buggy source:
public boolean contains(Point center,Point point){
  Rectangle r=new Rectangle(center.x - bitmap.getWidth() / 2 + this.horizontalOffset,center.y - bitmap.getHeight() / 2 + this.verticalOffset,center.x + bitmap.getWidth() / 2 + this.horizontalOffset,center.y + bitmap.getHeight() / 2 + this.verticalOffset);
  return r.contains(point);
}

Fixed version (ground truth):
public synchronized boolean contains(Point center,Point point){
  Rectangle r=new Rectangle(center.x - (float)bitmap.getWidth() / 2 + this.horizontalOffset,center.y - (float)bitmap.getHeight() / 2 + this.verticalOffset,center.x + (float)bitmap.getWidth() / 2 + this.horizontalOffset,center.y + (float)bitmap.getHeight() / 2 + this.verticalOffset);
  return r.contains(point);
}
Program: 90304
Project: 90304
Buggy source:
public MapWorker(TileCache tileCache,JobQueue<RendererJob> jobQueue,DatabaseRenderer databaseRenderer,Layer layer){
  super();
  this.tileCache=tileCache;
  this.jobQueue=jobQueue;
  this.databaseRenderer=databaseRenderer;
  this.layer=layer;
}

Fixed version (ground truth):
public MapWorker(TileCache tileCache,JobQueue<RendererJob> jobQueue,DatabaseRenderer databaseRenderer,Layer layer){
  super();
  if (DEBUG_TIMING) {
    totalTime=new AtomicLong();
    totalExecutions=new AtomicLong();
  }
 else {
    totalTime=null;
    totalExecutions=null;
  }
  this.tileCache=tileCache;
  this.jobQueue=jobQueue;
  this.databaseRenderer=databaseRenderer;
  this.layer=layer;
}
Program: 90305
Project: 90305
Buggy source:
public DisplayModel(){
  this.setTileSize();
}

Fixed version (ground truth):
public DisplayModel(){
  super();
  this.setTileSize();
}
Program: 90306
Project: 90306
Buggy source:
public RenderThemeBuilder(GraphicFactory graphicFactory,DisplayModel displayModel1,String elementName,Attributes attributes) throws SAXException {
  this.baseStrokeWidth=1f;
  this.baseTextSize=1f;
  this.mapBackground=graphicFactory.createColor(Color.WHITE);
  extractValues(graphicFactory,elementName,attributes);
}

Fixed version (ground truth):
public RenderThemeBuilder(GraphicFactory graphicFactory,String elementName,Attributes attributes) throws SAXException {
  this.baseStrokeWidth=1f;
  this.baseTextSize=1f;
  this.mapBackground=graphicFactory.createColor(Color.WHITE);
  extractValues(graphicFactory,elementName,attributes);
}
Program: 90308
Project: 90308
Buggy source:
@Override public void draw(BoundingBox boundingBox,byte zoomLevel,Canvas canvas,Point topLeftPoint){
  List<TilePosition> tilePositions=LayerUtil.getTilePositions(boundingBox,zoomLevel,topLeftPoint,this.displayModel.getTileSize());
  if (!isTransparent) {
    canvas.fillColor(this.displayModel.getBackgroundColor());
  }
  for (int i=tilePositions.size() - 1; i >= 0; --i) {
    TilePosition tilePosition=tilePositions.get(i);
    Point point=tilePosition.point;
    Tile tile=tilePosition.tile;
    Bitmap bitmap=this.tileCache.get(createJob(tile));
    if (bitmap == null) {
      this.jobQueue.add(createJob(tile));
      drawParentTileBitmap(canvas,point,tile);
    }
 else {
      canvas.drawBitmap(bitmap,(int)Math.round(point.x),(int)Math.round(point.y));
      bitmap.decrementRefCount();
    }
  }
  this.jobQueue.notifyWorkers();
}

Fixed version (ground truth):
@Override public void draw(BoundingBox boundingBox,byte zoomLevel,Canvas canvas,Point topLeftPoint){
  List<TilePosition> tilePositions=LayerUtil.getTilePositions(boundingBox,zoomLevel,topLeftPoint,this.displayModel.getTileSize());
  canvas.resetClip();
  if (!isTransparent) {
    canvas.fillColor(this.displayModel.getBackgroundColor());
  }
  for (int i=tilePositions.size() - 1; i >= 0; --i) {
    TilePosition tilePosition=tilePositions.get(i);
    Point point=tilePosition.point;
    Tile tile=tilePosition.tile;
    Bitmap bitmap=this.tileCache.get(createJob(tile));
    if (bitmap == null) {
      this.jobQueue.add(createJob(tile));
      drawParentTileBitmap(canvas,point,tile);
    }
 else {
      canvas.drawBitmap(bitmap,(int)Math.round(point.x),(int)Math.round(point.y));
      bitmap.decrementRefCount();
    }
  }
  this.jobQueue.notifyWorkers();
}
Program: 90309
Project: 90309
Buggy source:
/** 
 * Get the number of tiles that can be stored on the file system
 * @param directory where the cache will reside
 * @param fileSize average size of tile to be cached
 * @return number of tiles that can be stored without running out of space
 */
@SuppressWarnings("String_Node_Str") @TargetApi(18) public static long getAvailableCacheSlots(String directory,int fileSize){
  StatFs statfs=new StatFs(directory);
  if (android.os.Build.VERSION.SDK_INT >= 18) {
    return statfs.getAvailableBytes() / fileSize;
  }
  int result=statfs.getAvailableBlocks() / (fileSize / statfs.getBlockSize());
  return result;
}

Fixed version (ground truth):
/** 
 * Get the number of tiles that can be stored on the file system
 * @param directory where the cache will reside
 * @param fileSize average size of tile to be cached
 * @return number of tiles that can be stored without running out of space
 */
@SuppressWarnings("String_Node_Str") @TargetApi(18) public static long getAvailableCacheSlots(String directory,int fileSize){
  StatFs statfs=new StatFs(directory);
  if (android.os.Build.VERSION.SDK_INT >= 18) {
    return statfs.getAvailableBytes() / fileSize;
  }
  int blocksPerFile=Math.max(fileSize / statfs.getBlockSize(),1);
  return statfs.getAvailableBlocks() / blocksPerFile;
}
Program: 90310
Project: 90310
Buggy source:
/** 
 * Utility function to create a two-level tile cache with the right size. When the cache is created we do not actually know the size of the mapview, so the screenRatio is an approximation of the required size
 * @param c              the Android context
 * @param id             name for the storage directory
 * @param tileSize       tile size
 * @param screenRatio    part of the screen the view takes up
 * @param overdraw       overdraw allowance
 * @return a new cache created on the external storage
 */
public static TileCache createTileCache(Context c,String id,int tileSize,float screenRatio,double overdraw){
  int cacheSize=(int)Math.round(AndroidUtil.getMinimumCacheSize(c,tileSize,overdraw,screenRatio));
  return createExternalStorageTileCache(c,id,cacheSize,tileSize);
}

Fixed version (ground truth):
/** 
 * Utility function to create a two-level tile cache with the right size. When the cache is created we do not actually know the size of the mapview, so the screenRatio is an approximation of the required size
 * @param c              the Android context
 * @param id             name for the storage directory
 * @param tileSize       tile size
 * @param screenRatio    part of the screen the view takes up
 * @param overdraw       overdraw allowance
 * @return a new cache created on the external storage
 */
public static TileCache createTileCache(Context c,String id,int tileSize,float screenRatio,double overdraw){
  int cacheSize=Math.round(AndroidUtil.getMinimumCacheSize(c,tileSize,overdraw,screenRatio));
  return createExternalStorageTileCache(c,id,cacheSize,tileSize);
}
Program: 90311
Project: 90311
Buggy source:
/** 
 * @see List#add(Object)
 */
public synchronized void add(Layer layer){
  checkIsNull(layer);
  layer.setDisplayModel(this.displayModel);
  this.layersList.add(layer);
  layer.assign(this.redrawer);
}

Fixed version (ground truth):
/** 
 * @see List#add(Object)
 */
public synchronized void add(Layer layer){
  checkIsNull(layer);
  layer.setDisplayModel(this.displayModel);
  this.layersList.add(layer);
  layer.assign(this.redrawer);
  this.redrawer.redrawLayers();
}
Program: 90312
Project: 90312
Buggy source:
/** 
 * @see List#addAll(int,Collection)
 */
public synchronized void addAll(int index,Collection<Layer> layers){
  checkIsNull(layers);
  this.layersList.addAll(index,layers);
  for (  Layer layer : layers) {
    layer.setDisplayModel(this.displayModel);
    layer.assign(this.redrawer);
  }
}

Fixed version (ground truth):
/** 
 * @see List#addAll(int,Collection)
 */
public synchronized void addAll(int index,Collection<Layer> layers){
  checkIsNull(layers);
  this.layersList.addAll(index,layers);
  for (  Layer layer : layers) {
    layer.setDisplayModel(this.displayModel);
    layer.assign(this.redrawer);
  }
  this.redrawer.redrawLayers();
}
Program: 90313
Project: 90313
Buggy source:
/** 
 * @see List#clear()
 */
public synchronized void clear(){
  for (  Layer layer : this.layersList) {
    layer.unassign();
  }
  this.layersList.clear();
}

Fixed version (ground truth):
/** 
 * @see List#clear()
 */
public synchronized void clear(){
  for (  Layer layer : this.layersList) {
    layer.unassign();
  }
  this.layersList.clear();
  this.redrawer.redrawLayers();
}
Program: 90314
Project: 90314
Buggy source:
/** 
 * @see List#remove(Object)
 */
public synchronized boolean remove(Layer layer){
  checkIsNull(layer);
  if (this.layersList.remove(layer)) {
    layer.unassign();
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * @see List#remove(Object)
 */
public synchronized boolean remove(Layer layer){
  checkIsNull(layer);
  if (this.layersList.remove(layer)) {
    layer.unassign();
    this.redrawer.redrawLayers();
    return true;
  }
  return false;
}
Program: 90315
Project: 90315
Buggy source:
@Override public void renderArea(Paint fill,Paint stroke,int level){
  List<ShapePaintContainer> list=this.drawingLayers.get(level);
  list.add(new ShapePaintContainer(this.shapeContainer,fill));
  list.add(new ShapePaintContainer(this.shapeContainer,stroke));
}

Fixed version (ground truth):
@Override public void renderArea(Paint fill,Paint stroke,int level){
  List<ShapePaintContainer> list=this.drawingLayers.get(level);
  list.add(new ShapePaintContainer(this.shapeContainer,stroke));
  list.add(new ShapePaintContainer(this.shapeContainer,fill));
}
Program: 90316
Project: 90316
Buggy source:
public static Point getTopLeftPoint(MapPosition mapPosition,Dimension canvasDimension){
  LatLong centerPoint=mapPosition.latLong;
  byte zoomLevel=mapPosition.zoomLevel;
  int halfCanvasWidth=canvasDimension.width / 2;
  int halfCanvasHeight=canvasDimension.height / 2;
  double pixelX=MercatorProjection.longitudeToPixelX(centerPoint.longitude,zoomLevel) - halfCanvasWidth;
  double pixelY=MercatorProjection.latitudeToPixelY(centerPoint.latitude,zoomLevel) - halfCanvasHeight;
  return new Point(pixelX,pixelY);
}

Fixed version (ground truth):
public static Point getTopLeftPoint(MapPosition mapPosition,Dimension canvasDimension){
  LatLong centerPoint=mapPosition.latLong;
  byte zoomLevel=mapPosition.zoomLevel;
  int halfCanvasWidth=canvasDimension.width / 2;
  int halfCanvasHeight=canvasDimension.height / 2;
  double pixelX=Math.round(MercatorProjection.longitudeToPixelX(centerPoint.longitude,zoomLevel));
  double pixelY=Math.round(MercatorProjection.latitudeToPixelY(centerPoint.latitude,zoomLevel));
  return new Point((int)pixelX - halfCanvasWidth,(int)pixelY - halfCanvasHeight);
}
Program: 90317
Project: 90317
Buggy source:
@Override protected void init(){
  super.init();
  this.mapView2.getModel().mapViewPosition.setZoomLevel((byte)12);
  this.observer=new MapViewPositionObserver(this.mapView.getModel().mapViewPosition,this.mapView2.getModel().mapViewPosition){
    Polyline lastLine;
    @Override protected void setCenter(){
      super.setCenter();
      BoundingBox bbox=MapPositionUtil.getBoundingBox(DualOverviewMapViewer.this.mapView.getModel().mapViewPosition.getMapPosition(),DualOverviewMapViewer.this.mapView.getDimension());
      Paint paintStroke=Utils.createPaint(AndroidGraphicFactory.INSTANCE.createColor(Color.RED),2,Style.STROKE);
      Polyline polygon=new Polyline(paintStroke);
      polygon.getLatLongs().add(new LatLong(bbox.minLatitude,bbox.minLongitude));
      polygon.getLatLongs().add(new LatLong(bbox.minLatitude,bbox.maxLongitude));
      polygon.getLatLongs().add(new LatLong(bbox.maxLatitude,bbox.maxLongitude));
      polygon.getLatLongs().add(new LatLong(bbox.maxLatitude,bbox.minLongitude));
      polygon.getLatLongs().add(new LatLong(bbox.minLatitude,bbox.minLongitude));
      if (this.lastLine != null) {
        DualOverviewMapViewer.this.mapView2.getLayerManager().getLayers().remove(this.lastLine);
      }
      DualOverviewMapViewer.this.mapView2.getLayerManager().getLayers().add(polygon);
      this.lastLine=polygon;
    }
    @Override protected void setZoom(){
    }
  }
;
}

Fixed version (ground truth):
@Override protected void init(){
  super.init();
  this.mapView2.getModel().mapViewPosition.setZoomLevel((byte)12);
  this.observer=new MapViewPositionObserver(this.mapView.getModel().mapViewPosition,this.mapView2.getModel().mapViewPosition){
    Polyline lastLine;
    @Override protected void setCenter(){
      super.setCenter();
      BoundingBox bbox=MapPositionUtil.getBoundingBox(DualOverviewMapViewer.this.mapView.getModel().mapViewPosition.getMapPosition(),DualOverviewMapViewer.this.mapView.getDimension());
      Paint paintStroke=Utils.createPaint(AndroidGraphicFactory.INSTANCE.createColor(Color.RED),2,Style.STROKE);
      Polyline polygon=new Polyline(paintStroke,AndroidGraphicFactory.INSTANCE);
      polygon.getLatLongs().add(new LatLong(bbox.minLatitude,bbox.minLongitude));
      polygon.getLatLongs().add(new LatLong(bbox.minLatitude,bbox.maxLongitude));
      polygon.getLatLongs().add(new LatLong(bbox.maxLatitude,bbox.maxLongitude));
      polygon.getLatLongs().add(new LatLong(bbox.maxLatitude,bbox.minLongitude));
      polygon.getLatLongs().add(new LatLong(bbox.minLatitude,bbox.minLongitude));
      if (this.lastLine != null) {
        DualOverviewMapViewer.this.mapView2.getLayerManager().getLayers().remove(this.lastLine);
      }
      DualOverviewMapViewer.this.mapView2.getLayerManager().getLayers().add(polygon);
      this.lastLine=polygon;
    }
    @Override protected void setZoom(){
    }
  }
;
}
Program: 90318
Project: 90318
Buggy source:
@Override protected void setCenter(){
  super.setCenter();
  BoundingBox bbox=MapPositionUtil.getBoundingBox(DualOverviewMapViewer.this.mapView.getModel().mapViewPosition.getMapPosition(),DualOverviewMapViewer.this.mapView.getDimension());
  Paint paintStroke=Utils.createPaint(AndroidGraphicFactory.INSTANCE.createColor(Color.RED),2,Style.STROKE);
  Polyline polygon=new Polyline(paintStroke);
  polygon.getLatLongs().add(new LatLong(bbox.minLatitude,bbox.minLongitude));
  polygon.getLatLongs().add(new LatLong(bbox.minLatitude,bbox.maxLongitude));
  polygon.getLatLongs().add(new LatLong(bbox.maxLatitude,bbox.maxLongitude));
  polygon.getLatLongs().add(new LatLong(bbox.maxLatitude,bbox.minLongitude));
  polygon.getLatLongs().add(new LatLong(bbox.minLatitude,bbox.minLongitude));
  if (this.lastLine != null) {
    DualOverviewMapViewer.this.mapView2.getLayerManager().getLayers().remove(this.lastLine);
  }
  DualOverviewMapViewer.this.mapView2.getLayerManager().getLayers().add(polygon);
  this.lastLine=polygon;
}

Fixed version (ground truth):
@Override protected void setCenter(){
  super.setCenter();
  BoundingBox bbox=MapPositionUtil.getBoundingBox(DualOverviewMapViewer.this.mapView.getModel().mapViewPosition.getMapPosition(),DualOverviewMapViewer.this.mapView.getDimension());
  Paint paintStroke=Utils.createPaint(AndroidGraphicFactory.INSTANCE.createColor(Color.RED),2,Style.STROKE);
  Polyline polygon=new Polyline(paintStroke,AndroidGraphicFactory.INSTANCE);
  polygon.getLatLongs().add(new LatLong(bbox.minLatitude,bbox.minLongitude));
  polygon.getLatLongs().add(new LatLong(bbox.minLatitude,bbox.maxLongitude));
  polygon.getLatLongs().add(new LatLong(bbox.maxLatitude,bbox.maxLongitude));
  polygon.getLatLongs().add(new LatLong(bbox.maxLatitude,bbox.minLongitude));
  polygon.getLatLongs().add(new LatLong(bbox.minLatitude,bbox.minLongitude));
  if (this.lastLine != null) {
    DualOverviewMapViewer.this.mapView2.getLayerManager().getLayers().remove(this.lastLine);
  }
  DualOverviewMapViewer.this.mapView2.getLayerManager().getLayers().add(polygon);
  this.lastLine=polygon;
}
Program: 90319
Project: 90319
Buggy source:
protected void addOverlayLayers(List<Layer> layers){
  LatLong latLong1=new LatLong(52.5,13.4);
  LatLong latLong2=new LatLong(52.499,13.402);
  LatLong latLong3=new LatLong(52.503,13.399);
  LatLong latLong4=new LatLong(52.51,13.401);
  LatLong latLong5=new LatLong(52.508,13.408);
  Polyline polyline=new Polyline(Utils.createPaint(AndroidGraphicFactory.INSTANCE.createColor(Color.BLUE),8,Style.STROKE));
  List<LatLong> latLongs=polyline.getLatLongs();
  latLongs.add(latLong1);
  latLongs.add(latLong2);
  latLongs.add(latLong3);
  Paint paintFill=Utils.createPaint(AndroidGraphicFactory.INSTANCE.createColor(Color.GREEN),2,Style.STROKE);
  Paint paintStroke=Utils.createPaint(AndroidGraphicFactory.INSTANCE.createColor(Color.BLACK),2,Style.STROKE);
  Polygon polygon=new Polygon(paintFill,paintStroke,AndroidGraphicFactory.INSTANCE);
  latLongs=polygon.getLatLongs();
  latLongs.add(latLong2);
  latLongs.add(latLong3);
  latLongs.add(latLong4);
  latLongs.add(latLong5);
  Marker marker1=Utils.createMarker(this,R.drawable.marker_red,latLong1);
  Circle circle=new Circle(latLong3,300,Utils.createPaint(AndroidGraphicFactory.INSTANCE.createColor(Color.WHITE),0,Style.FILL),null);
  layers.add(polyline);
  layers.add(polygon);
  layers.add(circle);
  layers.add(marker1);
}

Fixed version (ground truth):
protected void addOverlayLayers(List<Layer> layers){
  LatLong latLong1=new LatLong(52.5,13.4);
  LatLong latLong2=new LatLong(52.499,13.402);
  LatLong latLong3=new LatLong(52.503,13.399);
  LatLong latLong4=new LatLong(52.51,13.401);
  LatLong latLong5=new LatLong(52.508,13.408);
  Polyline polyline=new Polyline(Utils.createPaint(AndroidGraphicFactory.INSTANCE.createColor(Color.BLUE),8,Style.STROKE),AndroidGraphicFactory.INSTANCE);
  List<LatLong> latLongs=polyline.getLatLongs();
  latLongs.add(latLong1);
  latLongs.add(latLong2);
  latLongs.add(latLong3);
  Paint paintFill=Utils.createPaint(AndroidGraphicFactory.INSTANCE.createColor(Color.GREEN),2,Style.STROKE);
  Paint paintStroke=Utils.createPaint(AndroidGraphicFactory.INSTANCE.createColor(Color.BLACK),2,Style.STROKE);
  Polygon polygon=new Polygon(paintFill,paintStroke,AndroidGraphicFactory.INSTANCE);
  latLongs=polygon.getLatLongs();
  latLongs.add(latLong2);
  latLongs.add(latLong3);
  latLongs.add(latLong4);
  latLongs.add(latLong5);
  Marker marker1=Utils.createMarker(this,R.drawable.marker_red,latLong1);
  Circle circle=new Circle(latLong3,300,Utils.createPaint(AndroidGraphicFactory.INSTANCE.createColor(Color.WHITE),0,Style.FILL),null);
  layers.add(polyline);
  layers.add(polygon);
  layers.add(circle);
  layers.add(marker1);
}
Program: 90320
Project: 90320
Buggy source:
private TileCache createTileCache(){
  TileCache firstLevelTileCache=new InMemoryTileCache(32);
  File cacheDirectory=getDir("String_Node_Str",MODE_PRIVATE);
  TileCache secondLevelTileCache=new FileSystemTileCache(1024,cacheDirectory,AndroidGraphics.INSTANCE);
  return new TwoLevelTileCache(firstLevelTileCache,secondLevelTileCache);
}

Fixed version (ground truth):
private TileCache createTileCache(){
  TileCache firstLevelTileCache=new InMemoryTileCache(64);
  File cacheDirectory=getDir("String_Node_Str",MODE_PRIVATE);
  TileCache secondLevelTileCache=new FileSystemTileCache(1024,cacheDirectory,AndroidGraphics.INSTANCE);
  return new TwoLevelTileCache(firstLevelTileCache,secondLevelTileCache);
}
Program: 90321
Project: 90321
Buggy source:
private static Layer createTileDownloadLayer(TileCache tileCache,MapViewPosition mapViewPosition,LayerManager layerManager){
  TileSource tileSource=OpenStreetMapMapnik.INSTANCE;
  return new TileDownloadLayer(tileCache,mapViewPosition,tileSource,layerManager,GRAPHIC_FACTORY);
}

Fixed version (ground truth):
private static Layer createTileDownloadLayer(TileCache tileCache,MapViewPosition mapViewPosition,LayerManager layerManager){
  TileSource tileSource=OpenStreetMapMapnik.INSTANCE;
  TileDownloadLayer tileDownloadLayer=new TileDownloadLayer(tileCache,mapViewPosition,tileSource,layerManager,GRAPHIC_FACTORY);
  tileDownloadLayer.start();
  return tileDownloadLayer;
}
Program: 90322
Project: 90322
Buggy source:
@Override public void drawCircle(int x,int y,int radius,Paint paint){
  AwtPaint awtPaint=AwtGraphicFactory.getAwtPaint(paint);
  setColorAndStroke(awtPaint);
  int doubleRadius=radius * 2;
  Style style=awtPaint.style;
switch (style) {
case FILL:
    this.graphics2D.fillOval(x - radius,y - radius,doubleRadius,doubleRadius);
  return;
case STROKE:
this.graphics2D.drawOval(x - radius,y - radius,doubleRadius,doubleRadius);
return;
}
throw new IllegalArgumentException("String_Node_Str" + style);
}

Fixed version (ground truth):
@Override public void drawCircle(int x,int y,int radius,Paint paint){
  AwtPaint awtPaint=AwtGraphicFactory.getAwtPaint(paint);
  setColorAndStroke(awtPaint);
  int doubleRadius=radius * 2;
  Style style=awtPaint.style;
switch (style) {
case FILL:
    this.graphics2D.fillOval(x - radius,y - radius,doubleRadius,doubleRadius);
  return;
case STROKE:
this.graphics2D.drawOval(x - radius,y - radius,doubleRadius,doubleRadius);
return;
}
throw new IllegalArgumentException(UNKNOWN_STYLE + style);
}
Program: 90323
Project: 90323
Buggy source:
@Override public void drawPath(Path path,Paint paint){
  AwtPaint awtPaint=AwtGraphicFactory.getAwtPaint(paint);
  AwtPath awtPath=AwtGraphicFactory.getAwtPath(path);
  setColorAndStroke(awtPaint);
  this.graphics2D.setPaint(awtPaint.texturePaint);
  Style style=awtPaint.style;
switch (style) {
case FILL:
    this.graphics2D.fill(awtPath.path2D);
  return;
case STROKE:
this.graphics2D.draw(awtPath.path2D);
return;
}
throw new IllegalArgumentException("String_Node_Str" + style);
}

Fixed version (ground truth):
@Override public void drawPath(Path path,Paint paint){
  AwtPaint awtPaint=AwtGraphicFactory.getAwtPaint(paint);
  AwtPath awtPath=AwtGraphicFactory.getAwtPath(path);
  setColorAndStroke(awtPaint);
  this.graphics2D.setPaint(awtPaint.texturePaint);
  Style style=awtPaint.style;
switch (style) {
case FILL:
    this.graphics2D.fill(awtPath.path2D);
  return;
case STROKE:
this.graphics2D.draw(awtPath.path2D);
return;
}
throw new IllegalArgumentException(UNKNOWN_STYLE + style);
}
Program: 90324
Project: 90324
Buggy source:
static AwtPaint getAwtPaint(Paint paint){
  return ((AwtPaint)paint);
}

Fixed version (ground truth):
static AwtPaint getAwtPaint(Paint paint){
  return (AwtPaint)paint;
}
Program: 90325
Project: 90325
Buggy source:
static AwtPath getAwtPath(Path path){
  return ((AwtPath)path);
}

Fixed version (ground truth):
static AwtPath getAwtPath(Path path){
  return (AwtPath)path;
}
Program: 90326
Project: 90326
Buggy source:
public TileDownloadLayer(TileCache tileCache,MapViewPosition mapViewPosition,TileSource tileSource,LayerManager layerManager,GraphicFactory graphicFactory){
  super(tileCache,mapViewPosition,graphicFactory);
  if (tileSource == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
 else   if (layerManager == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.tileSource=tileSource;
  int numberOfDownloadThreads=Math.min(tileSource.getParallelRequestsLimit(),DOWNLOAD_THREADS_MAX);
  this.tileDownloadThreads=new TileDownloadThread[numberOfDownloadThreads];
  for (int i=0; i < numberOfDownloadThreads; ++i) {
    TileDownloadThread tileDownloadThread=new TileDownloadThread(tileCache,this.jobQueue,layerManager,graphicFactory);
    tileDownloadThread.start();
    this.tileDownloadThreads[i]=tileDownloadThread;
  }
}

Fixed version (ground truth):
public TileDownloadLayer(TileCache tileCache,MapViewPosition mapViewPosition,TileSource tileSource,LayerManager layerManager,GraphicFactory graphicFactory){
  super(tileCache,mapViewPosition,graphicFactory);
  if (tileSource == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
 else   if (layerManager == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.tileSource=tileSource;
  int numberOfDownloadThreads=Math.min(tileSource.getParallelRequestsLimit(),DOWNLOAD_THREADS_MAX);
  this.tileDownloadThreads=new TileDownloadThread[numberOfDownloadThreads];
  for (int i=0; i < numberOfDownloadThreads; ++i) {
    this.tileDownloadThreads[i]=new TileDownloadThread(tileCache,this.jobQueue,layerManager,graphicFactory);
  }
}
Program: 90327
Project: 90327
Buggy source:
@Override public synchronized void draw(BoundingBox boundingBox,byte zoomLevel,Canvas canvas,Point canvasPosition){
  if (this.latLong == null || this.bitmap == null) {
    return;
  }
  double pixelX=MercatorProjection.longitudeToPixelX(this.latLong.longitude,zoomLevel);
  double pixelY=MercatorProjection.latitudeToPixelY(this.latLong.latitude,zoomLevel);
  int left=(int)(pixelX - canvasPosition.x + this.dx - (this.bitmap.getWidth() / 2));
  int top=(int)(pixelY - canvasPosition.y + this.dy - (this.bitmap.getHeight() / 2));
  int right=left + this.bitmap.getWidth();
  int bottom=top + this.bitmap.getHeight();
  Rectangle bitmapRectangle=new Rectangle(left,top,right,bottom);
  Rectangle canvasRectangle=new Rectangle(0,0,canvas.getWidth(),canvas.getHeight());
  if (!canvasRectangle.intersects(bitmapRectangle)) {
    return;
  }
  canvas.drawBitmap(this.bitmap,left,top);
}

Fixed version (ground truth):
@Override public synchronized void draw(BoundingBox boundingBox,byte zoomLevel,Canvas canvas,Point canvasPosition){
  if (this.latLong == null || this.bitmap == null) {
    return;
  }
  double pixelX=MercatorProjection.longitudeToPixelX(this.latLong.longitude,zoomLevel);
  double pixelY=MercatorProjection.latitudeToPixelY(this.latLong.latitude,zoomLevel);
  int halfBitmapWidth=this.bitmap.getWidth() / 2;
  int halfBitmapHeight=this.bitmap.getHeight() / 2;
  int left=(int)(pixelX - canvasPosition.x - halfBitmapWidth + this.dx);
  int top=(int)(pixelY - canvasPosition.y - halfBitmapHeight + this.dy);
  int right=left + this.bitmap.getWidth();
  int bottom=top + this.bitmap.getHeight();
  Rectangle bitmapRectangle=new Rectangle(left,top,right,bottom);
  Rectangle canvasRectangle=new Rectangle(0,0,canvas.getWidth(),canvas.getHeight());
  if (!canvasRectangle.intersects(bitmapRectangle)) {
    return;
  }
  canvas.drawBitmap(this.bitmap,left,top);
}
Program: 90328
Project: 90328
Buggy source:
@Override public void destroy(){
  this.mapWorker.interrupt();
  this.mapDatabase.closeFile();
  super.destroy();
}

Fixed version (ground truth):
@Override public void destroy(){
  new DestroyThread(this.mapWorker,this.mapDatabase).start();
  super.destroy();
}
Program: 90330
Project: 90330
Buggy source:
synchronized void onSizeChanged(){
  this.width=this.mapView.getWidth();
  this.height=this.mapView.getHeight();
  this.mapViewBitmap1=Bitmap.createBitmap(this.width,this.height,Bitmap.Config.RGB_565);
  this.mapViewBitmap2=Bitmap.createBitmap(this.width,this.height,Bitmap.Config.RGB_565);
  clear();
  this.mapViewCanvas.setBitmap(this.mapViewBitmap1);
}

Fixed version (ground truth):
synchronized void onSizeChanged(){
  this.destroy();
  this.mapViewCanvas=new Canvas();
  this.width=this.mapView.getWidth();
  this.height=this.mapView.getHeight();
  this.mapViewBitmap1=Bitmap.createBitmap(this.width,this.height,Bitmap.Config.RGB_565);
  this.mapViewBitmap2=Bitmap.createBitmap(this.width,this.height,Bitmap.Config.RGB_565);
  clear();
  this.mapViewCanvas.setBitmap(this.mapViewBitmap1);
}
Program: 90331
Project: 90331
Buggy source:
synchronized void destroy(){
  if (this.mapViewBitmap1 != null) {
    this.mapViewBitmap1.recycle();
  }
  if (this.mapViewBitmap2 != null) {
    this.mapViewBitmap2.recycle();
  }
}

Fixed version (ground truth):
synchronized void destroy(){
  if (this.mapViewBitmap1 != null) {
    this.mapViewBitmap1.recycle();
  }
  if (this.mapViewBitmap2 != null) {
    this.mapViewBitmap2.recycle();
  }
  this.mapViewCanvas=null;
}
Program: 90332
Project: 90332
Buggy source:
void destroy(){
  this.overlayController.interrupt();
  this.mapMover.interrupt();
  this.mapWorker.interrupt();
  this.zoomAnimator.interrupt();
  try {
    this.mapWorker.join();
  }
 catch (  InterruptedException e) {
    Thread.currentThread().interrupt();
  }
  this.frameBuffer.destroy();
  this.mapScaleBar.destroy();
  this.inMemoryTileCache.destroy();
  this.fileSystemTileCache.destroy();
  this.mapDatabase.closeFile();
}

Fixed version (ground truth):
void destroy(){
  this.overlayController.interrupt();
  this.mapMover.interrupt();
  this.mapWorker.interrupt();
  this.zoomAnimator.interrupt();
  try {
    this.mapWorker.join();
  }
 catch (  InterruptedException e) {
    Thread.currentThread().interrupt();
  }
  this.frameBuffer.destroy();
  this.mapScaleBar.destroy();
  this.inMemoryTileCache.destroy();
  this.fileSystemTileCache.destroy();
  this.databaseRenderer.destroy();
  this.mapDatabase.closeFile();
}
Program: 90334
Project: 90334
Buggy source:
private boolean checkSize(){
  if (this.changeSizeNeeded) {
    return changeSize();
  }
  return true;
}

Fixed version (ground truth):
private boolean checkSize(){
  this.sizeChange.writeLock().lock();
  try {
    if (this.changeSizeNeeded) {
      return changeSize();
    }
    return true;
  }
  finally {
    this.sizeChange.writeLock().unlock();
  }
}
Program: 90335
Project: 90335
Buggy source:
private void recycleBitmaps(){
  recycleBitmap(this.bitmap1);
  recycleBitmap(this.bitmap2);
}

Fixed version (ground truth):
private void recycleBitmaps(){
  if (this.bitmap1 != null) {
    this.bitmap1.recycle();
    this.bitmap1=null;
  }
  if (this.bitmap2 != null) {
    this.bitmap2.recycle();
    this.bitmap2=null;
  }
  this.overlayCanvas=null;
}
Program: 90336
Project: 90336
Buggy source:
@Override protected void afterRun(){
  recycleBitmaps();
}

Fixed version (ground truth):
@Override protected void afterRun(){
  this.recycleBitmaps();
}
Program: 90337
Project: 90337
Buggy source:
private void redraw(){
  this.bitmap2.eraseColor(Color.TRANSPARENT);
  this.overlayCanvas.setBitmap(this.bitmap2);
  MapPosition mapPositionBefore=this.mapView.getMapViewPosition().getMapPosition();
  BoundingBox boundingBox=this.mapView.getMapViewPosition().getBoundingBox();
  List<Overlay> overlays=this.mapView.getOverlays();
synchronized (overlays) {
    for (    Overlay overlay : overlays) {
      overlay.draw(boundingBox,mapPositionBefore.zoomLevel,this.overlayCanvas);
    }
  }
  MapPosition mapPositionAfter=this.mapView.getMapViewPosition().getMapPosition();
synchronized (this.matrix) {
    adjustMatrix(mapPositionBefore,mapPositionAfter);
    swapBitmaps();
  }
  this.mapView.postInvalidate();
}

Fixed version (ground truth):
private void redraw(){
  if (this.overlayCanvas == null) {
    this.overlayCanvas=new Canvas();
  }
  this.bitmap2.eraseColor(Color.TRANSPARENT);
  this.overlayCanvas.setBitmap(this.bitmap2);
  MapPosition mapPositionBefore=this.mapView.getMapViewPosition().getMapPosition();
  BoundingBox boundingBox=this.mapView.getMapViewPosition().getBoundingBox();
  List<Overlay> overlays=this.mapView.getOverlays();
synchronized (overlays) {
    for (    Overlay overlay : overlays) {
      overlay.draw(boundingBox,mapPositionBefore.zoomLevel,this.overlayCanvas);
    }
  }
  MapPosition mapPositionAfter=this.mapView.getMapViewPosition().getMapPosition();
synchronized (this.matrix) {
    adjustMatrix(mapPositionBefore,mapPositionAfter);
    swapBitmaps();
  }
  this.mapView.postInvalidate();
}
Program: 90338
Project: 90338
Buggy source:
public OverlayController(MapView mapView){
  super();
  this.mapView=mapView;
  this.matrix=new Matrix();
  this.overlayCanvas=new Canvas();
  this.changeSizeNeeded=true;
}

Fixed version (ground truth):
public OverlayController(MapView mapView){
  super();
  this.mapView=mapView;
  this.matrix=new Matrix();
  this.changeSizeNeeded=true;
}
Program: 90339
Project: 90339
Buggy source:
private boolean changeSize(){
  recycleBitmaps();
  int width=this.mapView.getWidth();
  int height=this.mapView.getHeight();
  if (width > 0 && height > 0) {
    this.bitmap1=Bitmap.createBitmap(width,height,Bitmap.Config.ARGB_8888);
    this.bitmap2=Bitmap.createBitmap(width,height,Bitmap.Config.ARGB_8888);
    this.changeSizeNeeded=false;
    this.redrawNeeded=true;
    return true;
  }
  return false;
}

Fixed version (ground truth):
private boolean changeSize(){
  int newWidth=this.mapView.getWidth();
  int newHeight=this.mapView.getHeight();
  if (newWidth > 0 && newHeight > 0) {
    if (this.width == newWidth && this.height == newHeight) {
      this.changeSizeNeeded=false;
      this.redrawNeeded=false;
      return false;
    }
    recycleBitmaps();
    this.width=newWidth;
    this.height=newHeight;
    this.bitmap1=Bitmap.createBitmap(newWidth,newHeight,Bitmap.Config.ARGB_8888);
    this.bitmap2=Bitmap.createBitmap(newWidth,newHeight,Bitmap.Config.ARGB_8888);
    this.changeSizeNeeded=false;
    this.redrawNeeded=true;
    return true;
  }
  return false;
}
Program: 90340
Project: 90340
Buggy source:
private void checkRedraw(){
  if (this.redrawNeeded) {
    this.redrawNeeded=false;
    redraw();
  }
}

Fixed version (ground truth):
private void checkRedraw(){
  this.sizeChange.readLock().lock();
  try {
    if (this.redrawNeeded) {
      this.redrawNeeded=false;
      redraw();
    }
  }
  finally {
    this.sizeChange.readLock().unlock();
  }
}
Program: 90341
Project: 90341
Buggy source:
@Override public void setBitmapShader(org.mapsforge.map.graphics.Bitmap bitmap){
  if (bitmap == null) {
    return;
  }
  android.graphics.Bitmap androidBitmap=android.graphics.Bitmap.createBitmap(bitmap.getPixels(),bitmap.getWidth(),bitmap.getHeight(),Config.ARGB_8888);
  Shader shader=new BitmapShader(androidBitmap,TileMode.REPEAT,TileMode.REPEAT);
  this.paint.setShader(shader);
}

Fixed version (ground truth):
@Override public void setBitmapShader(org.mapsforge.map.graphics.Bitmap bitmap){
  if (bitmap == null) {
    return;
  }
  this.bitmap=bitmap;
  android.graphics.Bitmap androidBitmap=android.graphics.Bitmap.createBitmap(bitmap.getPixels(),bitmap.getWidth(),bitmap.getHeight(),Config.ARGB_8888);
  Shader shader=new BitmapShader(androidBitmap,TileMode.REPEAT,TileMode.REPEAT);
  this.paint.setShader(shader);
}
Program: 90342
Project: 90342
Buggy source:
@Override public void destroy(){
}

Fixed version (ground truth):
@Override public void destroy(){
  this.fill.destroy();
  this.stroke.destroy();
}
Program: 90343
Project: 90343
Buggy source:
@Override public void destroy(){
}

Fixed version (ground truth):
@Override public void destroy(){
  this.stroke.destroy();
}
Program: 90344
Project: 90344
Buggy source:
void scale(float scaleX,float scaleY,float pivotX,float pivotY);

Fixed version (ground truth):
void scale(float scaleX,float scaleY);
Program: 90345
Project: 90345
Buggy source:
@Override public void scale(float scaleX,float scaleY,float pivotX,float pivotY){
  this.matrix.preScale(scaleX,scaleY,pivotX,pivotY);
}

Fixed version (ground truth):
@Override public void scale(float scaleX,float scaleY){
  this.matrix.preScale(scaleX,scaleY);
}