nus-yam/ex-repair huggingface dataset:
Program: 190842
Project: 190842
Buggy source:
Bitmap hunt() throws IOException {
  Bitmap bitmap;
  if (!skipMemoryCache) {
    bitmap=cache.get(key);
    if (bitmap != null) {
      stats.dispatchCacheHit();
      loadedFrom=MEMORY;
      return bitmap;
    }
  }
  bitmap=decode(data);
  if (bitmap != null) {
    stats.dispatchBitmapDecoded(bitmap);
    if (data.needsTransformation()) {
synchronized (DECODE_LOCK) {
        if (data.needsMatrixTransform() || exifRotation != 0) {
          bitmap=transformResult(data,bitmap,exifRotation);
        }
        if (data.hasCustomTransformations()) {
          bitmap=applyCustomTransformations(data.transformations,bitmap);
        }
      }
      stats.dispatchBitmapTransformed(bitmap);
    }
  }
  return bitmap;
}

Fixed version (ground truth):
Bitmap hunt() throws IOException {
  Bitmap bitmap;
  if (!skipMemoryCache) {
    bitmap=cache.get(key);
    if (bitmap != null) {
      stats.dispatchCacheHit();
      loadedFrom=MEMORY;
      return bitmap;
    }
  }
  bitmap=decode(data);
  if (bitmap != null) {
    stats.dispatchBitmapDecoded(bitmap);
    if (data.needsTransformation() || exifRotation != 0) {
synchronized (DECODE_LOCK) {
        if (data.needsMatrixTransform() || exifRotation != 0) {
          bitmap=transformResult(data,bitmap,exifRotation);
        }
        if (data.hasCustomTransformations()) {
          bitmap=applyCustomTransformations(data.transformations,bitmap);
        }
      }
      stats.dispatchBitmapTransformed(bitmap);
    }
  }
  return bitmap;
}
Program: 190843
Project: 190843
Buggy source:
@Override public void onReceive(Context context,Intent intent){
  String action=intent.getAction();
  Bundle extras=intent.getExtras();
  if (ACTION_AIRPLANE_MODE_CHANGED.equals(action)) {
    dispatchAirplaneModeChange(extras.getBoolean(EXTRA_AIRPLANE_STATE,false));
  }
 else   if (CONNECTIVITY_ACTION.equals(action)) {
    dispatchNetworkStateChange(connectivityManager.getActiveNetworkInfo());
  }
}

Fixed version (ground truth):
@Override public void onReceive(Context context,Intent intent){
  if (null == intent) {
    return;
  }
  String action=intent.getAction();
  Bundle extras=intent.getExtras();
  if (ACTION_AIRPLANE_MODE_CHANGED.equals(action)) {
    dispatchAirplaneModeChange(extras.getBoolean(EXTRA_AIRPLANE_STATE,false));
  }
 else   if (CONNECTIVITY_ACTION.equals(action)) {
    dispatchNetworkStateChange(connectivityManager.getActiveNetworkInfo());
  }
}
Program: 190845
Project: 190845
Buggy source:
private void drawDebugIndicator(Canvas canvas){
  canvas.save();
  canvas.rotate(45);
  DEBUG_PAINT.setColor(WHITE);
  canvas.drawRect(0,-10 * density,7.5f * density,10 * density,DEBUG_PAINT);
  DEBUG_PAINT.setColor(loadedFrom.debugColor);
  canvas.drawRect(0,-9 * density,6.5f * density,9 * density,DEBUG_PAINT);
  canvas.restore();
}

Fixed version (ground truth):
private void drawDebugIndicator(Canvas canvas){
  DEBUG_PAINT.setColor(WHITE);
  Path path=getTrianglePath(new Point(0,0),(int)(16 * density));
  canvas.drawPath(path,DEBUG_PAINT);
  DEBUG_PAINT.setColor(loadedFrom.debugColor);
  path=getTrianglePath(new Point(0,0),(int)(15 * density));
  canvas.drawPath(path,DEBUG_PAINT);
}
Program: 190846
Project: 190846
Buggy source:
Bitmap resolveRequest(Request request) throws IOException {
  Bitmap bitmap=loadFromCache(request);
  if (bitmap == null) {
    stats.cacheMiss();
    try {
      bitmap=loadFromType(request);
    }
 catch (    OutOfMemoryError e) {
      throw new IOException("String_Node_Str" + request,e);
    }
    if (bitmap != null && !request.skipCache) {
      cache.set(request.key,bitmap);
    }
  }
 else {
    stats.cacheHit();
  }
  return bitmap;
}

Fixed version (ground truth):
Bitmap resolveRequest(Request request) throws IOException {
  Bitmap bitmap=loadFromCache(request);
  if (bitmap == null) {
    stats.cacheMiss();
    try {
      bitmap=loadFromType(request);
    }
 catch (    OutOfMemoryError e) {
      throw new IOException("String_Node_Str" + request).initCause(e);
    }
    if (bitmap != null && !request.skipCache) {
      cache.set(request.key,bitmap);
    }
  }
 else {
    stats.cacheHit();
  }
  return bitmap;
}
Program: 190847
Project: 190847
Buggy source:
static int calculateDiskCacheSize(File dir){
  StatFs statFs=new StatFs(dir.getAbsolutePath());
  int available=statFs.getBlockCount() * statFs.getBlockSize();
  int size=available / 50;
  return Math.max(Math.min(size,MAX_DISK_CACHE_SIZE),MIN_DISK_CACHE_SIZE);
}

Fixed version (ground truth):
static int calculateDiskCacheSize(File dir){
  int size=0;
  try {
    StatFs statFs=new StatFs(dir.getAbsolutePath());
    int available=statFs.getBlockCount() * statFs.getBlockSize();
    size=available / 50;
  }
 catch (  IllegalArgumentException e) {
    size=MIN_DISK_CACHE_SIZE;
  }
  return Math.max(Math.min(size,MAX_DISK_CACHE_SIZE),MIN_DISK_CACHE_SIZE);
}
Program: 190848
Project: 190848
Buggy source:
private Bitmap transformResult(Request request,Bitmap result){
  List<Transformation> transformations=request.transformations;
  if (!transformations.isEmpty()) {
    for (int i=0, count=transformations.size(); i < count; i++) {
      Transformation t=transformations.get(i);
      result=t.transform(result);
      if (result == null) {
        throw new NullPointerException("String_Node_Str" + t.key() + "String_Node_Str");
      }
    }
  }
  return result;
}

