nus-yam/ex-repair huggingface dataset:
Program: 175010
Project: 175010
Buggy source:
public TileInfo call(){
  if (tileFile == null) {
    return null;
  }
  GeoImageReader gir2=imagePool.get();
  String next=buildTileId(level,i,j);
  if (gir2 == null) {
    return new TileInfo(next,tileFile,null);
  }
  try {
    int x=i * (1 << level) * Constant.TILE_SIZE_IMG_LAYER - xpadding;
    int y=j * (1 << level) * Constant.TILE_SIZE_IMG_LAYER - ypadding;
    float zoom=(1 << level);
    final BufferedImage out=createImage(gir2,x,y,Constant.TILE_SIZE_IMG_LAYER,Constant.TILE_SIZE_IMG_LAYER,zoom);
    ImageIO.write(out,"String_Node_Str",tileFile);
    return new TileInfo(next,tileFile,out);
  }
 catch (  Exception ex) {
    logger.error(ex.getMessage(),ex);
  }
 finally {
    imagePool.release(gir2);
  }
  return new TileInfo(next,tileFile,null);
}

Fixed version (ground truth):
public Object[] call(){
  Cache c=CacheManager.getCacheInstance(activeGir.getDisplayName(activeBand));
  StringBuilder ff=new StringBuilder(initfile).append(getBandFolder(activeBand)).append("String_Node_Str").append(i).append("String_Node_Str").append(j).append("String_Node_Str");
  final File f=c.newFile(ff.toString());
  if (f == null) {
    return new Object[]{ff.toString(),null};
  }
  String next=new StringBuilder().append(level).append("String_Node_Str").append(getBandFolder(activeBand)).append("String_Node_Str").append(i).append("String_Node_Str").append(j).toString();
  try {
    int x=i * (1 << level) * Constant.TILE_SIZE_IMG_LAYER - xpadding;
    int y=j * (1 << level) * Constant.TILE_SIZE_IMG_LAYER - ypadding;
    float zoom=(1 << level);
    final BufferedImage out=createImage(activeGir,x,y,Constant.TILE_SIZE_IMG_LAYER,Constant.TILE_SIZE_IMG_LAYER,zoom);
    ImageIO.write(out,"String_Node_Str",f);
    return new Object[]{f.getAbsolutePath(),next,out};
  }
 catch (  Exception ex) {
    logger.error(ex.getMessage(),ex);
  }
 finally {
  }
  return new Object[]{f.getAbsolutePath(),next,null};
}
Program: 175011
Project: 175011
Buggy source:
private boolean tryMemoryCache(GL2 gl,String file,int level,int i,int j,float xmin,float xmax,float ymin,float ymax){
  Texture t=tcm.getTexture(file);
  if (t != null) {
    bindTexture(gl,t,xmin,xmax,ymin,ymax);
    return true;
  }
  return false;
}

Fixed version (ground truth):
private boolean tryMemoryCache(GL gl,String file,float xmin,float xmax,float ymin,float ymax){
  Texture t=tcm.getTexture(file);
  if (t != null) {
    bindTexture(gl,t,xmin,xmax,ymin,ymax);
    return true;
  }
  return false;
}
Program: 175012
Project: 175012
Buggy source:
/** 
 * @param initfile file tile
 * @param level	   zoom level
 * @param i
 * @param j
 */
public void addTileToQueue(final File tileFile,final int level,final int i,final int j){
  String tilesStr=this.buildTileId(level,i,j);
  if (!submitedTiles.contains(tilesStr)) {
    submitedTiles.add(tilesStr);
    futures.add(0,poolExcutorService.submit(new ServiceTile(tileFile,level,i,j)));
  }
}

Fixed version (ground truth):
/** 
 * @param initfile file tile
 * @param level	   zoom level
 * @param i
 * @param j
 */
public void addTileToQueue(final String initfile,final int level,final int i,final int j){
  String tilesStr=new StringBuffer(level).append("String_Node_Str").append(getBandFolder(activeBand)).append("String_Node_Str").append(i).append("String_Node_Str").append(j).toString();
  if (!submitedTiles.contains(tilesStr)) {
    submitedTiles.add(tilesStr);
    futures.add(0,poolExcutorService.submit(new ServiceTile(initfile,level,i,j)));
  }
}
Program: 175013
Project: 175013
Buggy source:
/** 
 * @param gl
 */
private void updateFutures(GL gl){
  List<Future<Object[]>> remove1=new ArrayList<Future<Object[]>>();
  for (  Future<Object[]> f : futures) {
    if (f.isDone() || f.isCancelled()) {
      remove1.add(f);
      try {
        Object[] o=f.get();
        submitedTiles.remove(o[1]);
        if (o.length > 2 && o[2] != null) {
          tcm.add((String)o[0],AWTTextureIO.newTexture(gl.getGLProfile(),(BufferedImage)o[2],false));
        }
      }
 catch (      Exception ex) {
        logger.error(ex.getMessage(),ex);
      }
    }
  }
  futures.removeAll(remove1);
}

Fixed version (ground truth):
/** 
 * @param gl
 */
private void updateFutures(GL gl){
  List<Future<TileInfo>> remove1=new ArrayList<Future<TileInfo>>();
  for (  Future<TileInfo> f : futures) {
    if (f.isDone() || f.isCancelled()) {
      remove1.add(f);
      try {
        TileInfo o=f.get();
        submitedTiles.remove(o.idTile);
        if (o.pngImage != null) {
          tcm.add(o.idTile,AWTTextureIO.newTexture(gl.getGLProfile(),o.pngImage,false));
        }
      }
 catch (      Exception ex) {
        logger.error(ex.getMessage(),ex);
      }
    }
  }
  futures.removeAll(remove1);
}
Program: 175014
Project: 175014
Buggy source:
private boolean tryFileCache(GL gl,String file,int level,int i,int j,float xmin,float xmax,float ymin,float ymax){
  String tileId=new StringBuilder("String_Node_Str").append(level).append("String_Node_Str").append(getBandFolder(activeBand)).append("String_Node_Str").append(i).append("String_Node_Str").append(j).toString();
  Cache cacheInstance=CacheManager.getCacheInstance(activeGir.getDisplayName(activeBand));
  boolean ok=true;
  if (cacheInstance.contains(file) & !submitedTiles.contains(tileId)) {
    BufferedImage temp=null;
    try {
      try {
        temp=ImageIO.read(cacheInstance.newFile(file));
      }
 catch (      Exception ex) {
        try {
          Thread.sleep(200);
        }
 catch (        InterruptedException e) {
          Thread.currentThread().interrupt();
        }
        temp=ImageIO.read(cacheInstance.newFile(file));
      }
      if (temp == null) {
        ok=false;
      }
    }
 catch (    Exception ex) {
      ok=false;
      logger.warn("String_Node_Str" + file + "String_Node_Str"+ ex.getMessage());
    }
 finally {
      pngReader.dispose();
    }
    if (ok) {
      if (temp.getColorModel().getNumComponents() == 1) {
        temp=rescale.filter(temp,rescale.createCompatibleDestImage(temp,temp.getColorModel()));
      }
      Texture t=AWTTextureIO.newTexture(gl.getGLProfile(),temp,false);
      tcm.add(file,t);
      bindTexture(gl,t,xmin,xmax,ymin,ymax);
    }
  }
 else {
    ok=false;
  }
  return ok;
}

