nus-yam/ex-repair huggingface dataset:
Program: 33331
Project: 33331
Buggy source:
public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException {
  WikipediaApiInterface wikiAPI=SingletonWikipediaApi.getInstance();
  DBPediaApi dbpApi=new DBPediaApi();
  ExperimentTaskConfiguration taskConfigs[]=new ExperimentTaskConfiguration[]{new ExperimentTaskConfiguration(new SpotlightAnnotatorConfig(wikiAPI,dbpApi),new KnownNIFFileDatasetConfig(NIFDatasets.KORE50),ExperimentType.D2W,Matching.STRONG_ANNOTATION_MATCH)};
  Experimenter experimenter=new Experimenter(wikiAPI,new SimpleLoggingDAO4Debugging(),taskConfigs,"String_Node_Str");
  experimenter.run();
}

Fixed version (ground truth):
public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException {
  WikipediaApiInterface wikiAPI=SingletonWikipediaApi.getInstance();
  DBPediaApi dbpApi=new DBPediaApi();
  ExperimentTaskConfiguration taskConfigs[]=new ExperimentTaskConfiguration[]{new ExperimentTaskConfiguration(new SpotlightAnnotatorConfig(wikiAPI,dbpApi),new KnownNIFFileDatasetConfig(SingletonWikipediaApi.getInstance(),new DBPediaApi(),NIFDatasets.KORE50),ExperimentType.D2W,Matching.STRONG_ANNOTATION_MATCH)};
  Experimenter experimenter=new Experimenter(wikiAPI,new SimpleLoggingDAO4Debugging(),taskConfigs,"String_Node_Str");
  experimenter.run();
}
Program: 33332
Project: 33332
Buggy source:
private boolean couldHaveCachedResult(ExperimentTaskConfiguration config){
  return config.annotatorConfig.couldBeCached() && config.datasetConfig.couldBeCached();
}

Fixed version (ground truth):
private boolean couldHaveCachedResult(ExperimentTaskConfiguration config){
  LOGGER.error("String_Node_Str" + config.annotatorConfig.getAnnotatorName() + "String_Node_Str"+ config.annotatorConfig.couldBeCached()+ "String_Node_Str"+ config.datasetConfig.getDatasetName()+ "String_Node_Str"+ config.datasetConfig.couldBeCached()+ "String_Node_Str"+ (config.annotatorConfig.couldBeCached() && config.datasetConfig.couldBeCached()));
  return config.annotatorConfig.couldBeCached() && config.datasetConfig.couldBeCached();
}
Program: 33333
Project: 33333
Buggy source:
public NIFWebserviceAnnotatorConfiguration(String annotaturURL,String annotatorName,boolean couldBeCached,WikipediaApiInterface wikiApi,DBPediaApi dbpediaApi,ExperimentType... applicableForExperiment){
  super(annotatorName,false,applicableForExperiment);
  this.annotaturURL=annotaturURL;
  this.wikiApi=wikiApi;
  this.dbpediaApi=dbpediaApi;
}

Fixed version (ground truth):
public NIFWebserviceAnnotatorConfiguration(String annotaturURL,String annotatorName,boolean couldBeCached,WikipediaApiInterface wikiApi,DBPediaApi dbpediaApi,ExperimentType... applicableForExperiment){
  super(annotatorName,couldBeCached,applicableForExperiment);
  this.annotaturURL=annotaturURL;
  this.wikiApi=wikiApi;
  this.dbpediaApi=dbpediaApi;
}
Program: 33334
Project: 33334
Buggy source:
public static HashSet<it.acubelab.batframework.data.Annotation> createAnnotations(AnnotatedDocument document){
  List<Annotation> annotations=document.getAnnotations();
  HashSet<it.acubelab.batframework.data.Annotation> batAnnotations=new HashSet<it.acubelab.batframework.data.Annotation>();
  for (  Annotation annotation : annotations) {
    batAnnotations.add(translateAnnotation2BatAnnotation(annotation));
  }
  return null;
}

Fixed version (ground truth):
public static HashSet<it.acubelab.batframework.data.Annotation> createAnnotations(AnnotatedDocument document){
  List<Annotation> annotations=document.getAnnotations();
  HashSet<it.acubelab.batframework.data.Annotation> batAnnotations=new HashSet<it.acubelab.batframework.data.Annotation>();
  for (  Annotation annotation : annotations) {
    batAnnotations.add(translateAnnotation2BatAnnotation(annotation));
  }
  return batAnnotations;
}
Program: 33335
Project: 33335
Buggy source:
protected void correctAnnotationPositions(AnnotatedDocument resultDocument){
}

Fixed version (ground truth):
/** 
 * The positions in NIF are measured in codepoints, while Java counts in terms of characters. So we have to correct the positions of the annotations.
 * @param resultDocument
 */
protected void correctAnnotationPositions(AnnotatedDocument resultDocument){
  List<Annotation> annotations=resultDocument.getAnnotations();
  Collections.sort(annotations,new StartPosBasedComparator());
  List<Annotation> annotationsSortedByEnd=new ArrayList<Annotation>(annotations);
  Collections.sort(annotationsSortedByEnd,new EndPosBasedComparator());
  int startPositions[]=new int[annotations.size()];
  int endPositions[]=new int[annotations.size()];
  Annotation currentAnnotation;
  for (int i=0; i < annotations.size(); ++i) {
    startPositions[i]=annotations.get(i).getStartPosition();
    currentAnnotation=annotationsSortedByEnd.get(i);
    endPositions[i]=currentAnnotation.getStartPosition() + currentAnnotation.getLength();
  }
  String text=resultDocument.getText();
  int codePointsCount=0;
  int posInStart=0, posInEnd=0;
  for (int i=0; i < text.length(); ++i) {
    codePointsCount+=text.codePointCount(i,i + 1);
    while ((posInStart < startPositions.length) && (codePointsCount > startPositions[posInStart])) {
      annotations.get(posInStart).setStartPosition(i);
      ++posInStart;
    }
    while ((posInEnd < endPositions.length) && (codePointsCount > endPositions[posInEnd])) {
      currentAnnotation=annotationsSortedByEnd.get(posInEnd);
      currentAnnotation.setLength(i - currentAnnotation.getStartPosition());
      ++posInEnd;
    }
  }
}
Program: 33336
Project: 33336
Buggy source:
@Parameters public static List<Object[]> data(){
  return Arrays.asList(new Object[][]{{new AnnotatedDocumentImpl("String_Node_Str","String_Node_Str",Arrays.asList((Annotation)new AnnotationImpl(13,8)))},{new AnnotatedDocumentImpl("String_Node_Str","String_Node_Str",Arrays.asList((Annotation)new AnnotationImpl(0,4)))},{new AnnotatedDocumentImpl("String_Node_Str","String_Node_Str",Arrays.asList(((Annotation)new AnnotationImpl(0,4)),(Annotation)new AnnotationImpl(13,8)))},{new AnnotatedDocumentImpl("String_Node_Str","String_Node_Str",Arrays.asList((Annotation)new DisambiguatedAnnotation(13,8,"String_Node_Str")))},{new AnnotatedDocumentImpl("String_Node_Str","String_Node_Str",Arrays.asList((Annotation)new ScoredDisambigAnnotation(13,8,"String_Node_Str",0.87)))}});
}