Fixed version (ground truth):
Bitmap transformResult(Request request,Bitmap result){
  List<Transformation> transformations=request.transformations;
  if (!transformations.isEmpty()) {
    for (int i=0, count=transformations.size(); i < count; i++) {
      Transformation t=transformations.get(i);
      result=t.transform(result);
      if (result == null) {
        throw new NullPointerException("String_Node_Str" + t.key() + "String_Node_Str"+ request.path+ "String_Node_Str"+ i+ "String_Node_Str"+ request.transformationKeys());
      }
    }
  }
  return result;
}
Program: 190849
Project: 190849
Buggy source:
@Test public void reloadsTransformedBitmapFromCache() throws Exception {
  ImageView target=mock(ImageView.class);
  Transformation transformation=mock(Transformation.class);
  when(transformation.transform(any(Bitmap.class))).thenReturn(bitmap1);
  when(transformation.toString()).thenReturn("String_Node_Str");
  List<Transformation> transformations=new ArrayList<Transformation>(1);
  transformations.add(transformation);
  when(cache.get(Utils.createKey(URI_1,transformations,null))).thenReturn(bitmap1);
  Picasso picasso=create(LOADER_ANSWER,BITMAP1_ANSWER);
  picasso.load(URI_1).transform(transformation).into(target);
  executor.flush();
  verify(loader,never()).load(URI_1,false);
  assertThat(picasso.targetsToRequests).isEmpty();
}

Fixed version (ground truth):
@Test public void reloadsTransformedBitmapFromCache() throws Exception {
  ImageView target=mock(ImageView.class);
  Transformation transformation=mock(Transformation.class);
  when(transformation.transform(any(Bitmap.class))).thenReturn(bitmap1);
  when(transformation.key()).thenReturn("String_Node_Str");
  List<Transformation> transformations=new ArrayList<Transformation>(1);
  transformations.add(transformation);
  when(cache.get(Utils.createKey(URI_1,transformations,null))).thenReturn(bitmap1);
  Picasso picasso=create(LOADER_ANSWER,BITMAP1_ANSWER);
  picasso.load(URI_1).transform(transformation).into(target);
  executor.flush();
  verify(loader,never()).load(URI_1,false);
  assertThat(picasso.targetsToRequests).isEmpty();
}
Program: 190850
Project: 190850
Buggy source:
@Test public void doesNotDecodeAgainIfBitmapWithTransformationsAlreadyInCache() throws Exception {
  ImageView target1=mock(ImageView.class);
  ImageView target2=mock(ImageView.class);
  Transformation transformation=mock(Transformation.class);
  when(transformation.transform(any(Bitmap.class))).thenReturn(bitmap1);
  when(transformation.toString()).thenReturn("String_Node_Str");
  List<Transformation> transformations=new ArrayList<Transformation>(1);
  transformations.add(transformation);
  String key=Utils.createKey(URI_1,transformations,null);
  Picasso picasso=create(LOADER_ANSWER,BITMAP1_ANSWER);
  picasso.load(URI_1).transform(transformation).into(target1);
  picasso.load(URI_1).transform(transformation).into(target2);
  executor.executeFirst();
  when(cache.get(key)).thenReturn(bitmap1);
  executor.flush();
  verify(target1).setImageBitmap(bitmap1);
  verify(target2).setImageBitmap(bitmap1);
  verify(picasso.loader,times(1)).load(URI_1,false);
  assertThat(picasso.targetsToRequests).isEmpty();
}

Fixed version (ground truth):
@Test public void doesNotDecodeAgainIfBitmapWithTransformationsAlreadyInCache() throws Exception {
  ImageView target1=mock(ImageView.class);
  ImageView target2=mock(ImageView.class);
  Transformation transformation=mock(Transformation.class);
  when(transformation.transform(any(Bitmap.class))).thenReturn(bitmap1);
  when(transformation.key()).thenReturn("String_Node_Str");
  List<Transformation> transformations=new ArrayList<Transformation>(1);
  transformations.add(transformation);
  String key=Utils.createKey(URI_1,transformations,null);
  Picasso picasso=create(LOADER_ANSWER,BITMAP1_ANSWER);
  picasso.load(URI_1).transform(transformation).into(target1);
  picasso.load(URI_1).transform(transformation).into(target2);
  executor.executeFirst();
  when(cache.get(key)).thenReturn(bitmap1);
  executor.flush();
  verify(target1).setImageBitmap(bitmap1);
  verify(target2).setImageBitmap(bitmap1);
  verify(picasso.loader,times(1)).load(URI_1,false);
  assertThat(picasso.targetsToRequests).isEmpty();
}
Program: 190851
Project: 190851
Buggy source:
static Bitmap applyDebugColorFilter(Bitmap source,int loadedFrom){
  int color=RequestMetrics.getColorCodeForCacheHit(loadedFrom);
  ColorFilter filter=new LightingColorFilter(color,1);
  Paint paint=new Paint();
  paint.setColorFilter(filter);
  Bitmap result=source.copy(source.getConfig(),true);
  Canvas canvas=new Canvas(result);
  canvas.drawBitmap(result,0,0,paint);
  return result;
}

Fixed version (ground truth):
static Bitmap applyDebugColorFilter(Bitmap source,int loadedFrom){
  int color=RequestMetrics.getColorCodeForCacheHit(loadedFrom);
  ColorFilter filter=new LightingColorFilter(color,1);
  Paint paint=new Paint();
  paint.setColorFilter(filter);
  Bitmap output=Bitmap.createBitmap(source.getWidth(),source.getHeight(),source.getConfig());
  Canvas canvas=new Canvas(output);
  canvas.drawBitmap(source,0,0,paint);
  return output;
}
Program: 190852
Project: 190852
Buggy source:
private Picasso create(Answer loaderAnswer,Answer decoderAnswer) throws Exception {
  Picasso picasso=new Picasso.Builder().loader(loader).executor(executor).memoryCache(cache).debug().build();
  picasso=spy(picasso);
  doAnswer(loaderAnswer).when(loader).load(anyString(),anyBoolean());
  doAnswer(decoderAnswer).when(picasso).decodeStream(any(InputStream.class),any(Options.class));
  return picasso;
}

Fixed version (ground truth):
private Picasso create(Answer loaderAnswer,Answer decoderAnswer) throws Exception {
  Picasso picasso=new Picasso.Builder().loader(loader).executor(executor).memoryCache(cache).build();
  picasso=spy(picasso);
  doAnswer(loaderAnswer).when(loader).load(anyString(),anyBoolean());
  doAnswer(decoderAnswer).when(picasso).decodeStream(any(InputStream.class),any(Options.class));
  return picasso;
}
Program: 190853
Project: 190853
Buggy source:
public KmlPolygon createRegularPolygon(){
  List<LatLng> outerCoordinates=new ArrayList<LatLng>();
  outerCoordinates.add(new LatLng(10,10));
  outerCoordinates.add(new LatLng(20,20));
  outerCoordinates.add(new LatLng(30,30));
  outerCoordinates.add(new LatLng(10,10));
  List<List<LatLng>> innerCoordinates=new ArrayList<List<LatLng>>();
  List<LatLng> innerHole=new ArrayList<LatLng>();
  innerHole.add(new LatLng(20,20));
  innerHole.add(new LatLng(10,10));
  innerHole.add(new LatLng(20,20));
  innerCoordinates.add(innerHole);
  return new KmlPolygon(outerCoordinates,innerCoordinates);
}