Fixed version (ground truth):
private boolean tryFileCache(GL gl,String file,int level,int i,int j,float xmin,float xmax,float ymin,float ymax){
  String tileId=this.buildTileId(level,i,j);
  Cache cacheInstance=CacheManager.getCacheInstance(activeGir.getDisplayName(activeBand));
  boolean ok=true;
  if (cacheInstance.contains(file) && !submitedTiles.contains(tileId)) {
    BufferedImage temp=null;
    try {
      try {
        temp=ImageIO.read(cacheInstance.newFile(file));
      }
 catch (      Exception ex) {
        try {
          Thread.sleep(200);
        }
 catch (        InterruptedException e) {
          Thread.currentThread().interrupt();
        }
        temp=ImageIO.read(cacheInstance.newFile(file));
      }
      if (temp == null) {
        ok=false;
      }
    }
 catch (    Exception ex) {
      ok=false;
      logger.warn("String_Node_Str" + file + "String_Node_Str"+ ex.getMessage());
    }
 finally {
      pngReader.dispose();
    }
    if (ok) {
      if (temp.getColorModel().getNumComponents() == 1) {
        temp=rescale.filter(temp,rescale.createCompatibleDestImage(temp,temp.getColorModel()));
      }
      Texture t=AWTTextureIO.newTexture(gl.getGLProfile(),temp,false);
      tcm.add(file,t);
      bindTexture(gl,t,xmin,xmax,ymin,ymax);
    }
  }
 else {
    ok=false;
  }
  return ok;
}
Program: 175015
Project: 175015
Buggy source:
/** 
 * @param gl
 * @param texture
 * @param xmin
 * @param xmax
 * @param ymin
 * @param ymax
 */
private void bindTexture(GL gl,Texture texture,float xmin,float xmax,float ymin,float ymax){
  texture.enable(gl);
  texture.bind(gl);
  TextureCoords coords=texture.getImageTexCoords();
  gl.getGL2().glBegin(GL2.GL_QUADS);
  gl.getGL2().glTexCoord2f(coords.left(),coords.top());
  gl.getGL2().glVertex2f(xmin,1 - ymin);
  gl.getGL2().glTexCoord2f(coords.right(),coords.top());
  gl.getGL2().glVertex2f(xmax,1 - ymin);
  gl.getGL2().glTexCoord2f(coords.right(),coords.bottom());
  gl.getGL2().glVertex2f(xmax,1 - ymax);
  gl.getGL2().glTexCoord2f(coords.left(),coords.bottom());
  gl.getGL2().glVertex2f(xmin,1 - ymax);
  gl.getGL2().glEnd();
  texture.disable(gl);
}

Fixed version (ground truth):
/** 
 * @param gl
 * @param texture
 * @param xmin
 * @param xmax
 * @param ymin
 * @param ymax
 */
private void bindTexture(GL gl,Texture texture,float xmin,float xmax,float ymin,float ymax){
  texture.enable(gl);
  texture.bind(gl);
  TextureCoords coords=texture.getImageTexCoords();
  gl.getGL2().glBegin(GL2.GL_POLYGON);
  gl.getGL2().glTexCoord2f(coords.left(),coords.top());
  gl.getGL2().glVertex2f(xmin,1 - ymin);
  gl.getGL2().glTexCoord2f(coords.right(),coords.top());
  gl.getGL2().glVertex2f(xmax,1 - ymin);
  gl.getGL2().glTexCoord2f(coords.right(),coords.bottom());
  gl.getGL2().glVertex2f(xmax,1 - ymax);
  gl.getGL2().glTexCoord2f(coords.left(),coords.bottom());
  gl.getGL2().glVertex2f(xmin,1 - ymax);
  gl.getGL2().glEnd();
  texture.disable(gl);
}
Program: 175016
Project: 175016
Buggy source:
public Object[] call(){
  Cache c=CacheManager.getCacheInstance(activeGir.getDisplayName(activeBand));
  StringBuilder ff=new StringBuilder(initfile).append(getBandFolder(activeBand)).append("String_Node_Str").append(i).append("String_Node_Str").append(j).append("String_Node_Str");
  final File f=c.newFile(ff.toString());
  if (f == null) {
    return new Object[]{ff.toString(),null};
  }
  GeoImageReader gir2=imagePool.get();
  String next=new StringBuilder().append(level).append("String_Node_Str").append(getBandFolder(activeBand)).append("String_Node_Str").append(i).append("String_Node_Str").append(j).toString();
  if (gir2 == null) {
    return new Object[]{f.getAbsolutePath(),next,null};
  }
  try {
    int x=i * (1 << level) * Constant.TILE_SIZE_IMG_LAYER - xpadding;
    int y=j * (1 << level) * Constant.TILE_SIZE_IMG_LAYER - ypadding;
    float zoom=(1 << level);
    final BufferedImage out=createImage(gir2,x,y,Constant.TILE_SIZE_IMG_LAYER,Constant.TILE_SIZE_IMG_LAYER,zoom);
    ImageIO.write(out,"String_Node_Str",f);
    return new Object[]{f.getAbsolutePath(),next,out};
  }
 catch (  Exception ex) {
    logger.error(ex.getMessage(),ex);
  }
 finally {
    imagePool.release(gir2);
  }
  return new Object[]{f.getAbsolutePath(),next,null};
}

Fixed version (ground truth):
public TileInfo call(){
  Cache c=CacheManager.getCacheInstance(activeGir.getDisplayName(activeBand));
  StringBuilder ff=new StringBuilder(initfile).append(getBandFolder(activeBand)).append("String_Node_Str").append(i).append("String_Node_Str").append(j).append("String_Node_Str");
  final File f=c.newFile(ff.toString());
  if (f == null) {
    return new TileInfo(null,ff.toString(),null);
  }
  GeoImageReader gir2=imagePool.get();
  String next=new StringBuilder().append(level).append("String_Node_Str").append(getBandFolder(activeBand)).append("String_Node_Str").append(i).append("String_Node_Str").append(j).toString();
  if (gir2 == null) {
    return new TileInfo(next,f.getAbsolutePath(),null);
  }
  try {
    int x=i * (1 << level) * Constant.TILE_SIZE_IMG_LAYER - xpadding;
    int y=j * (1 << level) * Constant.TILE_SIZE_IMG_LAYER - ypadding;
    float zoom=(1 << level);
    final BufferedImage out=createImage(gir2,x,y,Constant.TILE_SIZE_IMG_LAYER,Constant.TILE_SIZE_IMG_LAYER,zoom);
    ImageIO.write(out,"String_Node_Str",f);
    return new TileInfo(next,f.getAbsolutePath(),out);
  }
 catch (  Exception ex) {
    logger.error(ex.getMessage(),ex);
  }
 finally {
    imagePool.release(gir2);
  }
  return new TileInfo(next,f.getAbsolutePath(),null);
}
Program: 175017
Project: 175017
Buggy source:
/** 
 * @param initfile file tile
 * @param level	   zoom level
 * @param i
 * @param j
 */