Fixed version (ground truth):
@Parameters public static List<Object[]> data(){
  return Arrays.asList(new Object[][]{{new AnnotatedDocumentImpl("String_Node_Str","String_Node_Str",Arrays.asList((Annotation)new AnnotationImpl(13,8)))},{new AnnotatedDocumentImpl("String_Node_Str","String_Node_Str",Arrays.asList((Annotation)new AnnotationImpl(0,4)))},{new AnnotatedDocumentImpl("String_Node_Str","String_Node_Str",Arrays.asList(((Annotation)new AnnotationImpl(0,4)),(Annotation)new AnnotationImpl(13,8)))},{new AnnotatedDocumentImpl("String_Node_Str","String_Node_Str",Arrays.asList((Annotation)new DisambiguatedAnnotation(13,8,"String_Node_Str")))},{new AnnotatedDocumentImpl("String_Node_Str","String_Node_Str",Arrays.asList((Annotation)new ScoredDisambigAnnotation(13,8,"String_Node_Str",0.87)))},{new AnnotatedDocumentImpl("String_Node_Str","String_Node_Str",Arrays.asList((Annotation)new AnnotationImpl(3,4),(Annotation)new ScoredDisambigAnnotation(19,8,"String_Node_Str",0.87)))}});
}
Program: 33338
Project: 33338
Buggy source:
protected int outputRunLen(byte[] input,int offset,int runLen,int stride,int color,int len){
  for (int i=0; i < runLen; i++) {
    if (empty_bits >= 1) {
      input[offset]|=(color << (empty_bits - 1));
      empty_bits--;
    }
    if (++lineOffset % stride == 0 || empty_bits == 0) {
      offset++;
      uncompressedBytes++;
      empty_bits=8;
      if (uncompressedBytes >= len)       break;
    }
  }
  return offset;
}

Fixed version (ground truth):
protected int outputRunLen(byte[] input,int offset,int runLen,int stride,int color,int len){
  for (int i=0; i < runLen; i++) {
    if (uncompressedBytes >= len)     break;
    if (empty_bits >= 1) {
      input[offset]|=(color << (empty_bits - 1));
      empty_bits--;
    }
    if (++lineOffset % stride == 0 || empty_bits == 0) {
      offset++;
      uncompressedBytes++;
      empty_bits=8;
    }
  }
  return offset;
}
Program: 33340
Project: 33340
Buggy source:
public ThumbnailResource(ImageResourceID id,int dataType,int width,int height,int paddedRowBytes,int totalSize,int compressedSize,int bitsPerPixel,int numOfPlanes,byte[] data){
  super(id,"String_Node_Str",data);
  if (id != ImageResourceID.THUMBNAIL_RESOURCE_PS4 && id != ImageResourceID.THUMBNAIL_RESOURCE_PS5)   throw new IllegalArgumentException("String_Node_Str" + id);
  this.id=id;
  this.width=width;
  this.height=height;
  this.paddedRowBytes=paddedRowBytes;
  this.totalSize=totalSize;
  this.compressedSize=compressedSize;
  this.bitsPerPixel=bitsPerPixel;
  this.numOfPlanes=numOfPlanes;
  this.dataType=dataType;
  if (dataType == Thumbnail.DATA_TYPE_KJpegRGB) {
    thumbnail.setImage(width,height,dataType,data);
  }
 else   if (dataType == Thumbnail.DATA_TYPE_KRawRGB) {
    DataBuffer db=new DataBufferByte(data,totalSize);
    int[] off={0,1,2};
    if (id == ImageResourceID.THUMBNAIL_RESOURCE_PS4)     off=new int[]{2,1,0};
    int numOfBands=3;
    int trans=Transparency.OPAQUE;
    WritableRaster raster=Raster.createInterleavedRaster(db,width,height,paddedRowBytes,numOfBands,off,null);
    ColorModel cm=new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),false,false,trans,DataBuffer.TYPE_BYTE);
    thumbnail.setImage(new BufferedImage(cm,raster,false,null));
  }
 else   throw new UnsupportedOperationException("String_Node_Str" + dataType);
}

Fixed version (ground truth):
public ThumbnailResource(ImageResourceID id,int dataType,int width,int height,int paddedRowBytes,int totalSize,int compressedSize,int bitsPerPixel,int numOfPlanes,byte[] data){
  super(id,"String_Node_Str",null);
  if (id != ImageResourceID.THUMBNAIL_RESOURCE_PS4 && id != ImageResourceID.THUMBNAIL_RESOURCE_PS5)   throw new IllegalArgumentException("String_Node_Str" + id);
  this.id=id;
  this.width=(width > 0) ? width : 0;
  this.height=(height > 0) ? height : 0;
  this.paddedRowBytes=paddedRowBytes;
  this.totalSize=totalSize;
  this.compressedSize=compressedSize;
  this.bitsPerPixel=bitsPerPixel;
  this.numOfPlanes=numOfPlanes;
  this.dataType=dataType;
  if (dataType == Thumbnail.DATA_TYPE_KJpegRGB) {
    thumbnail.setImage(width,height,dataType,data);
  }
 else   if (dataType == Thumbnail.DATA_TYPE_KRawRGB) {
    DataBuffer db=new DataBufferByte(data,totalSize);
    int[] off={0,1,2};
    if (id == ImageResourceID.THUMBNAIL_RESOURCE_PS4)     off=new int[]{2,1,0};
    int numOfBands=3;
    int trans=Transparency.OPAQUE;
    WritableRaster raster=Raster.createInterleavedRaster(db,width,height,paddedRowBytes,numOfBands,off,null);
    ColorModel cm=new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),false,false,trans,DataBuffer.TYPE_BYTE);
    thumbnail.setImage(new BufferedImage(cm,raster,false,null));
  }
 else   throw new UnsupportedOperationException("String_Node_Str" + dataType);
}
Program: 33341
Project: 33341
Buggy source:
private static final <T extends Comparable<? super T>>void swap(T[] array,int a,int b){
  T temp=array[a];
  array[a]=array[b];
  array[b]=temp;
}