Fixed version (ground truth):
public KmlPolygon createRegularPolygon(){
  ArrayList<LatLng> outerCoordinates=new ArrayList<LatLng>();
  outerCoordinates.add(new LatLng(10,10));
  outerCoordinates.add(new LatLng(20,20));
  outerCoordinates.add(new LatLng(30,30));
  outerCoordinates.add(new LatLng(10,10));
  ArrayList<ArrayList<LatLng>> innerCoordinates=new ArrayList<ArrayList<LatLng>>();
  ArrayList<LatLng> innerHole=new ArrayList<LatLng>();
  innerHole.add(new LatLng(20,20));
  innerHole.add(new LatLng(10,10));
  innerHole.add(new LatLng(20,20));
  innerCoordinates.add(innerHole);
  return new KmlPolygon(outerCoordinates,innerCoordinates);
}
Program: 190854
Project: 190854
Buggy source:
public KmlPolygon createRegularPolygon(){
  ArrayList<LatLng> outerCoordinates=new ArrayList<LatLng>();
  outerCoordinates.add(new LatLng(10,10));
  outerCoordinates.add(new LatLng(20,20));
  outerCoordinates.add(new LatLng(30,30));
  outerCoordinates.add(new LatLng(10,10));
  ArrayList<ArrayList<LatLng>> innerCoordinates=new ArrayList<ArrayList<LatLng>>();
  ArrayList<LatLng> innerHole=new ArrayList<LatLng>();
  innerHole.add(new LatLng(20,20));
  innerHole.add(new LatLng(10,10));
  innerHole.add(new LatLng(20,20));
  innerCoordinates.add(innerHole);
  return new KmlPolygon(outerCoordinates,innerCoordinates);
}

Fixed version (ground truth):
public KmlPolygon createRegularPolygon(){
  List<LatLng> outerCoordinates=new ArrayList<LatLng>();
  outerCoordinates.add(new LatLng(10,10));
  outerCoordinates.add(new LatLng(20,20));
  outerCoordinates.add(new LatLng(30,30));
  outerCoordinates.add(new LatLng(10,10));
  List<List<LatLng>> innerCoordinates=new ArrayList<List<LatLng>>();
  List<LatLng> innerHole=new ArrayList<LatLng>();
  innerHole.add(new LatLng(20,20));
  innerHole.add(new LatLng(10,10));
  innerHole.add(new LatLng(20,20));
  innerCoordinates.add(innerHole);
  return new KmlPolygon(outerCoordinates,innerCoordinates);
}
Program: 190856
Project: 190856
Buggy source:
/** 
 * Helper function for quadtree creation
 * @param points Collection of WeightedLatLng to calculate bounds for
 * @return Bounds that enclose the listed WeightedLatLng points
 */
static Bounds getBounds(Collection<WeightedLatLng> points){
  Iterator<WeightedLatLng> iter=points.iterator();
  WeightedLatLng first=iter.next();
  double minX=first.getPoint().x;
  double maxX=first.getPoint().x + SIGMA;
  double minY=first.getPoint().y;
  double maxY=first.getPoint().y + SIGMA;
  while (iter.hasNext()) {
    WeightedLatLng l=iter.next();
    double x=l.getPoint().x;
    double y=l.getPoint().y;
    if (x < minX)     minX=x;
    if (x + SIGMA > maxX)     maxX=x + SIGMA;
    if (y < minY)     minY=y;
    if (y + SIGMA > maxY)     maxY=y + SIGMA;
  }
  return new Bounds(minX,maxX,minY,maxY);
}

Fixed version (ground truth):
/** 
 * Helper function for quadtree creation
 * @param points Collection of WeightedLatLng to calculate bounds for
 * @return Bounds that enclose the listed WeightedLatLng points
 */
static Bounds getBounds(Collection<WeightedLatLng> points){
  Iterator<WeightedLatLng> iter=points.iterator();
  WeightedLatLng first=iter.next();
  double minX=first.getPoint().x;
  double maxX=first.getPoint().x;
  double minY=first.getPoint().y;
  double maxY=first.getPoint().y;
  while (iter.hasNext()) {
    WeightedLatLng l=iter.next();
    double x=l.getPoint().x;
    double y=l.getPoint().y;
    if (x < minX)     minX=x;
    if (x > maxX)     maxX=x;
    if (y < minY)     minY=y;
    if (y > maxY)     maxY=y;
  }
  return new Bounds(minX,maxX,minY,maxY);
}
Program: 190858
Project: 190858
Buggy source:
/** 
 * Helper function for quadtree creation
 * @param points Collection of WeightedLatLng to calculate bounds for
 * @return Bounds that enclose the listed WeightedLatLng points
 */
static Bounds getBounds(Collection<WeightedLatLng> points){
  Iterator<WeightedLatLng> iter=points.iterator();
  WeightedLatLng first=iter.next();
  double minX=first.getPoint().x;
  double maxX=first.getPoint().x + SIGMA;
  double minY=first.getPoint().y;
  double maxY=first.getPoint().y + SIGMA;
  while (iter.hasNext()) {
    WeightedLatLng l=iter.next();
    double x=l.getPoint().x;
    double y=l.getPoint().y;
    if (x < minX)     minX=x;
    if (x + SIGMA > maxX)     maxX=x + SIGMA;
    if (y < minY)     minY=y;
    if (y + SIGMA > maxY)     maxY=y + SIGMA;
  }
  return new Bounds(minX,maxX,minY,maxY);
}

Fixed version (ground truth):
/** 
 * Helper function for quadtree creation
 * @param points Collection of WeightedLatLng to calculate bounds for
 * @return Bounds that enclose the listed WeightedLatLng points
 */
static Bounds getBounds(Collection<WeightedLatLng> points){
  Iterator<WeightedLatLng> iter=points.iterator();
  WeightedLatLng first=iter.next();
  double minX=first.getPoint().x;
  double maxX=first.getPoint().x;
  double minY=first.getPoint().y;
  double maxY=first.getPoint().y;
  while (iter.hasNext()) {
    WeightedLatLng l=iter.next();
    double x=l.getPoint().x;
    double y=l.getPoint().y;
    if (x < minX)     minX=x;
    if (x > maxX)     maxX=x;
    if (y < minY)     minY=y;
    if (y > maxY)     maxY=y;
  }
  return new Bounds(minX,maxX,minY,maxY);
}
Program: 190859
Project: 190859
Buggy source:
/** 
 * Gets array of maximum intensity values to use with the heatmap for each zoom level This is the value that the highest color on the color map corresponds to
 * @param radius radius of the heatmap
 * @return array of maximum intensities
 */