public void addTileToQueue(final String initfile,final int level,final int i,final int j){
  String tilesStr=new StringBuffer(level).append("String_Node_Str").append(getBandFolder(activeBand)).append("String_Node_Str").append(i).append("String_Node_Str").append(j).toString();
  if (!submitedTiles.contains(tilesStr)) {
    submitedTiles.add(tilesStr);
    futures.add(0,poolExcutorService.submit(new ServiceTile(initfile,level,i,j)));
  }
}

Fixed version (ground truth):
/** 
 * @param initfile file tile
 * @param level	   zoom level
 * @param i
 * @param j
 */
public void addTileToQueue(final String initfile,final int level,final int i,final int j){
  String tilesStr=this.buildTileId(level,i,j);
  if (!submitedTiles.contains(tilesStr)) {
    submitedTiles.add(tilesStr);
    futures.add(0,poolExcutorService.submit(new ServiceTile(initfile,level,i,j)));
  }
}
Program: 175018
Project: 175018
Buggy source:
public boolean contains(String fileName){
  if (fileName == null) {
    return false;
  }
  fileName=clean(fileName);
  java.io.File file;
  if (fileName.startsWith(getPath().getAbsolutePath())) {
    file=new java.io.File(fileName);
  }
 else {
    file=new File(new StringBuilder(getPath().getAbsolutePath()).append("String_Node_Str").append(fileName).toString());
  }
  if (file.exists()) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * @param fileName
 * @return
 */
public boolean contains(String fileName){
  if (fileName == null) {
    return false;
  }
  fileName=clean(fileName);
  java.io.File file;
  if (fileName.startsWith(getPath().getAbsolutePath())) {
    file=new java.io.File(fileName);
  }
 else {
    file=new File(new StringBuilder(getPath().getAbsolutePath()).append("String_Node_Str").append(fileName).toString());
  }
  if (file.exists()) {
    return true;
  }
  return false;
}
Program: 175019
Project: 175019
Buggy source:
/** 
 * Reads single pixel value of the curent band.
 * @param x
 * @param y
 * @return pixel value
 */
public int readPixel(int x,int y,int band);

Fixed version (ground truth):
/** 
 * Reads single pixel value of the curent band.
 * @param x
 * @param y
 * @return pixel value
 */
public long readPixel(int x,int y,int band);
Program: 175020
Project: 175020
Buggy source:
@Override public int readPixel(int x,int y,int band){
  TIFFImageReadParam t=new TIFFImageReadParam();
  t.setSourceRegion(new Rectangle(x,y,1,1));
  int[] pix=new int[1];
  tiffRaster.getPixel(x,y,pix);
  return pix[0];
}

Fixed version (ground truth):
@Override public long readPixel(int x,int y,int band){
  TIFFImageReadParam t=new TIFFImageReadParam();
  t.setSourceRegion(new Rectangle(x,y,1,1));
  int[] pix=new int[1];
  tiffRaster.getPixel(x,y,pix);
  return pix[0];
}
Program: 175021
Project: 175021
Buggy source:
public int readPixel(int x,int y,int band){
  return readTile(x,y,1,1,band)[0];
}

Fixed version (ground truth):
public long readPixel(int x,int y,int band){
  return readTile(x,y,1,1,band)[0];
}
Program: 175022
Project: 175022
Buggy source:
@Override public int readPixel(int x,int y,int band){
  return read(x,y,1,1,band)[0];
}

Fixed version (ground truth):
@Override public long readPixel(int x,int y,int band){
  return read(x,y,1,1,band)[0];
}
Program: 175023
Project: 175023
Buggy source:
@Override public int[] readTile(int x,int y,int width,int height,int band){
  TIFF tiff=(TIFF)getImage(band);
  Rectangle rect=new Rectangle(x,y,width,height);
  rect=rect.intersection(tiff.getBounds());
  int[] tile=new int[height * width];
  if (rect.isEmpty()) {
    return tile;
  }
  if (rect.y != preloadedInterval[0] || rect.y + rect.height != preloadedInterval[1] || preloadedData.length < (rect.width * rect.height - 1)) {
    preloadLineTile(rect.y,rect.height,band);
  }
 else {
    logger.debug("String_Node_Str");
  }
  int yOffset=tiff.xSize;
  int xinit=rect.x - x;
  int yinit=rect.y - y;
  for (int i=0; i < rect.height; i++) {
    for (int j=0; j < rect.width; j++) {
      int temp=i * yOffset + j + rect.x;
      try {
        tile[(i + yinit) * width + j + xinit]=preloadedData[temp];
      }
 catch (      ArrayIndexOutOfBoundsException e) {
        logger.warn("String_Node_Str" + e.getMessage());
      }
    }
  }
  return tile;
}

Fixed version (ground truth):
@Override public int[] readTile(int x,int y,int width,int height,int band){
  TIFF tiff=(TIFF)getImage(band);
  Rectangle rect=new Rectangle(x,y,width,height);
  rect=rect.intersection(tiff.getBounds());
  int[] tile=new int[height * width];
  if (rect.isEmpty()) {
    return tile;
  }
  if (rect.y != preloadedInterval[0] || rect.y + rect.height != preloadedInterval[1] || preloadedData.length < (rect.width * rect.height - 1)) {
    preloadLineTile(rect.y,rect.height,band);
  }
 else {
    logger.debug("String_Node_Str");
  }
  int yOffset=tiff.xSize;
  int xinit=rect.x - x;
  int yinit=rect.y - y;
  for (int i=0; i < rect.height; i++) {
    for (int j=0; j < rect.width; j++) {
      int temp=i * yOffset + j + rect.x;
      try {
        tile[(i + yinit) * width + j + xinit]=(int)preloadedData[temp];
      }
 catch (      ArrayIndexOutOfBoundsException e) {
        logger.warn("String_Node_Str" + e.getMessage());
      }
    }
  }
  return tile;
}
Program: 175024
Project: 175024
Buggy source:
@Override public void preloadLineTile(int y,int length,int band){
  TIFF tiff=(TIFF)getImage(band);
  if (y < 0) {
    return;
  }
  preloadedInterval=new int[]{y,y + length};
  Rectangle rect=new Rectangle(0,y,tiff.xSize,length);
  rect=tiff.getBounds().intersection(rect);
  try {
    BufferedImage bi=null;
    try {
      bi=tiff.read(0,rect);
    }
 catch (    Exception e) {
      logger.warn("String_Node_Str" + 0 + "String_Node_Str"+ y+ "String_Node_Str");
      try {
        Thread.sleep(100);
      }
 catch (      InterruptedException exx) {
        Thread.currentThread().interrupt();
      }
      bi=tiff.read(0,rect);
    }
    WritableRaster raster=bi.getRaster();
    preloadedData=(short[])raster.getDataElements(0,0,raster.getWidth(),raster.getHeight(),null);
  }
 catch (  Exception ex) {
    logger.error(ex.getMessage(),ex);
  }
 finally {
  }
}

Fixed version (ground truth):
@Override public void preloadLineTile(int y,int length,int band){
  TIFF tiff=(TIFF)getImage(band);
  if (y < 0) {
    return;
  }
  preloadedInterval=new int[]{y,y + length};
  Rectangle rect=new Rectangle(0,y,tiff.xSize,length);
  rect=tiff.getBounds().intersection(rect);
  try {
    BufferedImage bi=null;
    try {
      bi=tiff.read(0,rect);
    }
 catch (    Exception e) {
      logger.warn("String_Node_Str" + 0 + "String_Node_Str"+ y+ "String_Node_Str");
      try {
        Thread.sleep(100);
      }
 catch (      InterruptedException exx) {
        Thread.currentThread().interrupt();
      }
      bi=tiff.read(0,rect);
    }
    WritableRaster raster=bi.getRaster();
    preloadedData=(Short[])raster.getDataElements(0,0,raster.getWidth(),raster.getHeight(),null);
  }
 catch (  Exception ex) {
    logger.error(ex.getMessage(),ex);
  }
 finally {
  }
}
Program: 175025
Project: 175025
Buggy source:
@Override public int[] readTile(int x,int y,int width,int height,int band){
  Rectangle rect=new Rectangle(x,y,width,height);
  rect=rect.intersection(getImage(band).getBounds());
  int[] tile=new int[height * width];
  if (rect.isEmpty()) {
    return tile;
  }
  if (rect.y != preloadedInterval[0] || rect.y + rect.height != preloadedInterval[1] || preloadedData.length < (rect.width * rect.height - 1)) {
    preloadLineTile(rect.y,rect.height,band);
  }
 else {
    logger.debug("String_Node_Str");
  }
  int yOffset=getImage(band).xSize;
  int xinit=rect.x - x;
  int yinit=rect.y - y;
  for (int i=0; i < rect.height; i++) {
    for (int j=0; j < rect.width; j++) {
      int temp=i * yOffset + j + rect.x;
      try {
        tile[(i + yinit) * width + j + xinit]=preloadedData[temp];
      }
 catch (      ArrayIndexOutOfBoundsException e) {
        logger.warn("String_Node_Str" + e.getMessage());
      }
    }
  }
  return tile;
}

Fixed version (ground truth):
@Override public int[] readTile(int x,int y,int width,int height,int band){
  Rectangle rect=new Rectangle(x,y,width,height);
  rect=rect.intersection(getImage(band).getBounds());
  int[] tile=new int[height * width];
  if (rect.isEmpty()) {
    return tile;
  }
  if (rect.y != preloadedInterval[0] || rect.y + rect.height != preloadedInterval[1] || preloadedData.length < (rect.width * rect.height - 1)) {
    preloadLineTile(rect.y,rect.height,band);
  }
 else {
  }
  int yOffset=getImage(band).xSize;
  int xinit=rect.x - x;
  int yinit=rect.y - y;
  for (int i=0; i < rect.height; i++) {
    for (int j=0; j < rect.width; j++) {
      int temp=i * yOffset + j + rect.x;
      try {
        tile[(i + yinit) * width + j + xinit]=((Short)preloadedData[temp]).intValue();
      }
 catch (      ArrayIndexOutOfBoundsException e) {
        logger.warn("String_Node_Str" + e.getMessage());
      }
    }
  }
  return tile;
}
Program: 175026
Project: 175026
Buggy source:
@Override public void preloadLineTile(int y,int length,int band){
  if (y < 0) {
    return;
  }
  preloadedInterval=new int[]{y,y + length};
  Rectangle rect=new Rectangle(0,y,getImage(band).xSize,length);
  TIFF tiff=getImage(band);
  rect=tiff.getBounds().intersection(rect);
  try {
    BufferedImage bi=null;
    try {
      bi=tiff.read(0,rect);
    }
 catch (    Exception e) {
      logger.warn("String_Node_Str" + 0 + "String_Node_Str"+ y+ "String_Node_Str");
      try {
        Thread.sleep(100);
      }
 catch (      InterruptedException exx) {
        Thread.currentThread().interrupt();
      }
      bi=tiff.read(0,rect);
    }
    WritableRaster raster=bi.getRaster();
    preloadedData=(short[])raster.getDataElements(0,0,raster.getWidth(),raster.getHeight(),null);
  }
 catch (  Exception ex) {
    logger.error(ex.getMessage(),ex);
  }
 finally {
  }
}

Fixed version (ground truth):
@Override public void preloadLineTile(int y,int length,int band){
  if (y < 0) {
    return;
  }
  preloadedInterval=new int[]{y,y + length};
  Rectangle rect=new Rectangle(0,y,getImage(band).xSize,length);
  TIFF tiff=getImage(band);
  rect=tiff.getBounds().intersection(rect);
  try {
    BufferedImage bi=null;
    try {
      bi=tiff.read(0,rect);
    }
 catch (    Exception e) {
      logger.warn("String_Node_Str" + 0 + "String_Node_Str"+ y+ "String_Node_Str");
      try {
        Thread.sleep(100);
      }
 catch (      InterruptedException exx) {
        Thread.currentThread().interrupt();
      }
      bi=tiff.read(0,rect);
    }
    WritableRaster raster=bi.getRaster();
    short[] ss=(short[])raster.getDataElements(0,0,raster.getWidth(),raster.getHeight(),null);
    preloadedData=ArrayUtils.toObject(ss);
  }
 catch (  Exception ex) {
    logger.error(ex.getMessage(),ex);
  }
 finally {
  }
}
Program: 175027
Project: 175027
Buggy source:
@Override public int readPixel(int x,int y,int band){
  return read(x,y,1,1,band)[0];
}

Fixed version (ground truth):
@Override public long readPixel(int x,int y,int band){
  return read(x,y,1,1,band)[0];
}
Program: 175028
Project: 175028
Buggy source:
@Override public int[] read(int x,int y,int width,int height,int band){
  int data[]=null;
  GeoToolsGDALReader tiff=(GeoToolsGDALReader)getImage(band);
  try {
    short[] b=tiff.readShortValues(x,y,width,height);
    data=new int[b.length];
    for (int i=0; i < b.length; i++)     data[i]=b[i];
  }
 catch (  Exception ex) {
    logger.warn(ex.getMessage());
  }
 finally {
  }
  return data;
}

Fixed version (ground truth):
@Override public int[] read(int x,int y,int width,int height,int band){
  int data[]=null;
  GeoToolsGDALReader tiff=(GeoToolsGDALReader)getImage(band);
  try {
    int[] b=tiff.readPixValues(x,y,width,height);
    data=new int[b.length];
    for (int i=0; i < b.length; i++)     data[i]=b[i];
  }
 catch (  Exception ex) {
    logger.warn(ex.getMessage());
  }
 finally {
  }
  return data;
}
Program: 175029
Project: 175029
Buggy source:
@Override public int[] readTile(int x,int y,int width,int height,int band){
  Rectangle rect=new Rectangle(x,y,width,height);
  rect=rect.intersection(getImage(band).getBounds());
  int[] tile=new int[height * width];
  if (rect.isEmpty()) {
    return tile;
  }
  if (rect.y != preloadedInterval[0] || rect.y + rect.height != preloadedInterval[1] || preloadedData.length < (rect.y * rect.height - 1)) {
    preloadLineTile(rect.y,rect.height,band);
  }
 else {
  }
  int yOffset=getImage(band).getxSize();
  int xinit=rect.x - x;
  int yinit=rect.y - y;
  for (int i=0; i < rect.height; i++) {
    for (int j=0; j < rect.width; j++) {
      int temp=i * yOffset + j + rect.x;
      try {
        tile[(i + yinit) * width + j + xinit]=preloadedData[temp];
      }
 catch (      ArrayIndexOutOfBoundsException e) {
        logger.warn("String_Node_Str" + e.getMessage());
      }
    }
  }
  return tile;
}

Fixed version (ground truth):
@Override public int[] readTile(int x,int y,int width,int height,int band){
  Rectangle rect=new Rectangle(x,y,width,height);
  rect=rect.intersection(getImage(band).getBounds());
  int[] tile=new int[height * width];
  if (rect.isEmpty()) {
    return tile;
  }
  if (rect.y != preloadedInterval[0] || rect.y + rect.height != preloadedInterval[1] || preloadedData.length < (rect.y * rect.height - 1)) {
    preloadLineTile(rect.y,rect.height,band);
  }
 else {
  }
  int yOffset=getImage(band).getxSize();
  int xinit=rect.x - x;
  int yinit=rect.y - y;
  for (int i=0; i < rect.height; i++) {
    for (int j=0; j < rect.width; j++) {
      int temp=i * yOffset + j + rect.x;
      try {
        tile[(i + yinit) * width + j + xinit]=(int)preloadedData[temp];
      }
 catch (      ArrayIndexOutOfBoundsException e) {
        logger.warn("String_Node_Str" + e.getMessage());
      }
    }
  }
  return tile;
}
Program: 175030
Project: 175030
Buggy source:
@Override public void preloadLineTile(int y,int length,int band){
  if (y < 0) {
    return;
  }
  GeoToolsGDALReader tiff=(GeoToolsGDALReader)getImage(band);
  preloadedInterval=new int[]{y,y + length};
  Rectangle rect=new Rectangle(0,y,tiff.getxSize(),length);
  rect=tiff.getBounds().intersection(rect);
  try {
    short[] bi=null;
    try {
      bi=tiff.readShortValues(0,y,rect.width,rect.height);
    }
 catch (    Exception e) {
      logger.warn("String_Node_Str" + 0 + "String_Node_Str"+ y+ "String_Node_Str");
      try {
        Thread.sleep(100);
      }
 catch (      InterruptedException exx) {
        Thread.currentThread().interrupt();
      }
      bi=tiff.readShortValues(0,y,rect.width,rect.height);
    }
    preloadedData=bi;
  }
 catch (  Exception ex) {
    logger.error(ex.getMessage(),ex);
  }
 finally {
  }
}

Fixed version (ground truth):
@Override public void preloadLineTile(int y,int length,int band){
  if (y < 0) {
    return;
  }
  GeoToolsGDALReader tiff=(GeoToolsGDALReader)getImage(band);
  preloadedInterval=new int[]{y,y + length};
  Rectangle rect=new Rectangle(0,y,tiff.getxSize(),length);
  rect=tiff.getBounds().intersection(rect);
  try {
    int[] bi=null;
    try {
      bi=tiff.readPixValues(0,y,rect.width,rect.height);
    }
 catch (    Exception e) {
      logger.warn("String_Node_Str" + 0 + "String_Node_Str"+ y+ "String_Node_Str");
      try {
        Thread.sleep(100);
      }
 catch (      InterruptedException exx) {
        Thread.currentThread().interrupt();
      }
      bi=tiff.readPixValues(0,y,rect.width,rect.height);
    }
    preloadedData=ArrayUtils.toObject(bi);
  }
 catch (  Exception ex) {
    logger.error(ex.getMessage(),ex);
  }
 finally {
  }
}
Program: 175031
Project: 175031
Buggy source:
@Override public int readPixel(int x,int y,int band){
  Rectangle rect=new Rectangle(x,y,1,1);
  rect=rect.intersection(getImage(band).getBounds());
  short data[]=null;
  GeoToolsGDALReader img=(GeoToolsGDALReader)getImage(band);
  try {
    data=img.readShortValues(x,y,1,1);
  }
  finally {
  }
  return data[0];
}

Fixed version (ground truth):
@Override public long readPixel(int x,int y,int band){
  Rectangle rect=new Rectangle(x,y,1,1);
  rect=rect.intersection(getImage(band).getBounds());
  int data[]=null;
  GeoToolsGDALReader img=(GeoToolsGDALReader)getImage(band);
  try {
    data=img.readPixValues(x,y,1,1);
  }
  finally {
  }
  return data[0];
}
Program: 175032
Project: 175032
Buggy source:
@Override public int[] readTile(int x,int y,int width,int height,int band){
  Rectangle rect=new Rectangle(x,y,width,height);
  rect=rect.intersection(getImage(band).getBounds());
  int[] tile=new int[height * width];
  if (rect.isEmpty()) {
    return tile;
  }
  if (rect.y != preloadedInterval[0] || rect.y + rect.height != preloadedInterval[1] || preloadedData.length < (rect.y * rect.height - 1)) {
    preloadLineTile(rect.y,rect.height,band);
  }
 else {
  }
  int yOffset=getImage(band).getxSize();
  int xinit=rect.x - x;
  int yinit=rect.y - y;
  for (int i=0; i < rect.height; i++) {
    for (int j=0; j < rect.width; j++) {
      int temp=i * yOffset + j + rect.x;
      try {
        tile[(i + yinit) * width + j + xinit]=preloadedData[temp];
      }
 catch (      ArrayIndexOutOfBoundsException e) {
        logger.warn("String_Node_Str" + e.getMessage());
      }
    }
  }
  return tile;
}

Fixed version (ground truth):
@Override public int[] readTile(int x,int y,int width,int height,int band){
  Rectangle rect=new Rectangle(x,y,width,height);
  rect=rect.intersection(getImage(band).getBounds());
  int[] tile=new int[height * width];
  if (rect.isEmpty()) {
    return tile;
  }
  if (rect.y != preloadedInterval[0] || rect.y + rect.height != preloadedInterval[1] || preloadedData.length < (rect.y * rect.height - 1)) {
    preloadLineTile(rect.y,rect.height,band);
  }
 else {
  }
  int yOffset=getImage(band).getxSize();
  int xinit=rect.x - x;
  int yinit=rect.y - y;
  for (int i=0; i < rect.height; i++) {
    for (int j=0; j < rect.width; j++) {
      int temp=i * yOffset + j + rect.x;
      try {
        tile[(i + yinit) * width + j + xinit]=(int)preloadedData[temp];
      }
 catch (      ArrayIndexOutOfBoundsException e) {
        logger.warn("String_Node_Str" + e.getMessage());
      }
    }
  }
  return tile;
}
Program: 175033
Project: 175033
Buggy source:
@Override public void preloadLineTile(int y,int length,int band){
  if (y < 0) {
    return;
  }
  CeosBinaryReader tiff=(CeosBinaryReader)getImage(band);
  preloadedInterval=new int[]{y,y + length};
  Rectangle rect=new Rectangle(0,y,tiff.getxSize(),length);
  rect=tiff.getBounds().intersection(rect);
  try {
    short[] bi=null;
    try {
      bi=tiff.readShort(0,y,rect.width,rect.height);
    }
 catch (    Exception e) {
      logger.warn("String_Node_Str" + 0 + "String_Node_Str"+ y+ "String_Node_Str");
      try {
        Thread.sleep(100);
      }
 catch (      InterruptedException exx) {
        Thread.currentThread().interrupt();
      }
      bi=tiff.readShort(0,y,rect.width,rect.height);
    }
    preloadedData=bi;
  }
 catch (  Exception ex) {
    logger.error(ex.getMessage(),ex);
  }
 finally {
  }
}

Fixed version (ground truth):
@Override public void preloadLineTile(int y,int length,int band){
  if (y < 0) {
    return;
  }
  CeosBinaryReader tiff=(CeosBinaryReader)getImage(band);
  preloadedInterval=new int[]{y,y + length};
  Rectangle rect=new Rectangle(0,y,tiff.getxSize(),length);
  rect=tiff.getBounds().intersection(rect);
  try {
    int[] bi=null;
    try {
      bi=tiff.readInt(0,y,rect.width,rect.height);
    }
 catch (    Exception e) {
      logger.warn("String_Node_Str" + 0 + "String_Node_Str"+ y+ "String_Node_Str");
      try {
        Thread.sleep(100);
      }
 catch (      InterruptedException exx) {
        Thread.currentThread().interrupt();
      }
      bi=tiff.readInt(0,y,rect.width,rect.height);
    }
    preloadedData=ArrayUtils.toObject(bi);
  }
 catch (  Exception ex) {
    logger.error(ex.getMessage(),ex);
  }
 finally {
  }
}
Program: 175034
Project: 175034
Buggy source:
@Override public int readPixel(int x,int y,int band){
  Rectangle rect=new Rectangle(x,y,1,1);
  rect=rect.intersection(getImage(band).getBounds());
  short data[]=null;
  CeosBinaryReader img=(CeosBinaryReader)getImage(band);
  try {
    data=img.readShort(x,y,1,1);
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
  return data[0];
}

Fixed version (ground truth):
@Override public long readPixel(int x,int y,int band){
  Rectangle rect=new Rectangle(x,y,1,1);
  rect=rect.intersection(getImage(band).getBounds());
  short data[]=null;
  CeosBinaryReader img=(CeosBinaryReader)getImage(band);
  try {
    data=img.readShort(x,y,1,1);
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
  return data[0];
}
Program: 175035
Project: 175035
Buggy source:
public int readPixel(int x,int y,int band){
  if (x < 0 || y < 0 || x > xSize || y > ySize) {
    return -1;
  }
  stride[1]=1;
  stride[0]=1;
  dims[1]=1;
  dims[0]=1;
  starts[1]=x;
  starts[0]=y;
  try {
    Object o2=imagedata.read();
    return Array.getInt(o2,0) & 0xFFFF;
  }
 catch (  Exception ex) {
    logger.error(null,ex);
    return 0;
  }
}

Fixed version (ground truth):
public long readPixel(int x,int y,int band){
  if (x < 0 || y < 0 || x > xSize || y > ySize) {
    return -1;
  }
  stride[1]=1;
  stride[0]=1;
  dims[1]=1;
  dims[0]=1;
  starts[1]=x;
  starts[0]=y;
  try {
    Object o2=imagedata.read();
    return Array.getInt(o2,0) & 0xFFFF;
  }
 catch (  Exception ex) {
    logger.error(null,ex);
    return 0;
  }
}
Program: 175036
Project: 175036
Buggy source:
@Override public int readPixel(int x,int y,int band){
  int result=0;
  long temp=0;
  byte[] pixelByte=new byte[2];
  if (x >= 0 & y >= 0 & x < xSize & y < ySize) {
    try {
      temp=(y * (xOffset + xSize * 2) + xOffset + x * 2);
      fss.seek(temp + offsetBand);
      fss.read(pixelByte,0,2);
      int interm1=pixelByte[0];
      int interm2=pixelByte[1];
      result=((interm1) << 8 | interm2 & 0xff);
    }
 catch (    IOException e) {
      logger.error("String_Node_Str" + x + "String_Node_Str"+ y+ "String_Node_Str",e);
    }
  }
  return result;
}

Fixed version (ground truth):
@Override public long readPixel(int x,int y,int band){
  int result=0;
  long temp=0;
  byte[] pixelByte=new byte[2];
  if (x >= 0 & y >= 0 & x < xSize & y < ySize) {
    try {
      temp=(y * (xOffset + xSize * 2) + xOffset + x * 2);
      fss.seek(temp + offsetBand);
      fss.read(pixelByte,0,2);
      int interm1=pixelByte[0];
      int interm2=pixelByte[1];
      result=((interm1) << 8 | interm2 & 0xff);
    }
 catch (    IOException e) {
      logger.error("String_Node_Str" + x + "String_Node_Str"+ y+ "String_Node_Str",e);
    }
  }
  return result;
}
Program: 175037
Project: 175037
Buggy source:
@Override public int readPixel(int x,int y,int band){
  int result=0;
  long temp=0;
  byte[] pixelByte=new byte[4];
  if (x >= 0 & y >= 0 & x < xSize & y < ySize) {
    try {
      temp=(y * (xOffset + xSize * 4) + xOffset + x * 4);
      fss.seek(temp + offsetBand);
      fss.read(pixelByte,0,4);
      byte interm0=pixelByte[0];
      byte interm1=pixelByte[1];
      byte interm2=pixelByte[2];
      byte interm3=pixelByte[3];
      long real=((interm0) << 8) | (interm1 & 0xFF);
      long img=((interm2) << 8) | (interm3 & 0xFF);
      result=(int)Math.sqrt(real * real + img * img);
    }
 catch (    IOException e) {
      logger.error("String_Node_Str" + x + "String_Node_Str"+ y+ "String_Node_Str",e);
    }
  }
  return result;
}

Fixed version (ground truth):
@Override public long readPixel(int x,int y,int band){
  int result=0;
  long temp=0;
  byte[] pixelByte=new byte[4];
  if (x >= 0 & y >= 0 & x < xSize & y < ySize) {
    try {
      temp=(y * (xOffset + xSize * 4) + xOffset + x * 4);
      fss.seek(temp + offsetBand);
      fss.read(pixelByte,0,4);
      byte interm0=pixelByte[0];
      byte interm1=pixelByte[1];
      byte interm2=pixelByte[2];
      byte interm3=pixelByte[3];
      long real=((interm0) << 8) | (interm1 & 0xFF);
      long img=((interm2) << 8) | (interm3 & 0xFF);
      result=(int)Math.sqrt(real * real + img * img);
    }
 catch (    IOException e) {
      logger.error("String_Node_Str" + x + "String_Node_Str"+ y+ "String_Node_Str",e);
    }
  }
  return result;
}
Program: 175038
Project: 175038
Buggy source:
@Override public int readPixel(int x,int y,int band){
  int result=0;
  long temp=0;
  byte[] pixelByte=new byte[2];
  if (x >= 0 & y >= 0 & x < xSize & y < ySize) {
    if (numberOfBytes == 2) {
      try {
        temp=(y * (xOffset + xSize * 2) + xOffset + x * 2);
        dat.seek(temp + offsetImage);
        dat.read(pixelByte,0,2);
        int interm1=pixelByte[0];
        int interm2=pixelByte[1];
        result=((interm1 & 0xff) << 8 | interm2 & 0xff);
      }
 catch (      IOException e) {
        logger.error("String_Node_Str" + x + "String_Node_Str"+ y+ "String_Node_Str",e);
      }
    }
 else {
      try {
        temp=(y * (xOffset + xSize) + xOffset + x);
        dat.seek(temp + offsetImage);
        dat.read(pixelByte,0,1);
        result=pixelByte[0];
      }
 catch (      IOException e) {
        logger.error("String_Node_Str" + x + "String_Node_Str"+ y+ "String_Node_Str",e);
      }
    }
  }
  return result;
}

Fixed version (ground truth):
@Override public long readPixel(int x,int y,int band){
  int result=0;
  long temp=0;
  byte[] pixelByte=new byte[2];
  if (x >= 0 & y >= 0 & x < xSize & y < ySize) {
    if (numberOfBytes == 2) {
      try {
        temp=(y * (xOffset + xSize * 2) + xOffset + x * 2);
        dat.seek(temp + offsetImage);
        dat.read(pixelByte,0,2);
        int interm1=pixelByte[0];
        int interm2=pixelByte[1];
        result=((interm1 & 0xff) << 8 | interm2 & 0xff);
      }
 catch (      IOException e) {
        logger.error("String_Node_Str" + x + "String_Node_Str"+ y+ "String_Node_Str",e);
      }
    }
 else {
      try {
        temp=(y * (xOffset + xSize) + xOffset + x);
        dat.seek(temp + offsetImage);
        dat.read(pixelByte,0,1);
        result=pixelByte[0];
      }
 catch (      IOException e) {
        logger.error("String_Node_Str" + x + "String_Node_Str"+ y+ "String_Node_Str",e);
      }
    }
  }
  return result;
}
Program: 175039
Project: 175039
Buggy source:
@Override public int readPixel(int x,int y,int band){
  TIFFImageReadParam t=new TIFFImageReadParam();
  t.setSourceRegion(new Rectangle(x,y,1,1));
  TIFF tiff=getImage(band);
  try {
    return tiff.read(0,t).getRGB(x,y);
  }
 catch (  IOException ex) {
    logger.error(ex.getMessage(),ex);
  }
  return -1;
}

Fixed version (ground truth):
@Override public long readPixel(int x,int y,int band){
  TIFFImageReadParam t=new TIFFImageReadParam();
  t.setSourceRegion(new Rectangle(x,y,1,1));
  TIFF tiff=getImage(band);
  try {
    return tiff.read(0,t).getRGB(x,y);
  }
 catch (  IOException ex) {
    logger.error(ex.getMessage(),ex);
  }
  return -1;
}
Program: 175040
Project: 175040
Buggy source:
@Override public int readPixel(int x,int y,int band){
  TIFFImageReadParam t=new TIFFImageReadParam();
  Rectangle rect=new Rectangle(x,y,1,1);
  rect=rect.intersection(bounds);
  t.setSourceRegion(rect);
  TIFF tiff=getImage(band);
  try {
    int img=tiff.read(0,t).getRaster().getSample(0,0,1);
    int real=tiff.read(0,t).getRaster().getSample(0,0,0);
    return (int)Math.sqrt(real * real + img * img);
  }
 catch (  IOException ex) {
    logger.error(ex.getMessage(),ex);
  }
catch (  ArrayIndexOutOfBoundsException ex) {
    logger.warn(ex.getMessage());
    ex.printStackTrace();
  }
catch (  IllegalArgumentException iae) {
    logger.warn(iae.getMessage());
  }
 finally {
  }
  return -1;
}

Fixed version (ground truth):
@Override public long readPixel(int x,int y,int band){
  TIFFImageReadParam t=new TIFFImageReadParam();
  Rectangle rect=new Rectangle(x,y,1,1);
  rect=rect.intersection(bounds);
  t.setSourceRegion(rect);
  TIFF tiff=getImage(band);
  try {
    int img=tiff.read(0,t).getRaster().getSample(0,0,1);
    int real=tiff.read(0,t).getRaster().getSample(0,0,0);
    return (int)Math.sqrt(real * real + img * img);
  }
 catch (  IOException ex) {
    logger.error(ex.getMessage(),ex);
  }
catch (  ArrayIndexOutOfBoundsException ex) {
    logger.warn(ex.getMessage());
    ex.printStackTrace();
  }
catch (  IllegalArgumentException iae) {
    logger.warn(iae.getMessage());
  }
 finally {
  }
  return -1;
}
Program: 175041
Project: 175041
Buggy source:
public MaskGeometries(String maskName,List<Geometry> maskGeometries,String fileName){
  this.maskName=maskName;
  this.maskGeometries=maskGeometries;
  intersectedMapCache=new HashMap<String,Boolean>();
  includesMapCache=new HashMap<String,Boolean>();
  this.fileName=fileName;
}

Fixed version (ground truth):
public MaskGeometries(String maskName,List<Geometry> maskGeometries,String fileName){
  this.maskName=maskName;
  this.maskGeometries=maskGeometries;
  intersectedMapCache=new HashMap<String,Boolean>();
  includesMapCache=new HashMap<String,Boolean>();
  this.fileName=fileName;
  splitMultiPolygons();
}
Program: 175042
Project: 175042
Buggy source:
/** 
 * rasterize the mask clipped with the Rectangle scaled back to full size with an offset onto a BufferedImage
 */
public int[] getRasterDataMask(int x,int y,int w,int h,int offsetX,int offsetY,double scalingFactor){
  Rectangle rect=new Rectangle(x,y,w,h);
  BufferedImage bi=this.rasterize(rect,offsetX,offsetY,scalingFactor);
  Raster rastermask=bi.getData();
  int[] maskdata=rastermask.getPixels(0,0,rastermask.getWidth(),rastermask.getHeight(),(int[])null);
  return maskdata;
}

Fixed version (ground truth):
/** 
 * rasterize the mask clipped with the Rectangle scaled back to full size with an offset onto a BufferedImage
 */
public int[] getRasterDataMask(int x,int y,int w,int h,int offsetX,int offsetY,double scalingFactor){
  Rectangle rect=new Rectangle(x,y,w,h);
  BufferedImage bi=this.rasterize(rect,offsetX,offsetY,scalingFactor);
  Raster rastermask=bi.getData();
  int[] maskdata=rastermask.getSamples(0,0,rastermask.getWidth(),rastermask.getHeight(),0,(int[])null);
  return maskdata;
}
Program: 175043
Project: 175043
Buggy source:
/** 
 * rasterize the mask clipped with the Rectangle scaled back to full size with an offset onto a BufferedImage
 */
public BufferedImage rasterize(Rectangle rect,int offsetX,int offsetY,double scalingFactor){
  BufferedImage image=new BufferedImage(rect.width,rect.height,BufferedImage.TYPE_BYTE_BINARY);
  GeometryFactory gf=new GeometryFactory();
  Coordinate[] coords=new Coordinate[]{new Coordinate((int)(((double)rect.getMinX() / scalingFactor)),(int)(((double)rect.getMinY() / scalingFactor))),new Coordinate((int)(((double)rect.getMaxX() / scalingFactor)),(int)(((double)rect.getMinY() / scalingFactor))),new Coordinate((int)(((double)rect.getMaxX() / scalingFactor)),(int)(((double)rect.getMaxY() / scalingFactor))),new Coordinate((int)(((double)rect.getMinX() / scalingFactor)),(int)(((double)rect.getMaxY() / scalingFactor))),new Coordinate((int)(((double)rect.getMinX() / scalingFactor)),(int)(((double)rect.getMinY() / scalingFactor)))};
  Polygon geom=gf.createPolygon(gf.createLinearRing(coords));
  Graphics g2d=image.getGraphics();
  g2d.setColor(Color.WHITE);
  for (  Geometry p : maskGeometries) {
    if (p.intersects(geom)) {
      int[] xPoints=new int[p.getNumPoints()];
      int[] yPoints=new int[p.getNumPoints()];
      int i=0;
      for (      Coordinate c : p.getCoordinates()) {
        xPoints[i]=(int)((c.x + offsetX) * scalingFactor);
        yPoints[i]=(int)((c.y + offsetY) * scalingFactor);
        i++;
      }
      g2d.fillPolygon(xPoints,yPoints,p.getNumPoints());
    }
  }
  g2d.dispose();
  return image;
}

Fixed version (ground truth):
/** 
 * rasterize the mask clipped with the Rectangle scaled back to full size with an offset onto a BufferedImage
 */
public BufferedImage rasterize(Rectangle rect,int offsetX,int offsetY,double scalingFactor){
  BufferedImage image=new BufferedImage(rect.width,rect.height,BufferedImage.TYPE_BYTE_BINARY);
  GeometryFactory gf=new GeometryFactory();
  Coordinate[] coords=new Coordinate[]{new Coordinate((int)(((double)rect.getMinX() / scalingFactor)),(int)(((double)rect.getMinY() / scalingFactor))),new Coordinate((int)(((double)rect.getMaxX() / scalingFactor)),(int)(((double)rect.getMinY() / scalingFactor))),new Coordinate((int)(((double)rect.getMaxX() / scalingFactor)),(int)(((double)rect.getMaxY() / scalingFactor))),new Coordinate((int)(((double)rect.getMinX() / scalingFactor)),(int)(((double)rect.getMaxY() / scalingFactor))),new Coordinate((int)(((double)rect.getMinX() / scalingFactor)),(int)(((double)rect.getMinY() / scalingFactor)))};
  Polygon geom=gf.createPolygon(gf.createLinearRing(coords));
  Graphics g2d=image.getGraphics();
  g2d.setColor(Color.white);
  for (  Geometry p : maskGeometries) {
    if (p.intersects(geom)) {
      int[] xPoints=new int[p.getNumPoints()];
      int[] yPoints=new int[p.getNumPoints()];
      int i=0;
      for (      Coordinate c : p.getCoordinates()) {
        xPoints[i]=(int)((c.x + offsetX) * scalingFactor);
        yPoints[i]=(int)((c.y + offsetY) * scalingFactor);
        i++;
      }
      g2d.fillPolygon(xPoints,yPoints,i);
    }
  }
  g2d.dispose();
  return image;
}
Program: 175047
Project: 175047
Buggy source:
/** 
 * @param shpInput
 * @param bbox
 * @param transform
 * @return
 */
public static GeometryImage createIntersectedLayer(File shpInput,Polygon bbox,GeoTransform transform){
  GeometryImage glout=null;
  DataStore dataStore=null;
  try {
    if (shpInput != null) {
      Map<String,Serializable> params=new HashMap<String,Serializable>();
      params.put("String_Node_Str",shpInput.toURI().toURL());
      dataStore=DataStoreFinder.getDataStore(params);
      SimpleFeatureSource featureSource=(SimpleFeatureSource)dataStore.getFeatureSource(dataStore.getTypeNames()[0]);
      Polygon imageP=bbox;
      ClipProcess clip=new ClipProcess();
      SimpleFeatureCollection fc=clip.execute(featureSource.getFeatures(),imageP,true);
      if (fc.isEmpty()) {
        return null;
      }
      String[] schemaStr=createSchema(fc.getSchema().getDescriptors());
      String[] types=createTypes(fc.getSchema().getDescriptors());
      String geoName=fc.getSchema().getGeometryDescriptor().getType().getName().toString();
      boolean applayT=false;
      if (transform != null)       applayT=true;
      glout=GeometryImage.createFromSimpleGeometry(imageP,geoName,fc,schemaStr,types,applayT,transform);
      glout.setName(shpInput.getName());
    }
  }
 catch (  Exception ex) {
    logger.error(ex.getMessage(),ex);
  }
 finally {
    if (dataStore != null)     dataStore.dispose();
  }
  return glout;
}

Fixed version (ground truth):
/** 
 * @param shpInput
 * @param bbox
 * @param transform
 * @return
 */
public static GeometryImage createIntersectedLayer(File shpInput,Polygon bbox,GeoTransform transform){
  GeometryImage glout=null;
  DataStore dataStore=null;
  try {
    if (shpInput != null) {
      Map<String,Serializable> params=new HashMap<String,Serializable>();
      params.put("String_Node_Str",shpInput.toURI().toURL());
      dataStore=DataStoreFinder.getDataStore(params);
      SimpleFeatureSource featureSource=(SimpleFeatureSource)dataStore.getFeatureSource(dataStore.getTypeNames()[0]);
      Polygon imageP=bbox;
      ClipProcess clip=new ClipProcess();
      SimpleFeatureCollection fc=clip.execute(featureSource.getFeatures(),imageP,true);
      if (fc.isEmpty()) {
        return null;
      }
      String[] schemaStr=createSchema(fc.getSchema().getDescriptors());
      String[] types=createTypes(fc.getSchema().getDescriptors());
      String geoName=fc.getSchema().getGeometryDescriptor().getType().getName().toString();
      boolean applayT=false;
      if (transform != null)       applayT=true;
      glout=GeometryImage.createFromSimpleGeometry(imageP,geoName,fc,schemaStr,types,applayT,transform);
      glout.setName(shpInput.getName());
      glout.splitMultiPolygons();
    }
  }
 catch (  Exception ex) {
    logger.error(ex.getMessage(),ex);
  }
 finally {
    if (dataStore != null)     dataStore.dispose();
  }
  return glout;
}