Fixed version (ground truth):
private static final <T>void swap(T[] array,int a,int b){
  T temp=array[a];
  array[a]=array[b];
  array[b]=temp;
}
Program: 33342
Project: 33342
Buggy source:
public ExifThumbnail getThumbnail(){
  if (thumbnail != null)   return thumbnail;
  if (reader != null && !reader.isDataLoaded()) {
    try {
      reader.read();
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
    return reader.getThumbnail();
  }
  return null;
}

Fixed version (ground truth):
public ExifThumbnail getThumbnail(){
  if (thumbnail != null)   return thumbnail;
  if (reader != null) {
    if (!reader.isDataLoaded()) {
      try {
        reader.read();
      }
 catch (      IOException e) {
        e.printStackTrace();
      }
    }
    return reader.getThumbnail();
  }
  return null;
}
Program: 33343
Project: 33343
Buggy source:
public IFD getGPSIFD(){
  if (gpsSubIFD != null) {
    return gpsSubIFD;
  }
 else {
    if (reader != null && !reader.isDataLoaded()) {
      try {
        reader.read();
      }
 catch (      IOException e) {
        e.printStackTrace();
      }
      gpsSubIFD=reader.getImageIFD();
    }
    return gpsSubIFD;
  }
}

Fixed version (ground truth):
public IFD getGPSIFD(){
  if (gpsSubIFD != null) {
    return gpsSubIFD;
  }
 else {
    if (reader != null) {
      if (!reader.isDataLoaded()) {
        try {
          reader.read();
        }
 catch (        IOException e) {
          e.printStackTrace();
        }
      }
      gpsSubIFD=reader.getGPSIFD();
    }
    return gpsSubIFD;
  }
}
Program: 33344
Project: 33344
Buggy source:
public IFD getExifIFD(){
  if (exifSubIFD != null) {
    return exifSubIFD;
  }
 else {
    if (reader != null && !reader.isDataLoaded()) {
      try {
        reader.read();
      }
 catch (      IOException e) {
        e.printStackTrace();
      }
      exifSubIFD=reader.getImageIFD();
    }
    return exifSubIFD;
  }
}

Fixed version (ground truth):
public IFD getExifIFD(){
  if (exifSubIFD != null) {
    return exifSubIFD;
  }
 else {
    if (reader != null) {
      if (!reader.isDataLoaded()) {
        try {
          reader.read();
        }
 catch (        IOException e) {
          e.printStackTrace();
        }
      }
      exifSubIFD=reader.getExifIFD();
    }
    return exifSubIFD;
  }
}
Program: 33345
Project: 33345
Buggy source:
public IFD getImageIFD(){
  if (imageIFD != null) {
    return imageIFD;
  }
 else {
    if (reader != null && !reader.isDataLoaded()) {
      try {
        reader.read();
      }
 catch (      IOException e) {
        e.printStackTrace();
      }
      imageIFD=reader.getImageIFD();
    }
    return imageIFD;
  }
}

Fixed version (ground truth):
public IFD getImageIFD(){
  if (imageIFD != null) {
    return imageIFD;
  }
 else {
    if (reader != null) {
      if (!reader.isDataLoaded()) {
        try {
          reader.read();
        }
 catch (        IOException e) {
          e.printStackTrace();
        }
      }
      imageIFD=reader.getImageIFD();
    }
    return imageIFD;
  }
}
Program: 33346
Project: 33346
Buggy source:
public void print(){
  ImageResourceID eId=ImageResourceID.fromShort(id);
  if ((id >= ImageResourceID.PATH_INFO0.getValue()) && (id <= ImageResourceID.PATH_INFO998.getValue())) {
    System.out.println("String_Node_Str" + "String_Node_Str" + StringUtils.shortToHexStringMM(id) + "String_Node_Str"+ "String_Node_Str");
  }
 else   if ((id >= ImageResourceID.PLUGIN_RESOURCE0.getValue()) && (id <= ImageResourceID.PLUGIN_RESOURCE999.getValue())) {
    System.out.println("String_Node_Str" + "String_Node_Str" + StringUtils.shortToHexStringMM(id) + "String_Node_Str"+ "String_Node_Str");
  }
 else   if (eId == ImageResourceID.UNKNOWN) {
    System.out.println(eId + "String_Node_Str" + StringUtils.shortToHexStringMM(id)+ "String_Node_Str");
  }
 else {
    System.out.println(eId);
  }
  System.out.println("String_Node_Str");
  System.out.println("String_Node_Str" + name);
  System.out.println("String_Node_Str" + size);
  eId.show(getData());
}

Fixed version (ground truth):
public void print(){
  ImageResourceID eId=ImageResourceID.fromShort(id);
  if ((id >= ImageResourceID.PATH_INFO0.getValue()) && (id <= ImageResourceID.PATH_INFO998.getValue())) {
    System.out.println("String_Node_Str" + "String_Node_Str" + StringUtils.shortToHexStringMM(id) + "String_Node_Str"+ "String_Node_Str");
  }
 else   if ((id >= ImageResourceID.PLUGIN_RESOURCE0.getValue()) && (id <= ImageResourceID.PLUGIN_RESOURCE999.getValue())) {
    System.out.println("String_Node_Str" + "String_Node_Str" + StringUtils.shortToHexStringMM(id) + "String_Node_Str"+ "String_Node_Str");
  }
 else   if (eId == ImageResourceID.UNKNOWN) {
    System.out.println(eId + "String_Node_Str" + StringUtils.shortToHexStringMM(id)+ "String_Node_Str");
  }
 else {
    System.out.println(eId);
  }
  System.out.println("String_Node_Str");
  System.out.println("String_Node_Str" + name);
  System.out.println("String_Node_Str" + size);
}
Program: 33347
Project: 33347
Buggy source:
/** 
 * Get a string representation of the IPTCDataSet associated with the key
 * @param key the name for the IPTCDataSet
 * @return a String representation of the IPTCDataSet, separated by ";"
 */
public String getAsString(String key){
  List<IPTCDataSet> list=getDataSet(key);
  String value="String_Node_Str";
  if (list != null) {
    if (list.size() == 0) {
      value=list.get(0).getDataAsString();
    }
 else {
      for (int i=0; i < list.size() - 1; i++)       value+=list.get(i).getDataAsString() + "String_Node_Str";
      value+=list.get(list.size() - 1).getDataAsString();
    }
  }
  return value;
}

Fixed version (ground truth):
/** 
 * Get a string representation of the IPTCDataSet associated with the key
 * @param key the name for the IPTCDataSet
 * @return a String representation of the IPTCDataSet, separated by ";"
 */
public String getAsString(String key){
  List<IPTCDataSet> list=getDataSet(key);
  String value="String_Node_Str";
  if (list != null) {
    if (list.size() == 1) {
      value=list.get(0).getDataAsString();
    }
 else {
      for (int i=0; i < list.size() - 1; i++)       value+=list.get(i).getDataAsString() + "String_Node_Str";
      value+=list.get(list.size() - 1).getDataAsString();
    }
  }
  return value;
}
Program: 33350
Project: 33350
Buggy source:
public void write(OutputStream os) throws IOException {
  os.write("String_Node_Str".getBytes());
  IOUtils.writeShortMM(os,id);
  if (name.trim().length() == 0)   IOUtils.writeShortMM(os,0);
 else   os.write(name.trim().getBytes());
  if (name.trim().length() % 2 != 0)   os.write(0);
  IOUtils.writeIntMM(os,size);
  os.write(data);
  if (size % 2 != 0)   os.write(0);
}

Fixed version (ground truth):
public void write(OutputStream os) throws IOException {
  os.write("String_Node_Str".getBytes());
  IOUtils.writeShortMM(os,id);
  byte[] temp=name.trim().getBytes();
  os.write(temp.length);
  os.write(temp);
  if (temp.length % 2 == 0)   os.write(0);
  IOUtils.writeIntMM(os,size);
  os.write(data);
  if (data.length % 2 != 0)   os.write(0);
}
Program: 33351
Project: 33351
Buggy source:
public ICCPBuilder name(String name){
  this.profileName=name.trim() + '\0';
  return this;
}

Fixed version (ground truth):
public ICCPBuilder name(String name){
  this.profileName=name.trim().replaceAll("String_Node_Str","String_Node_Str");
  return this;
}
Program: 33352
Project: 33352
Buggy source:
@Override protected byte[] buildData(){
  byte[] nameBytes=null;
  try {
    nameBytes=profileName.getBytes("String_Node_Str");
  }
 catch (  UnsupportedEncodingException e) {
    e.printStackTrace();
  }
  return ArrayUtils.concat(nameBytes,profileData);
}

Fixed version (ground truth):
@Override protected byte[] buildData(){
  StringBuilder sb=new StringBuilder(this.profileName);
  sb.append('\0');
  sb.append('\0');
  ByteArrayOutputStream bo=new ByteArrayOutputStream(1024);
  try {
    bo.write(sb.toString().getBytes("String_Node_Str"));
    DeflaterOutputStream ds=new DeflaterOutputStream(bo);
    BufferedOutputStream bout=new BufferedOutputStream(ds);
    bout.write(profileData);
    bout.flush();
    bout.close();
  }
 catch (  Exception ex) {
    ex.printStackTrace();
  }
  return bo.toByteArray();
}
Program: 33356
Project: 33356
Buggy source:
/** 
 * RGB to GrayScale image conversion with Floyd-Steinberg dither
 * @param rgb input RGB image array (format: ARGBARGBARGB...)
 * @param imageWidth image width
 * @param imageHeight image height
 * @param err_limit Floyd-Steinberg error diffusion error limit (range 0-255 inclusive)
 * @return byte array for the BW image
 */
public static byte[] rgb2bilevelDither(int[] rgb,int imageWidth,int imageHeight,int err_limit){
  byte[] pixels=new byte[rgb.length];
  int sum=0;
  for (int i=0; i < rgb.length; i++) {
    if ((rgb[i] >>> 24) < 0x80)     pixels[i]=(byte)0xff;
 else     pixels[i]=(byte)(((rgb[i] >> 16) & 0xff) * 0.2126 + ((rgb[i] >> 8) & 0xff) * 0.7152 + (rgb[i] & 0xff) * 0.0722);
    sum+=(pixels[i] & 0xff);
  }
  int threshold=(sum / pixels.length);
  IMGUtils.dither_FloydSteinberg(pixels,imageWidth,imageHeight,threshold,err_limit);
  return pixels;
}

Fixed version (ground truth):
/** 
 * RGB to GrayScale image conversion with Floyd-Steinberg dither
 * @param rgb input RGB image array (format: ARGBARGBARGB...)
 * @param imageWidth image width
 * @param imageHeight image height
 * @param err_limit Floyd-Steinberg error diffusion error limit (range 0-255 inclusive)
 * @return byte array for the BW image
 */
public static byte[] rgb2bilevelDither(int[] rgb,int imageWidth,int imageHeight,int err_limit){
  byte[] pixels=new byte[rgb.length];
  byte[] mask=new byte[rgb.length];
  int sum=0;
  Arrays.fill(mask,(byte)0x01);
  for (int i=0; i < rgb.length; i++) {
    if ((rgb[i] >>> 24) < 0x80) {
      pixels[i]=(byte)0xff;
      mask[i]=0x00;
    }
 else     pixels[i]=(byte)(((rgb[i] >> 16) & 0xff) * 0.2126 + ((rgb[i] >> 8) & 0xff) * 0.7152 + (rgb[i] & 0xff) * 0.0722);
    sum+=(pixels[i] & 0xff);
  }
  int threshold=(sum / pixels.length);
  IMGUtils.dither_FloydSteinberg(pixels,mask,imageWidth,imageHeight,threshold,err_limit);
  return pixels;
}
Program: 33359
Project: 33359
Buggy source:
/** 
 * RGB to GrayScale image conversion with Floyd-Steinberg dither
 * @param rgb input RGB image array (format: ARGBARGBARGB...)
 * @param imageWidth image width
 * @param imageHeight image height
 * @param err_limit Floyd-Steinberg error diffusion error limit (range 0-255 inclusive)
 * @return byte array for the BW image
 */
public static byte[] rgb2bilevelDither(int[] rgb,int imageWidth,int imageHeight,int err_limit){
  byte[] pixels=new byte[rgb.length];
  int sum=0;
  for (int i=0; i < rgb.length; i++) {
    pixels[i]=(byte)(((rgb[i] >> 16) & 0xff) * 0.2126 + ((rgb[i] >> 8) & 0xff) * 0.7152 + (rgb[i] & 0xff) * 0.0722);
    sum+=(pixels[i] & 0xff);
  }
  int threshold=(sum / pixels.length);
  IMGUtils.dither_FloydSteinberg(pixels,imageWidth,imageHeight,threshold,err_limit);
  return pixels;
}

Fixed version (ground truth):
/** 
 * RGB to GrayScale image conversion with Floyd-Steinberg dither
 * @param rgb input RGB image array (format: ARGBARGBARGB...)
 * @param imageWidth image width
 * @param imageHeight image height
 * @param err_limit Floyd-Steinberg error diffusion error limit (range 0-255 inclusive)
 * @return byte array for the BW image
 */
public static byte[] rgb2bilevelDither(int[] rgb,int imageWidth,int imageHeight,int err_limit){
  byte[] pixels=new byte[rgb.length];
  int sum=0;
  for (int i=0; i < rgb.length; i++) {
    if ((rgb[i] >>> 24) < 0x80)     pixels[i]=(byte)0xff;
 else     pixels[i]=(byte)(((rgb[i] >> 16) & 0xff) * 0.2126 + ((rgb[i] >> 8) & 0xff) * 0.7152 + (rgb[i] & 0xff) * 0.0722);
    sum+=(pixels[i] & 0xff);
  }
  int threshold=(sum / pixels.length);
  IMGUtils.dither_FloydSteinberg(pixels,imageWidth,imageHeight,threshold,err_limit);
  return pixels;
}
Program: 33360
Project: 33360
Buggy source:
public static byte[] rgb2bilevel(int[] rgb){
  byte[] pixels=new byte[rgb.length];
  int sum=0;
  for (int i=0; i < rgb.length; i++) {
    pixels[i]=(byte)(((rgb[i] >> 16) & 0xff) * 0.2126 + ((rgb[i] >> 8) & 0xff) * 0.7152 + (rgb[i] & 0xff) * 0.0722);
    sum+=(pixels[i] & 0xff);
  }
  int threshold=(sum / pixels.length);
  for (int l=0; l < pixels.length; l++) {
    if ((pixels[l] & 0xff) <= threshold) {
      pixels[l]=1;
    }
 else {
      pixels[l]=0;
    }
  }
  return pixels;
}

Fixed version (ground truth):
public static byte[] rgb2bilevel(int[] rgb){
  byte[] pixels=new byte[rgb.length];
  int sum=0;
  for (int i=0; i < rgb.length; i++) {
    if ((rgb[i] >>> 24) < 0x80)     pixels[i]=(byte)0xff;
 else     pixels[i]=(byte)(((rgb[i] >> 16) & 0xff) * 0.2126 + ((rgb[i] >> 8) & 0xff) * 0.7152 + (rgb[i] & 0xff) * 0.0722);
    sum+=(pixels[i] & 0xff);
  }
  int threshold=(sum / pixels.length);
  for (int l=0; l < pixels.length; l++) {
    if ((pixels[l] & 0xff) <= threshold) {
      pixels[l]=1;
    }
 else {
      pixels[l]=0;
    }
  }
  return pixels;
}
Program: 33362
Project: 33362
Buggy source:
/** 
 * Remove pages from a multiple page TIFF image
 * @param rin input image stream
 * @param rout output image stream
 * @param pages an array of page numbers to be removed
 * @return number of pages removed
 * @throws IOException
 */
public static int removePages(RandomAccessInputStream rin,RandomAccessOutputStream rout,int... pages) throws IOException {
  List<IFD> list=new ArrayList<IFD>();
  int offset=copyHeader(rin,rout);
  readIFDs(null,null,TiffTag.class,list,offset,rin);
  int pagesRemoved=0;
  List<Integer> pageList=ArrayUtils.intArrayAsList(pages);
  Collections.sort(pageList);
  for (int i=pageList.size() - 1; i >= 0; i--) {
    int index=pageList.get(i);
    if (index < 0)     break;
    if (list.size() > 1 && list.size() > index) {
      pagesRemoved++;
      list.remove(index);
    }
  }
  for (int i=0; i < list.size(); i++) {
    list.get(i).removeField(TiffTag.PAGE_NUMBER.getValue());
    list.get(i).addField(new ShortField(TiffTag.PAGE_NUMBER.getValue(),new short[]{(short)i,(short)(list.size() - 1)}));
  }
  int writeOffset=FIRST_WRITE_OFFSET;
  offset=copyPages(list,writeOffset,rin,rout);
  int firstIFDOffset=list.get(0).getStartOffset();
  writeToStream(rout,firstIFDOffset);
  return pagesRemoved;
}

Fixed version (ground truth):
/** 
 * Remove pages from a multiple page TIFF image
 * @param rin input image stream
 * @param rout output image stream
 * @param pages an array of page numbers to be removed
 * @return number of pages removed
 * @throws IOException
 */
public static int removePages(RandomAccessInputStream rin,RandomAccessOutputStream rout,int... pages) throws IOException {
  List<IFD> list=new ArrayList<IFD>();
  int offset=copyHeader(rin,rout);
  readIFDs(null,null,TiffTag.class,list,offset,rin);
  int pagesRemoved=0;
  pages=ArrayUtils.removeDuplicates(pages);
  for (int i=pages.length - 1; i >= 0; i--) {
    if (pages[i] < 0)     break;
    if (list.size() > 1 && list.size() > pages[i]) {
      pagesRemoved++;
      list.remove(pages[i]);
    }
  }
  for (int i=0; i < list.size(); i++) {
    list.get(i).removeField(TiffTag.PAGE_NUMBER.getValue());
    list.get(i).addField(new ShortField(TiffTag.PAGE_NUMBER.getValue(),new short[]{(short)i,(short)(list.size() - 1)}));
  }
  int writeOffset=FIRST_WRITE_OFFSET;
  offset=copyPages(list,writeOffset,rin,rout);
  int firstIFDOffset=list.get(0).getStartOffset();
  writeToStream(rout,firstIFDOffset);
  return pagesRemoved;
}
Program: 33366
Project: 33366
Buggy source:
/** 
 * Creates a BufferedImage the same size as the logical screen <p> <b>Note</b>: the underlying frame will share the same data with the current base image.  Subsequent call to this method will change the previous frames too. If this is not intended, backups of the previous frames should be done before new calls 
 * @param is input stream for the image - single frame of multiple frame animated GIF
 * @return java BufferedImage or null if there is no more frames
 * @throws Exception
 */
public BufferedImage getFrameAsBufferedImageEx(InputStream is) throws Exception {
  BufferedImage bi=getFrameAsBufferedImage(is);
  if (bi == null)   return null;
  if (baseImage == null)   baseImage=new BufferedImage(logicalScreenWidth,logicalScreenHeight,BufferedImage.TYPE_INT_ARGB);
  Rectangle area=new Rectangle(image_x,image_y,width,height);
  BufferedImage backup=new BufferedImage(width,height,BufferedImage.TYPE_INT_ARGB);
  backup.setData(baseImage.getData(area));
  Graphics2D g=baseImage.createGraphics();
  if (disposalMethod == 1 || disposalMethod == 0)   ;
 else   if (disposalMethod == 2) {
    baseImage=new BufferedImage(logicalScreenWidth,logicalScreenHeight,BufferedImage.TYPE_INT_ARGB);
    g=baseImage.createGraphics();
  }
 else   if (disposalMethod == 3) {
    g.drawImage(backup,image_x,image_y,null);
  }
 else {
    baseImage=new BufferedImage(logicalScreenWidth,logicalScreenHeight,BufferedImage.TYPE_INT_ARGB);
    g=baseImage.createGraphics();
  }
  g.drawImage(bi,image_x,image_y,null);
  return baseImage;
}

Fixed version (ground truth):
/** 
 * Creates a frame as a BufferedImage the same size as the logical screen
 * @param is input stream for the image - single frame of multiple frame animated GIF
 * @return java BufferedImage or null if there is no more frames
 * @throws Exception
 */
public BufferedImage getFrameAsBufferedImageEx(InputStream is) throws Exception {
  BufferedImage bi=getFrameAsBufferedImage(is);
  if (bi == null)   return null;
  if (baseImage == null)   baseImage=new BufferedImage(logicalScreenWidth,logicalScreenHeight,BufferedImage.TYPE_INT_ARGB);
  Rectangle area=new Rectangle(image_x,image_y,width,height);
  BufferedImage backup=new BufferedImage(width,height,BufferedImage.TYPE_INT_ARGB);
  backup.setData(baseImage.getData(area));
  Graphics2D g=baseImage.createGraphics();
  g.drawImage(bi,image_x,image_y,null);
  BufferedImage clone=new BufferedImage(logicalScreenWidth,logicalScreenHeight,BufferedImage.TYPE_INT_ARGB);
  clone.setData(baseImage.getData());
  if (disposalMethod == 1 || disposalMethod == 0)   ;
 else   if (disposalMethod == 2) {
    Composite oldComposite=g.getComposite();
    g.setComposite(AlphaComposite.Clear);
    g.fillRect(image_x,image_y,width,height);
    g.setComposite(oldComposite);
  }
 else   if (disposalMethod == 3) {
    Composite oldComposite=g.getComposite();
    g.setComposite(AlphaComposite.Src);
    g.drawImage(backup,image_x,image_y,null);
    g.setComposite(oldComposite);
  }
 else {
    baseImage=new BufferedImage(logicalScreenWidth,logicalScreenHeight,BufferedImage.TYPE_INT_ARGB);
    g=baseImage.createGraphics();
  }
  return clone;
}
Program: 33367
Project: 33367
Buggy source:
/** 
 * Creates a BufferedImage for the current frame. For animated GIF, the frame may only occupy part of the logical screen and may also rely on transparency and previous frames to work properly. A more 
 * @param is
 * @return
 * @throws Exception
 */
public BufferedImage getFrameAsBufferedImage(InputStream is) throws Exception {
  byte[] pixels=readFrame(is);
  if (pixels == null)   return null;
  int[] off={0};
  DataBuffer db=new DataBufferByte(pixels,pixels.length);
  WritableRaster raster=Raster.createInterleavedRaster(db,width,height,width,1,off,null);
  ColorModel cm=new IndexColorModel(bitsPerPixel,rgbColorPalette.length,rgbColorPalette,0,false,transparent_color,DataBuffer.TYPE_BYTE);
  return new BufferedImage(cm,raster,false,null);
}

Fixed version (ground truth):
/** 
 * Creates a BufferedImage for the current frame. For animated GIF, the frame may only occupy part of the logical screen and may also rely on transparency and previous frames to work properly.
 * @param is InputStream for the GIF/Animated GIF
 * @return a BufferedImage for the GIF image or current frame in case of animated GIF
 * @throws Exception
 */
public BufferedImage getFrameAsBufferedImage(InputStream is) throws Exception {
  byte[] pixels=readFrame(is);
  if (pixels == null)   return null;
  int[] off={0};
  DataBuffer db=new DataBufferByte(pixels,pixels.length);
  WritableRaster raster=Raster.createInterleavedRaster(db,width,height,width,1,off,null);
  ColorModel cm=new IndexColorModel(bitsPerPixel,rgbColorPalette.length,rgbColorPalette,0,false,transparent_color,DataBuffer.TYPE_BYTE);
  return new BufferedImage(cm,raster,false,null);
}
Program: 33369
Project: 33369
Buggy source:
public static int[] toPrimitive(Integer[] integers){
  int[] ints=new int[integers.length];
  int i=0;
  for (  Integer n : ints) {
    ints[i++]=n;
  }
  return ints;
}

Fixed version (ground truth):
public static int[] toPrimitive(Integer[] integers){
  int[] ints=new int[integers.length];
  int i=0;
  for (  Integer n : integers) {
    ints[i++]=n;
  }
  return ints;
}
Program: 33373
Project: 33373
Buggy source:
public static WritableRaster CMYK2RGB(Raster raster,ICC_Profile profile,boolean hasAlpha){
  ColorModel cm=null;
  if (hasAlpha) {
    cm=ColorModel.getRGBdefault();
  }
 else   cm=new DirectColorModel(24,0x00ff0000,0x0000ff00,0x000000ff);
  ColorConvertOp converter=new ColorConvertOp(new ICC_ColorSpace(profile),cm.getColorSpace(),null);
  WritableRaster destRaster=converter.createCompatibleDestRaster(raster);
  converter.filter(raster,destRaster);
  return destRaster;
}

Fixed version (ground truth):
/** 
 * Convert CMYK raster to RGB raster w/o alpha
 * @param raster WritableRaster for CMYK ICC_Profile ColorSpace
 * @param cm ColorModel for CMYK ICC_Profile ColorSpace
 * @return WritableRaster for RGB ColorSpace
 */
public static WritableRaster CMYK2RGB(WritableRaster raster,ColorModel cm){
  ColorSpace sRGB=ColorSpace.getInstance(ColorSpace.CS_sRGB);
  ColorConvertOp cco=new ColorConvertOp(cm.getColorSpace(),sRGB,null);
  WritableRaster rgbRaster=null;
  BufferedImage cmykImage=new BufferedImage(cm,raster,false,null);
  rgbRaster=cco.filter(cmykImage,null).getRaster();
  return rgbRaster;
}
Program: 33375
Project: 33375
Buggy source:
@Override public void setInput(byte[] input,int offset,int len){
  if (input[offset] == (byte)0x00 && input[offset + 1] == (byte)0x01)   isCodeBigEndian=false;
  is=new ByteArrayInputStream(input,offset,len);
  bits_remain=0;
  clearStringTable();
}

Fixed version (ground truth):
@Override public void setInput(byte[] input,int offset,int len){
  if (input[offset] == (byte)0x00 && input[offset + 1] == (byte)0x01)   isCodeBigEndian=false;
  is=new ByteArrayInputStream(input,offset,len);
  bits_remain=0;
  leftOver=0;
  clearStringTable();
}
Program: 33384
Project: 33384
Buggy source:
public void finish() throws Exception {
  if (isTIFF)   writer.update(deflater.getTotalOut());
}

Fixed version (ground truth):
public void finish() throws Exception {
  if (isTIFF && writer != null)   writer.update(deflater.getTotalOut());
}
Program: 33387
Project: 33387
Buggy source:
public static byte[] easyRGB2CMYK(int[] rgb,boolean hasAlpha){
  byte[] cmyk=(hasAlpha ? new byte[rgb.length * 5] : new byte[rgb.length * 4]);
  for (int i=0, index=0; i < rgb.length; i++) {
    int red=((rgb[i] >> 16) & 0xff);
    int green=((rgb[i] >> 8) & 0xff);
    int blue=(rgb[i] & 0xff);
    float c=1 - (red / 255.0f);
    float m=1 - (green / 255.0f);
    float y=1 - (blue / 255.0f);
    float tempK=1.0f;
    if (c < tempK)     tempK=c;
    if (m < tempK)     tempK=m;
    if (y < tempK)     tempK=y;
    if (tempK == 1.0f)     cmyk[index++]=cmyk[index++]=cmyk[index++]=0;
 else {
      cmyk[index++]=(byte)((c - tempK) / (1 - tempK) * 255);
      cmyk[index++]=(byte)((m - tempK) / (1 - tempK) * 255);
      cmyk[index++]=(byte)((m - tempK) / (1 - tempK) * 255);
    }
    cmyk[index++]=(byte)(tempK * 255);
    if (hasAlpha)     cmyk[index++]=(byte)((rgb[i] >> 24) & 0xff);
  }
  return cmyk;
}

Fixed version (ground truth):
public static byte[] easyRGB2CMYK(int[] rgb,boolean hasAlpha){
  byte[] cmyk=(hasAlpha ? new byte[rgb.length * 5] : new byte[rgb.length * 4]);
  for (int i=0, index=0; i < rgb.length; i++) {
    int red=((rgb[i] >> 16) & 0xff);
    int green=((rgb[i] >> 8) & 0xff);
    int blue=(rgb[i] & 0xff);
    float c=1 - (red / 255.0f);
    float m=1 - (green / 255.0f);
    float y=1 - (blue / 255.0f);
    float tempK=1.0f;
    if (c < tempK)     tempK=c;
    if (m < tempK)     tempK=m;
    if (y < tempK)     tempK=y;
    if (tempK == 1.0f)     cmyk[index++]=cmyk[index++]=cmyk[index++]=0;
 else {
      cmyk[index++]=(byte)((c - tempK) / (1 - tempK) * 255);
      cmyk[index++]=(byte)((m - tempK) / (1 - tempK) * 255);
      cmyk[index++]=(byte)((y - tempK) / (1 - tempK) * 255);
    }
    cmyk[index++]=(byte)(tempK * 255);
    if (hasAlpha)     cmyk[index++]=(byte)((rgb[i] >> 24) & 0xff);
  }
  return cmyk;
}
Program: 33389
Project: 33389
Buggy source:
/** 
 * Returns a non-intersecting list of shard ids and versions chosen from the shardsForTime list. Shards in the list are sorted chronologically.
 */
static List<ShardIdWithVersion> removeIntersectingShards(List<ShardIdWithVersion> shardsForTime,String dataset,final DateTime start){
  final List<ShardTruncatedStart> shardsForTimeTruncated=new ArrayList<ShardTruncatedStart>(shardsForTime.size());
  for (  ShardIdWithVersion shard : shardsForTime) {
    ShardInfo.DateTimeRange range=shard.getRange();
    if (range == null) {
      log.warn("String_Node_Str" + dataset + "String_Node_Str"+ shard.getShardId());
      continue;
    }
    DateTime shardStart=range.start;
    if (start.isAfter(range.start)) {
      shardStart=start;
    }
    shardsForTimeTruncated.add(new ShardTruncatedStart(shard,shardStart));
  }
  Collections.sort(shardsForTimeTruncated,new Comparator<ShardTruncatedStart>(){
    @Override public int compare(    ShardTruncatedStart o1,    ShardTruncatedStart o2){
      final int c=o1.start.compareTo(o2.start);
      if (c != 0)       return c;
      return -Longs.compare(o1.version,o2.version);
    }
  }
);
  final List<ShardIdWithVersion> chosenShards=Lists.newArrayList();
  DateTime processedUpTo=new DateTime(0L);
  for (  ShardTruncatedStart shard : shardsForTimeTruncated) {
    if (!shard.start.isBefore(processedUpTo)) {
      chosenShards.add(shard.shard);
      processedUpTo=shard.end;
    }
  }
  return chosenShards;
}

Fixed version (ground truth):
/** 
 * Returns a non-intersecting list of shard ids and versions chosen from the shardsForTime list. Shards in the list are sorted chronologically.
 */
static List<ShardIdWithVersion> removeIntersectingShards(List<ShardIdWithVersion> shardsForTime,String dataset,final DateTime start){
  final List<ShardTruncatedStart> shardsForTimeTruncated=new ArrayList<ShardTruncatedStart>(shardsForTime.size());
  for (  ShardIdWithVersion shard : shardsForTime) {
    ShardInfo.DateTimeRange range=shard.getRange();
    if (range == null) {
      log.warn("String_Node_Str" + dataset + "String_Node_Str"+ shard.getShardId());
      continue;
    }
    DateTime shardStart=range.start;
    if (start.isAfter(range.start)) {
      shardStart=start;
    }
    shardsForTimeTruncated.add(new ShardTruncatedStart(shard,shardStart));
  }
  Collections.sort(shardsForTimeTruncated,new Comparator<ShardTruncatedStart>(){
    @Override public int compare(    ShardTruncatedStart o1,    ShardTruncatedStart o2){
      final int c=o1.start.compareTo(o2.start);
      if (c != 0)       return c;
      return -Longs.compare(o1.version,o2.version);
    }
  }
);
  final List<ShardIdWithVersion> chosenShards=Lists.newArrayList();
  DateTime processedUpTo=new DateTime(-2000000,1,1,0,0);
  for (  ShardTruncatedStart shard : shardsForTimeTruncated) {
    if (!shard.start.isBefore(processedUpTo)) {
      chosenShards.add(shard.shard);
      processedUpTo=shard.end;
    }
  }
  return chosenShards;
}
Program: 33390
Project: 33390
Buggy source:
public long length(){
  File f;
  try {
    f=topFS.loadFile(fullPath);
  }
 catch (  IOException e) {
    return 0L;
  }
  return f.length();
}

Fixed version (ground truth):
public long length(){
  File f;
  try {
    f=topFS.loadFile(fullPath);
  }
 catch (  IOException e) {
    e.printStackTrace();
    return 0L;
  }
  return f.length();
}
Program: 33391
Project: 33391
Buggy source:
public File loadDirectory() throws IOException {
  final Map<String,File> data;
  data=topFS.loadDirectory(fullPath,null);
  return data.get(fullPath);
}

Fixed version (ground truth):
public File loadDirectory() throws IOException {
  final Map<String,File> data;
  data=topFS.loadDirectory(fullPath,null);
  if (data == null) {
    return null;
  }
  return data.get(fullPath);
}
Program: 33392
Project: 33392
Buggy source:
public int weigh(String path,File cachedFile){
  return (int)(cachedFile.length() / 1024);
}

Fixed version (ground truth):
public int weigh(String path,File cachedFile){
  int kb;
  kb=(int)(cachedFile.length() / 1024);
  if (kb == 0) {
    kb=1;
  }
  return kb;
}
Program: 33393
Project: 33393
Buggy source:
@Override public Map<String,File> loadDirectory(String fullPath,File location) throws IOException {
  final String relativePath=mounter.getMountRelativePath(fullPath,mountPoint);
  final Map<String,File> files;
  final File localDir;
  if (location != null) {
    throw new UnsupportedOperationException("String_Node_Str" + "String_Node_Str");
  }
  localDir=new File(localCacheDir,relativePath);
  localDir.getParentFile().mkdirs();
  files=parentFS.loadDirectory(relativePath,localDir);
  for (  Map.Entry<String,File> entry : files.entrySet()) {
    cache.put(entry.getKey(),entry.getValue());
  }
  files.put(relativePath,localDir);
  return files;
}

Fixed version (ground truth):
@Override public Map<String,File> loadDirectory(String fullPath,File location) throws IOException {
  final String relativePath=mounter.getMountRelativePath(fullPath,mountPoint);
  final Map<String,File> files;
  final File localDir;
  if (location != null) {
    throw new UnsupportedOperationException("String_Node_Str" + "String_Node_Str");
  }
  localDir=new File(localCacheDir,relativePath);
  localDir.getParentFile().mkdirs();
  files=parentFS.loadDirectory(fullPath,localDir);
  if (files == null) {
    return null;
  }
  for (  Map.Entry<String,File> entry : files.entrySet()) {
    cache.put(entry.getKey(),entry.getValue());
  }
  files.put(fullPath,localDir);
  return files;
}
Program: 33394
Project: 33394
Buggy source:
public void onRemoval(RemovalNotification<String,File> rn){
  removeFile(rn.getValue());
}

Fixed version (ground truth):
public void onRemoval(RemovalNotification<String,File> rn){
  if (rn.getCause().equals(RemovalCause.REPLACED)) {
    return;
  }
  removeFile(rn.getValue());
}
Program: 33395
Project: 33395
Buggy source:
public CachedRemoteFileSystem(Map<String,Object> settings,RemoteFileSystem parentFS,RemoteFileSystemMounter mounter) throws IOException {
  final int cacheSize;
  final String cacheDir;
  this.parentFS=parentFS;
  mountPoint=(String)settings.get("String_Node_Str");
  if (!mountPoint.endsWith(DELIMITER)) {
    mountPoint=mountPoint + DELIMITER;
  }
  mountPoint=mounter.getRootMountPoint() + mountPoint;
  mountPoint=mountPoint.replace("String_Node_Str","String_Node_Str");
  this.mounter=mounter;
  cacheDir=(String)settings.get("String_Node_Str");
  localCacheDir=new File(cacheDir);
  localCacheDir.mkdir();
  cacheSize=(Integer)settings.get("String_Node_Str");
  cache=CacheBuilder.newBuilder().maximumWeight(cacheSize * 1024).weigher(new Weigher<String,File>(){
    public int weigh(    String path,    File cachedFile){
      return (int)(cachedFile.length() / 1024);
    }
  }
).removalListener(new RemovalListener<String,File>(){
    public void onRemoval(    RemovalNotification<String,File> rn){
      removeFile(rn.getValue());
    }
  }
).build(new CacheLoader<String,File>(){
    public File load(    String path) throws Exception {
      return downloadFile(path);
    }
  }
);
  scanExistingFiles();
}

Fixed version (ground truth):
public CachedRemoteFileSystem(Map<String,Object> settings,RemoteFileSystem parentFS,RemoteFileSystemMounter mounter) throws IOException {
  final int cacheSize;
  final String cacheDir;
  this.parentFS=parentFS;
  mountPoint=(String)settings.get("String_Node_Str");
  if (!mountPoint.endsWith(DELIMITER)) {
    mountPoint=mountPoint + DELIMITER;
  }
  mountPoint=mounter.getRootMountPoint() + mountPoint;
  mountPoint=mountPoint.replace("String_Node_Str","String_Node_Str");
  this.mounter=mounter;
  cacheDir=(String)settings.get("String_Node_Str");
  localCacheDir=new File(cacheDir);
  localCacheDir.mkdir();
  cacheSize=(Integer)settings.get("String_Node_Str");
  cache=CacheBuilder.newBuilder().initialCapacity(8192).maximumWeight(cacheSize * 1024).weigher(new Weigher<String,File>(){
    public int weigh(    String path,    File cachedFile){
      int kb;
      kb=(int)(cachedFile.length() / 1024);
      if (kb == 0) {
        kb=1;
      }
      return kb;
    }
  }
).removalListener(new RemovalListener<String,File>(){
    public void onRemoval(    RemovalNotification<String,File> rn){
      if (rn.getCause().equals(RemovalCause.REPLACED)) {
        return;
      }
      removeFile(rn.getValue());
    }
  }
).build(new CacheLoader<String,File>(){
    public File load(    String path) throws Exception {
      return downloadFile(path);
    }
  }
);
  scanExistingFiles();
}
Program: 33396
Project: 33396
Buggy source:
@Override public void copyFileInto(String fullPath,File localFile) throws IOException {
  final String relativePath=mounter.getMountRelativePath(fullPath,mountPoint);
  final FileMetadata metadata;
  final SquallArchiveCompressor compressor;
  final InputStream is;
  metadata=scanMetadataForFile(relativePath);
  if (metadata == null) {
    throw new FileNotFoundException("String_Node_Str" + relativePath + "String_Node_Str");
  }
  final long startOffset=metadata.getStartOffset();
  final long originalSize=metadata.getSize();
  final String archiveFile=metadata.getArchiveFilename();
  final String sqarpath;
  final String archivePath;
  final DigestInputStream digestStream;
  final OutputStream os;
  sqarpath=mountPoint.substring(0,mountPoint.length() - DELIMITER.length()) + SUFFIX;
  archivePath=sqarpath + DELIMITER + archiveFile;
  is=parentFS.getInputStreamForFile(archivePath,startOffset,originalSize);
  try {
    compressor=metadata.getCompressor();
    digestStream=new DigestInputStream(compressor.newInputStream(is),ArchiveUtils.getMD5Digest());
    os=new BufferedOutputStream(new FileOutputStream(localFile));
    ArchiveUtils.streamCopy(digestStream,os,originalSize);
    os.close();
  }
  finally {
    is.close();
  }
  final String checksum=ArchiveUtils.toHex(digestStream.getMessageDigest().digest());
  if (!checksum.equals(metadata.getChecksum())) {
    throw new IOException("String_Node_Str" + fullPath + "String_Node_Str"+ archivePath+ "String_Node_Str"+ checksum+ "String_Node_Str"+ metadata.getChecksum());
  }
}

Fixed version (ground truth):
@Override public void copyFileInto(String fullPath,File localFile) throws IOException {
  final String relativePath=mounter.getMountRelativePath(fullPath,mountPoint);
  final FileMetadata metadata;
  final SquallArchiveCompressor compressor;
  final InputStream is;
  metadata=scanMetadataForFile(relativePath);
  if (metadata == null) {
    throw new FileNotFoundException("String_Node_Str" + relativePath + "String_Node_Str");
  }
  final long startOffset=metadata.getStartOffset();
  final long originalSize=metadata.getSize();
  final String archiveFile=metadata.getArchiveFilename();
  final String sqarpath;
  final String archivePath;
  final DigestInputStream digestStream;
  final OutputStream os;
  sqarpath=mountPoint.substring(0,mountPoint.length() - DELIMITER.length()) + SUFFIX;
  archivePath=sqarpath + DELIMITER + archiveFile;
  is=parentFS.getInputStreamForFile(archivePath,startOffset,originalSize + 2048);
  try {
    compressor=metadata.getCompressor();
    digestStream=new DigestInputStream(compressor.newInputStream(is),ArchiveUtils.getMD5Digest());
    os=new BufferedOutputStream(new FileOutputStream(localFile));
    ArchiveUtils.streamCopy(digestStream,os,originalSize);
    os.close();
  }
  finally {
    is.close();
  }
  final String checksum=ArchiveUtils.toHex(digestStream.getMessageDigest().digest());
  if (!checksum.equals(metadata.getChecksum())) {
    throw new IOException("String_Node_Str" + fullPath + "String_Node_Str"+ archivePath+ "String_Node_Str"+ checksum+ "String_Node_Str"+ metadata.getChecksum());
  }
}