private double[] getMaxIntensities(int radius){
  double[] maxIntensityArray=new double[MAX_ZOOM_LEVEL];
  for (int i=DEFAULT_MIN_ZOOM; i < DEFAULT_MAX_ZOOM; i++) {
    maxIntensityArray[i]=getMaxValue(mData,mBounds,radius,(int)(SCREEN_SIZE * Math.pow(2,i - 3)));
    if (i == DEFAULT_MIN_ZOOM) {
      for (int j=0; j < i; j++)       maxIntensityArray[j]=maxIntensityArray[i];
    }
  }
  for (int i=DEFAULT_MIN_ZOOM; i < MAX_ZOOM_LEVEL; i++) {
    maxIntensityArray[i]=maxIntensityArray[DEFAULT_MAX_ZOOM - 1];
  }
  return maxIntensityArray;
}

Fixed version (ground truth):
/** 
 * Gets array of maximum intensity values to use with the heatmap for each zoom level This is the value that the highest color on the color map corresponds to
 * @param radius radius of the heatmap
 * @return array of maximum intensities
 */
private double[] getMaxIntensities(int radius){
  double[] maxIntensityArray=new double[MAX_ZOOM_LEVEL];
  for (int i=DEFAULT_MIN_ZOOM; i < DEFAULT_MAX_ZOOM; i++) {
    maxIntensityArray[i]=getMaxValue(mData,mBounds,radius,(int)(SCREEN_SIZE * Math.pow(2,i - 3)));
    if (i == DEFAULT_MIN_ZOOM) {
      for (int j=0; j < i; j++)       maxIntensityArray[j]=maxIntensityArray[i];
    }
  }
  for (int i=DEFAULT_MAX_ZOOM; i < MAX_ZOOM_LEVEL; i++) {
    maxIntensityArray[i]=maxIntensityArray[DEFAULT_MAX_ZOOM - 1];
  }
  return maxIntensityArray;
}
Program: 190862
Project: 190862
Buggy source:
@Override protected void startDemo(){
  getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(SYDNEY,16));
  double[] kernel=HeatmapUtil.generateKernel(5,1.5);
  Log.e("String_Node_Str",Arrays.toString(kernel));
  double[][] grid=new double[5][5];
  grid[2][2]=2;
  grid[2][1]=1;
  grid[1][2]=1;
  grid[2][3]=1;
  grid[3][2]=1;
  double[] testKernel={0.5,1,0.5};
  double[][] convolved=HeatmapUtil.convolve(grid,testKernel);
  printGrid(convolved);
  int[] colorMapTest=HeatmapUtil.generateColorMap(HeatmapConstants.DEFAULT_HEATMAP_GRADIENT,101,1);
  Log.e("String_Node_Str",Arrays.toString(colorMapTest));
  Bitmap colorMap=Bitmap.createBitmap(256,256,Bitmap.Config.ARGB_8888);
  int colours[]=new int[256 * 256];
  int i, j, count=0;
  for (i=0; i < 256; i++) {
    for (j=0; j < 256; j++) {
      if (j < colorMapTest.length)       colours[count]=colorMapTest[j];
 else       colours[count]=colorMapTest[colorMapTest.length - 1];
      count++;
    }
  }
  colorMap.setPixels(colours,0,256,0,0,256,256);
  BitmapDescriptor image=BitmapDescriptorFactory.fromBitmap(colorMap);
  LatLng northeast=new LatLng(-33.865429,151.196766);
  LatLng southwest=new LatLng(-33.866209,151.195216);
  LatLngBounds bounds=new LatLngBounds(southwest,northeast);
  getMap().addGroundOverlay(new GroundOverlayOptions().image(image).positionFromBounds(bounds));
}

Fixed version (ground truth):
@Override protected void startDemo(){
  getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(SYDNEY,16));
  double[] kernel=HeatmapUtil.generateKernel(5,1.5);
  Log.e("String_Node_Str",Arrays.toString(kernel));
  double[][] grid=new double[5][5];
  grid[2][2]=2;
  grid[2][1]=1;
  grid[1][2]=1;
  grid[2][3]=1;
  grid[3][2]=1;
  double[] testKernel={0.5,1,0.5};
  double[][] convolved=HeatmapUtil.convolve(grid,testKernel);
  printGrid(convolved);
  int[] colorMapTest=HeatmapUtil.generateColorMap(HeatmapConstants.DEFAULT_HEATMAP_GRADIENT,102,1);
  Log.e("String_Node_Str",Arrays.toString(colorMapTest));
  Bitmap colorMap=Bitmap.createBitmap(256,256,Bitmap.Config.ARGB_8888);
  int colours[]=new int[256 * 256];
  int i, j, count=0;
  for (i=0; i < 256; i++) {
    for (j=0; j < 256; j++) {
      if (j < colorMapTest.length)       colours[count]=colorMapTest[j];
 else       colours[count]=colorMapTest[colorMapTest.length - 1];
      count++;
    }
  }
  colorMap.setPixels(colours,0,256,0,0,256,256);
  BitmapDescriptor image=BitmapDescriptorFactory.fromBitmap(colorMap);
  LatLng northeast=new LatLng(-33.865429,151.196766);
  LatLng southwest=new LatLng(-33.866209,151.195216);
  LatLngBounds bounds=new LatLngBounds(southwest,northeast);
  getMap().addGroundOverlay(new GroundOverlayOptions().image(image).positionFromBounds(bounds));
}
Program: 190863
Project: 190863
Buggy source:
/** 
 * Generates the color map to use with a provided gradient.
 * @param gradient Array of colors (int format)
 * @param size Number of elements in the color map
 * @param opacity Overall opacity of entire image: every individual alpha value will bemultiplied by this opacity.
 * @return the generated color map based on the gradient
 */
public static int[] generateColorMap(int[] gradient,int size,double opacity){
  int[] values=new int[gradient.length];
  int[] colors=new int[gradient.length];
  int interval=(size - 1) / (gradient.length - 1);
  int i;
  for (i=0; i < gradient.length; i++) {
    values[i]=i * interval;
    colors[i]=gradient[i];
  }
  Log.e("String_Node_Str",Arrays.toString(values));
  int[] colorMap=new int[size];
  int lowColorStop=0;
  for (i=0; i < size; i++) {
    Log.e("String_Node_Str","String_Node_Str" + i + "String_Node_Str"+ lowColorStop);
    if (i > values[lowColorStop + 1])     lowColorStop++;
    if (lowColorStop < values.length - 1) {
      colorMap[i]=interpolateColor(interval * lowColorStop,i,interval * (lowColorStop + 1),colors[lowColorStop],colors[lowColorStop + 1]);
    }
 else {
      colorMap[i]=colors[colors.length - 1];
    }
    if (opacity != 1) {
      int c=colorMap[i];
      colorMap[i]=Color.argb((int)(Color.alpha(c) * opacity),Color.red(c),Color.green(c),Color.blue(c));
    }
  }
  return colorMap;
}

Fixed version (ground truth):
/** 
 * Generates the color map to use with a provided gradient.
 * @param gradient Array of colors (int format)
 * @param size Number of elements in the color map
 * @param opacity Overall opacity of entire image: every individual alpha value will bemultiplied by this opacity.
 * @return the generated color map based on the gradient
 */
public static int[] generateColorMap(int[] gradient,int size,double opacity){
  int[] values=new int[gradient.length];
  int[] colors=new int[gradient.length];
  int interval=(size - 1) / (gradient.length - 1);
  int i;
  for (i=0; i < gradient.length; i++) {
    values[i]=i * interval;
    colors[i]=gradient[i];
  }
  Log.e("String_Node_Str",Arrays.toString(values));
  int[] colorMap=new int[size];
  int lowColorStop=0;
  for (i=0; i < size; i++) {
    Log.e("String_Node_Str","String_Node_Str" + i + "String_Node_Str"+ lowColorStop);
    if (lowColorStop + 1 < values.length) {
      if (i > values[lowColorStop + 1])       lowColorStop++;
    }
    if (lowColorStop < values.length - 1) {
      if (i > values[lowColorStop + 1])       lowColorStop++;
      colorMap[i]=interpolateColor(interval * lowColorStop,i,interval * (lowColorStop + 1),colors[lowColorStop],colors[lowColorStop + 1]);
    }
 else {
      colorMap[i]=colors[colors.length - 1];
    }
    if (opacity != 1) {
      int c=colorMap[i];
      colorMap[i]=Color.argb((int)(Color.alpha(c) * opacity),Color.red(c),Color.green(c),Color.blue(c));
    }
  }
  return colorMap;
}
Program: 190864
Project: 190864
Buggy source:
public Bounds(double minX,double maxX,double minY,double maxY){
  this.minX=minX;
  this.minY=minY;
  this.maxX=maxX;
  this.maxY=maxY;
  midX=(minX + maxX) / 2;
  midY=(minY + minY) / 2;
}

Fixed version (ground truth):
public Bounds(double minX,double maxX,double minY,double maxY){
  this.minX=minX;
  this.minY=minY;
  this.maxX=maxX;
  this.maxY=maxY;
  midX=(minX + maxX) / 2;
  midY=(minY + maxY) / 2;
}
Program: 190865
Project: 190865
Buggy source:
@Override public void add(T item){
  Node node=new Node(item);
  int index=Collections.binarySearch(mPoints,node);
  mPoints.add(index,node);
}

Fixed version (ground truth):
@Override public void add(T item){
  int size=mPoints.size();
  Node node=new Node(item);
  int index=Collections.binarySearch(mPoints,node);
  if (index < 0) {
    if (-index - 1 < mPoints.size())     mPoints.add(-index - 1,node);
 else     mPoints.add(node);
  }
 else {
    mPoints.add(index + 1,node);
  }
}
Program: 190866
Project: 190866
Buggy source:
private void search(Bounds searchBounds,Bounds currBounds,int location,int depth,Collection<T> results){
  if (searchBounds.contains(currBounds)) {
    Node node=new Node(location);
    int index=Collections.binarySearch(mPoints,node);
    for (; mPoints.get(index).location < location + (mBase ^ depth); index++) {
      results.add(mPoints.get(index).t);
    }
  }
 else   if (searchBounds.intersects(currBounds) && depth > 0) {
    search(searchBounds,new Bounds(currBounds.minX,currBounds.midX,currBounds.minY,currBounds.midY),location + mQuadrant.TOP_LEFT.getValue() * (mBase ^ depth),depth - 1,results);
    search(searchBounds,new Bounds(currBounds.midX,currBounds.maxX,currBounds.minY,currBounds.midY),location + mQuadrant.TOP_RIGHT.getValue() * (mBase ^ depth),depth - 1,results);
    search(searchBounds,new Bounds(currBounds.minX,currBounds.midX,currBounds.midY,currBounds.maxY),location + mQuadrant.BOTTOM_LEFT.getValue() * (mBase ^ depth),depth - 1,results);
    search(searchBounds,new Bounds(currBounds.midX,currBounds.maxX,currBounds.midY,currBounds.maxY),location + mQuadrant.BOTTOM_RIGHT.getValue() * (mBase ^ depth),depth - 1,results);
  }
 else   if (searchBounds.intersects(currBounds)) {
    Node node=new Node(location);
    int index=Collections.binarySearch(mPoints,node);
    for (; mPoints.get(index).location < location + (mBase ^ depth); index++) {
      if (searchBounds.contains(mPoints.get(index).t.getPoint().x,mPoints.get(index).t.getPoint().y)) {
        results.add(mPoints.get(index).t);
      }
    }
  }
}

Fixed version (ground truth):
private void search(Bounds searchBounds,Bounds currBounds,int location,int depth,Collection<T> results){
  for (  Node node : mPoints) {
    if (searchBounds.contains(node.t.getPoint().x,node.t.getPoint().y))     results.add(node.t);
  }
}
Program: 190867
Project: 190867
Buggy source:
@Override public boolean remove(T item){
  Node node=new Node(item);
  int index=Collections.binarySearch(mPoints,node);
  if (mPoints.get(index) == node) {
    mPoints.remove(index);
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean remove(T item){
  Node node=new Node(item);
  int index=Collections.binarySearch(mPoints,node);
  if (index >= 0) {
    while (index < mPoints.size() && mPoints.get(index).location == node.location && mPoints.get(index).t != item) {
      index++;
    }
    if (mPoints.get(index).t == item) {
      mPoints.remove(index);
      return true;
    }
  }
  return false;
}
Program: 190868
Project: 190868
Buggy source:
@Override public void onConnectedToRoom(Room room){
  Log.d(TAG,"String_Node_Str");
  mParticipants=room.getParticipants();
  mMyId=room.getParticipantId(Games.Players.getCurrentPlayerId(mGoogleApiClient));
  mRoomId=room.getRoomId();
  Log.d(TAG,"String_Node_Str" + mRoomId);
  Log.d(TAG,"String_Node_Str" + mMyId);
  Log.d(TAG,"String_Node_Str");
}

Fixed version (ground truth):
@Override public void onConnectedToRoom(Room room){
  Log.d(TAG,"String_Node_Str");
  mParticipants=room.getParticipants();
  mMyId=room.getParticipantId(Games.Players.getCurrentPlayerId(mGoogleApiClient));
  if (mRoomId == null)   mRoomId=room.getRoomId();
  Log.d(TAG,"String_Node_Str" + mRoomId);
  Log.d(TAG,"String_Node_Str" + mMyId);
  Log.d(TAG,"String_Node_Str");
}
Program: 190869
Project: 190869
Buggy source:
@Override public void onInvitationRemoved(String invitationId){
  if (mIncomingInvitationId != null) {
    if (mIncomingInvitationId.equals(invitationId)) {
      mIncomingInvitationId=null;
      switchToScreen(mCurScreen);
    }
  }
}

Fixed version (ground truth):
@Override public void onInvitationRemoved(String invitationId){
  if (mIncomingInvitationId.equals(invitationId) && mIncomingInvitationId != null) {
    mIncomingInvitationId=null;
    switchToScreen(mCurScreen);
  }
}
Program: 190870
Project: 190870
Buggy source:
@Override public void onRoomCreated(int statusCode,Room room){
  Log.d(TAG,"String_Node_Str" + statusCode + "String_Node_Str"+ room+ "String_Node_Str");
  if (statusCode != GamesStatusCodes.STATUS_OK) {
    Log.e(TAG,"String_Node_Str" + statusCode);
    showGameError();
    return;
  }
  showWaitingRoom(room);
}

Fixed version (ground truth):
@Override public void onRoomCreated(int statusCode,Room room){
  Log.d(TAG,"String_Node_Str" + statusCode + "String_Node_Str"+ room+ "String_Node_Str");
  if (statusCode != GamesStatusCodes.STATUS_OK) {
    Log.e(TAG,"String_Node_Str" + statusCode);
    showGameError();
    return;
  }
  mRoomId=room.getRoomId();
  showWaitingRoom(room);
}
Program: 190871
Project: 190871
Buggy source:
/** 
 * Attempts to resolve a connection failure. This will usually involve starting a UI flow that lets the user give the appropriate consents necessary for sign-in to work.
 */
void resolveConnectionResult(){
  if (mExpectingResolution) {
    debugLog("String_Node_Str");
    return;
  }
  if (mActivity == null) {
    debugLog("String_Node_Str");
    return;
  }
  debugLog("String_Node_Str" + mConnectionResult);
  if (mConnectionResult.hasResolution()) {
    debugLog("String_Node_Str");
    try {
      mExpectingResolution=true;
      mConnectionResult.startResolutionForResult(mActivity,RC_RESOLVE);
    }
 catch (    SendIntentException e) {
      debugLog("String_Node_Str");
      connect();
    }
  }
 else {
    debugLog("String_Node_Str");
    giveUp(new SignInFailureReason(mConnectionResult.getErrorCode()));
  }
}

Fixed version (ground truth):
/** 
 * Attempts to resolve a connection failure. This will usually involve starting a UI flow that lets the user give the appropriate consents necessary for sign-in to work.
 */
void resolveConnectionResult(){
  if (mExpectingResolution) {
    debugLog("String_Node_Str");
    return;
  }
  if (mActivity == null) {
    debugLog("String_Node_Str");
    return;
  }
  debugLog("String_Node_Str" + mConnectionResult);
  if (mConnectionResult.hasResolution()) {
    debugLog("String_Node_Str");
    try {
      mExpectingResolution=true;
      mConnectionResult.startResolutionForResult(mActivity,RC_RESOLVE);
    }
 catch (    SendIntentException e) {
      debugLog("String_Node_Str");
      connect();
    }
  }
 else {
    debugLog("String_Node_Str");
    giveUp(new SignInFailureReason(mConnectionResult.getErrorCode()));
    mConnectionResult=null;
  }
}
Program: 190872
Project: 190872
Buggy source:
void startConnections(){
  if (!checkState(TYPE_GAMEHELPER_BUG,"String_Node_Str","String_Node_Str" + "String_Node_Str",STATE_DISCONNECTED)) {
    return;
  }
  debugLog("String_Node_Str");
  setState(STATE_CONNECTING);
  mInvitationId=null;
  connectNextClient();
}

Fixed version (ground truth):
void startConnections(){
  if (!checkState(TYPE_GAMEHELPER_BUG,"String_Node_Str","String_Node_Str" + "String_Node_Str",STATE_DISCONNECTED)) {
    return;
  }
  debugLog("String_Node_Str");
  setState(STATE_CONNECTING);
  mInvitationId=null;
  mTurnBasedMatch=null;
  connectNextClient();
}
Program: 190873
Project: 190873
Buggy source:
/** 
 * Called when we successfully obtain a connection to a client. 
 */
@Override public void onConnected(Bundle connectionHint){
  mTurnBasedMatch=null;
  debugLog("String_Node_Str" + mClientCurrentlyConnecting);
  mConnectedClients|=mClientCurrentlyConnecting;
  debugLog("String_Node_Str" + mConnectedClients);
  if (mClientCurrentlyConnecting == CLIENT_GAMES && connectionHint != null) {
    debugLog("String_Node_Str");
    Invitation inv=connectionHint.getParcelable(GamesClient.EXTRA_INVITATION);
    if (inv != null && inv.getInvitationId() != null) {
      debugLog("String_Node_Str");
      mInvitationId=inv.getInvitationId();
      debugLog("String_Node_Str" + mInvitationId);
    }
    debugLog("String_Node_Str");
    TurnBasedMatch match=connectionHint.getParcelable(GamesClient.EXTRA_TURN_BASED_MATCH);
    if (match != null) {
      mTurnBasedMatch=match;
    }
  }
  connectNextClient();
}

Fixed version (ground truth):
/** 
 * Called when we successfully obtain a connection to a client. 
 */
@Override public void onConnected(Bundle connectionHint){
  debugLog("String_Node_Str" + mClientCurrentlyConnecting);
  mConnectedClients|=mClientCurrentlyConnecting;
  debugLog("String_Node_Str" + mConnectedClients);
  if (mClientCurrentlyConnecting == CLIENT_GAMES && connectionHint != null) {
    debugLog("String_Node_Str");
    Invitation inv=connectionHint.getParcelable(GamesClient.EXTRA_INVITATION);
    if (inv != null && inv.getInvitationId() != null) {
      debugLog("String_Node_Str");
      mInvitationId=inv.getInvitationId();
      debugLog("String_Node_Str" + mInvitationId);
    }
    debugLog("String_Node_Str");
    mTurnBasedMatch=connectionHint.getParcelable(GamesClient.EXTRA_TURN_BASED_MATCH);
  }
  connectNextClient();
}
Program: 190874
Project: 190874
Buggy source:
/** 
 * Handle activity result. Call this method from your Activity's onActivityResult callback. If the activity result pertains to the sign-in process, processes it appropriately.
 */
public void onActivityResult(int requestCode,int responseCode,Intent intent){
  if (requestCode == RC_RESOLVE) {
    mExpectingActivityResult=false;
    debugLog("String_Node_Str" + requestCode + "String_Node_Str"+ responseCode);
    if (responseCode == Activity.RESULT_OK) {
      debugLog("String_Node_Str");
      connectCurrentClient();
    }
 else {
      debugLog("String_Node_Str");
      giveUp();
    }
  }
}

Fixed version (ground truth):
/** 
 * Handle activity result. Call this method from your Activity's onActivityResult callback. If the activity result pertains to the sign-in process, processes it appropriately.
 */
public void onActivityResult(int requestCode,int responseCode,Intent intent){
  if (requestCode == RC_RESOLVE) {
    mExpectingActivityResult=false;
    debugLog("String_Node_Str" + requestCode + "String_Node_Str"+ responseCode);
    if (responseCode == Activity.RESULT_OK) {
      debugLog("String_Node_Str");
      connectCurrentClient();
    }
 else     if (responseCode == Activity.RESULT_CANCELED) {
      mAutoSignIn=false;
      mConnectionResult=null;
      mUserInitiatedSignIn=false;
      dismissDialog();
    }
 else {
      debugLog("String_Node_Str");
      giveUp();
    }
  }
}
Program: 190875
Project: 190875
Buggy source:
/** 
 * This method takes a temperature in Celsius or Fahrenheit and converts it to the other value.
 * @param source the temperature to convert from
 * @return the converted temperature.
 */
public Temperature convert(Temperature source){
  if (source.getScale() == CELSIUS) {
    if (source.getTemperature() < Temperature.ABSOLUTE_ZERO_C) {
      FacesContext.getCurrentInstance().addMessage(null,new FacesMessage("String_Node_Str"));
    }
 else     if (source.getTemperature() == Temperature.ABSOLUTE_ZERO_C) {
      FacesContext.getCurrentInstance().addMessage(null,new FacesMessage("String_Node_Str"));
    }
    return new Temperature((source.getTemperature() * 9 / 5) + 32,FARENHEIT);
  }
 else   if (source.getScale() == FARENHEIT) {
    if (source.getTemperature() < Temperature.ABSOLUTE_ZERO_F) {
      FacesContext.getCurrentInstance().addMessage(null,new FacesMessage("String_Node_Str"));
    }
 else     if (source.getTemperature() == Temperature.ABSOLUTE_ZERO_F) {
      FacesContext.getCurrentInstance().addMessage(null,new FacesMessage("String_Node_Str"));
    }
    return new Temperature((source.getTemperature() - 32) * 5 / 9,CELSIUS);
  }
 else {
    throw new IllegalStateException("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * This method takes a temperature in Celsius or Fahrenheit and converts it to the other value.
 * @param source the temperature to convert from
 * @return the converted temperature.
 */
public Temperature convert(Temperature source){
  if (source.getScale() == CELSIUS) {
    if (source.getTemperature() < Temperature.ABSOLUTE_ZERO_C) {
      FacesContext.getCurrentInstance().addMessage(null,new FacesMessage("String_Node_Str"));
    }
 else     if (source.getTemperature() == Temperature.ABSOLUTE_ZERO_C) {
      FacesContext.getCurrentInstance().addMessage(null,new FacesMessage("String_Node_Str"));
    }
    return new Temperature((source.getTemperature() * 9 / 5) + 32,FAHRENHEIT);
  }
 else   if (source.getScale() == FAHRENHEIT) {
    if (source.getTemperature() < Temperature.ABSOLUTE_ZERO_F) {
      FacesContext.getCurrentInstance().addMessage(null,new FacesMessage("String_Node_Str"));
    }
 else     if (source.getTemperature() == Temperature.ABSOLUTE_ZERO_F) {
      FacesContext.getCurrentInstance().addMessage(null,new FacesMessage("String_Node_Str"));
    }
    return new Temperature((source.getTemperature() - 32) * 5 / 9,CELSIUS);
  }
 else {
    throw new IllegalStateException("String_Node_Str");
  }
}
Program: 190876
Project: 190876
Buggy source:
public void register(){
  try {
    memberRegistration.register(newMember);
    facesContext.addMessage(null,new FacesMessage(FacesMessage.SEVERITY_INFO,"String_Node_Str","String_Node_Str"));
    initNewMember();
  }
 catch (  Exception e) {
    facesContext.addMessage(null,new FacesMessage(FacesMessage.SEVERITY_ERROR,"String_Node_Str","String_Node_Str"));
  }
}

Fixed version (ground truth):
public void register(){
  try {
    memberRegistration.register(newMember);
    facesContext.addMessage(null,new FacesMessage(FacesMessage.SEVERITY_INFO,"String_Node_Str","String_Node_Str"));
    initNewMember();
  }
 catch (  Exception e) {
    String errorMessage=getRootErrorMessage(e);
    facesContext.addMessage(null,new FacesMessage(FacesMessage.SEVERITY_ERROR,errorMessage,"String_Node_Str"));
  }
}
Program: 190877
Project: 190877
Buggy source:
public void register() throws Exception {
  memberRegistration.register(newMember);
  facesContext.addMessage(null,new FacesMessage(FacesMessage.SEVERITY_INFO,"String_Node_Str","String_Node_Str"));
  initNewMember();
}

Fixed version (ground truth):
public void register() throws Exception {
  try {
    memberRegistration.register(newMember);
    facesContext.addMessage(null,new FacesMessage(FacesMessage.SEVERITY_INFO,"String_Node_Str","String_Node_Str"));
    initNewMember();
  }
 catch (  Exception e) {
    String errorMessage=getRootErrorMessage(e);
    FacesMessage m=new FacesMessage(FacesMessage.SEVERITY_ERROR,errorMessage,"String_Node_Str");
    facesContext.addMessage(null,m);
  }
}
Program: 190878
Project: 190878
Buggy source:
public void register() throws Exception {
  memberRegistration.register(newMember);
  facesContext.addMessage(null,new FacesMessage(FacesMessage.SEVERITY_INFO,"String_Node_Str","String_Node_Str"));
  initNewMember();
}

Fixed version (ground truth):
public void register() throws Exception {
  try {
    memberRegistration.register(newMember);
    facesContext.addMessage(null,new FacesMessage(FacesMessage.SEVERITY_INFO,"String_Node_Str","String_Node_Str"));
    initNewMember();
  }
 catch (  Exception e) {
    String errorMessage=getRootErrorMessage(e);
    facesContext.addMessage(null,new FacesMessage(FacesMessage.SEVERITY_ERROR,errorMessage,"String_Node_Str"));
  }
}
Program: 190880
Project: 190880
Buggy source:
public T parse(InputStream is) throws Exception {
  StringBuffer xmlFile=new StringBuffer();
  BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(is));
  String line=null;
  while ((line=bufferedReader.readLine()) != null) {
    xmlFile.append(line);
  }
  String xml=xmlFile.toString();
  try {
    SchemaFactory sf=SchemaFactory.newInstance("String_Node_Str");
    Schema schema=sf.newSchema(schemaURL);
    Validator validator=schema.newValidator();
    Source source=new StreamSource(new CharArrayReader(xml.toCharArray()));
    validator.validate(source);
  }
 catch (  Exception e) {
    e.printStackTrace();
    return null;
  }
  ByteArrayInputStream bais=new ByteArrayInputStream(xml.getBytes());
  T result=parseInternal(bais);
  return result;
}

Fixed version (ground truth):
public T parse(InputStream is) throws Exception {
  StringBuffer xmlFile=new StringBuffer();
  BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(is));
  String line=null;
  while ((line=bufferedReader.readLine()) != null) {
    xmlFile.append(line);
  }
  String xml=xmlFile.toString();
  try {
    SchemaFactory sf=SchemaFactory.newInstance("String_Node_Str");
    Schema schema=sf.newSchema(schemaURL);
    Validator validator=schema.newValidator();
    Source source=new StreamSource(new CharArrayReader(xml.toCharArray()));
    validator.validate(source);
  }
 catch (  Exception e) {
    this.errorHolder.addErrorMessage("String_Node_Str",e);
    return null;
  }
  ByteArrayInputStream bais=new ByteArrayInputStream(xml.getBytes());
  T result=parseInternal(bais);
  return result;
}
Program: 190881
Project: 190881
Buggy source:
/** 
 * Action method invoked from UploadServlet once it parses request with 'multipart/form-data' form data and fetches uploaded file.<br> This method expects file to be passed as   {@link InputStream}.
 * @param stringBuffer
 * @throws IOException
 */
@SuppressWarnings("String_Node_Str") public void parseUpload(InputStream is){
  try {
    this.catalog=this.xmlParser.parse(is);
  }
 catch (  Exception e) {
    errorHolder.addErrorMessage("String_Node_Str",e);
    return;
  }
}

Fixed version (ground truth):
/** 
 * Action method invoked from UploadServlet once it parses request with 'multipart/form-data' form data and fetches uploaded file.<br> This method expects file to be passed as   {@link InputStream}.
 * @param stringBuffer
 * @throws IOException
 */
@SuppressWarnings("String_Node_Str") public void parseUpload(InputStream is){
  try {
    this.errorHolder.clear();
    this.catalog=this.xmlParser.parse(is);
  }
 catch (  Exception e) {
    this.errorHolder.addErrorMessage("String_Node_Str",e);
    return;
  }
}
Program: 190882
Project: 190882
Buggy source:
public void addErrorMessage(String msg,Throwable t){
  Error error=new Error(msg,t);
  this.errorsList.add(error);
}

Fixed version (ground truth):
@Override public void addErrorMessage(String msg,Throwable t){
  Error error=new Error(msg,t);
  this.errorsList.add(error);
}
Program: 190883
Project: 190883
Buggy source:
public int getErrorCount(){
  return this.errorsList.size();
}

Fixed version (ground truth):
@Override public int getErrorCount(){
  return this.errorsList.size();
}
Program: 190884
Project: 190884
Buggy source:
public List<Error> getErrorMessages(){
  return this.errorsList;
}

Fixed version (ground truth):
@Override public List<Error> getErrorMessages(){
  return new ArrayList<Error>(this.errorsList);
}
Program: 190885
Project: 190885
Buggy source:
public String getException(){
  if (this.t != null) {
    ByteArrayOutputStream baos=new ByteArrayOutputStream();
    PrintStream ps=new PrintStream(baos);
    this.t.printStackTrace(ps);
    String stackTrace=new String(baos.toByteArray());
    return stackTrace;
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
public String getException(){
  if (this.t != null) {
    return this.t.getMessage();
  }
  return null;
}
Program: 190886
Project: 190886
Buggy source:
public void setListening(boolean listening){
  if (listening == mBatteryListening) {
    return;
  }
  mBatteryListening=listening;
  if (mBatteryListening) {
    TunerService.get(getContext()).addTunable(this,STATUS_BAR_SHOW_BATTERY_PERCENT);
    mBatteryController.addStateChangedCallback(this);
  }
 else {
    mBatteryController.removeStateChangedCallback(this);
    TunerService.get(getContext()).removeTunable(this);
  }
}

Fixed version (ground truth):
public void setListening(boolean listening){
  if (listening == mBatteryListening) {
    return;
  }
  mBatteryListening=listening;
  if (mBatteryListening) {
    TunerService.get(getContext()).addTunable(this,STATUS_BAR_SHOW_BATTERY_PERCENT,STATUS_BAR_BATTERY_STYLE);
    mBatteryController.addStateChangedCallback(this);
  }
 else {
    mBatteryController.removeStateChangedCallback(this);
    TunerService.get(getContext()).removeTunable(this);
  }
}
Program: 190887
Project: 190887
Buggy source:
@Override public void onTuningChanged(String key,String newValue){
  if (key.equals(STATUS_BAR_SHOW_BATTERY_PERCENT)) {
    mShowBatteryText=newValue == null ? false : Integer.parseInt(newValue) == 2;
    updateVisibilities();
  }
}

Fixed version (ground truth):
@Override public void onTuningChanged(String key,String newValue){
switch (key) {
case STATUS_BAR_SHOW_BATTERY_PERCENT:
    mShowBatteryText=newValue != null && Integer.parseInt(newValue) == 2;
  break;
case STATUS_BAR_BATTERY_STYLE:
if (newValue != null) {
  final int value=Integer.parseInt(newValue);
  if (value == BatteryMeterDrawable.BATTERY_STYLE_TEXT) {
    mForceBatteryText=true;
  }
 else   if (value == BatteryMeterDrawable.BATTERY_STYLE_HIDDEN) {
    mForceBatteryText=false;
  }
 else {
    mForceBatteryText=null;
  }
}
break;
}
updateVisibilities();
}
Program: 190888
Project: 190888
Buggy source:
private void updateVisibilities(){
  if (mMultiUserSwitch.getParent() != this && !mKeyguardUserSwitcherShowing) {
    if (mMultiUserSwitch.getParent() != null) {
      getOverlay().remove(mMultiUserSwitch);
    }
    addView(mMultiUserSwitch,0);
  }
 else   if (mMultiUserSwitch.getParent() == this && mKeyguardUserSwitcherShowing) {
    removeView(mMultiUserSwitch);
  }
  if (mKeyguardUserSwitcher == null) {
    if (mUserSwitcherController != null && mUserSwitcherController.getSwitchableUserCount() > 1) {
      mMultiUserSwitch.setVisibility(View.VISIBLE);
    }
 else {
      mMultiUserSwitch.setVisibility(View.GONE);
    }
  }
  mBatteryLevel.setVisibility(mBatteryCharging || mShowBatteryText ? View.VISIBLE : View.GONE);
}

Fixed version (ground truth):
private void updateVisibilities(){
  if (mMultiUserSwitch.getParent() != this && !mKeyguardUserSwitcherShowing) {
    if (mMultiUserSwitch.getParent() != null) {
      getOverlay().remove(mMultiUserSwitch);
    }
    addView(mMultiUserSwitch,0);
  }
 else   if (mMultiUserSwitch.getParent() == this && mKeyguardUserSwitcherShowing) {
    removeView(mMultiUserSwitch);
  }
  if (mKeyguardUserSwitcher == null) {
    if (mUserSwitcherController != null && mUserSwitcherController.getSwitchableUserCount() > 1) {
      mMultiUserSwitch.setVisibility(View.VISIBLE);
    }
 else {
      mMultiUserSwitch.setVisibility(View.GONE);
    }
  }
  if (mForceBatteryText != null) {
    mBatteryLevel.setVisibility(mForceBatteryText ? View.VISIBLE : View.GONE);
  }
 else {
    mBatteryLevel.setVisibility(mBatteryCharging || mShowBatteryText ? View.VISIBLE : View.GONE);
  }
}