nus-yam/ex-repair huggingface dataset:
Program: 179755
Project: 179755
Buggy source:
private String formatTrack(String source){
  source=source.replaceAll("String_Node_Str","String_Node_Str");
  try {
    Integer.parseInt(source);
  }
 catch (  NumberFormatException ex) {
    source=source.trim();
    return WordUtils.capitalize(source.toLowerCase());
  }
  return null;
}

Fixed version (ground truth):
private String formatTrack(String source){
  source=EncodingConverter.getInstance().convertToUTF8(source);
  source=source.replaceAll("String_Node_Str","String_Node_Str");
  try {
    Integer.parseInt(source);
  }
 catch (  NumberFormatException ex) {
    source=source.trim();
    return WordUtils.capitalize(source.toLowerCase());
  }
  return null;
}
Program: 179756
Project: 179756
Buggy source:
private String formatArtist(String source){
  source.replaceAll("String_Node_Str","String_Node_Str");
  try {
    Integer.parseInt(source);
  }
 catch (  NumberFormatException ex) {
    source=source.trim();
    return source;
  }
  return null;
}

Fixed version (ground truth):
private String formatArtist(String source){
  source=EncodingConverter.getInstance().convertToUTF8(source);
  source.replaceAll("String_Node_Str","String_Node_Str");
  try {
    Integer.parseInt(source);
  }
 catch (  NumberFormatException ex) {
    source=source.trim();
    return source;
  }
  return null;
}
Program: 179757
Project: 179757
Buggy source:
private String formatGenre(String source){
  source=source.replaceAll("String_Node_Str","String_Node_Str");
  try {
    Integer.parseInt(source);
  }
 catch (  NumberFormatException ex) {
    source=source.trim();
    return WordUtils.capitalize(source.toLowerCase()).trim();
  }
  return null;
}

Fixed version (ground truth):
private String formatGenre(String source){
  source=EncodingConverter.getInstance().convertToUTF8(source);
  source=source.replaceAll("String_Node_Str","String_Node_Str");
  try {
    Integer.parseInt(source);
  }
 catch (  NumberFormatException ex) {
    source=source.trim();
    return WordUtils.capitalize(source.toLowerCase()).trim();
  }
  return null;
}
Program: 179758
Project: 179758
Buggy source:
private String formatAlbum(String source){
  source=source.replaceAll("String_Node_Str","String_Node_Str");
  try {
    Integer.parseInt(source);
  }
 catch (  NumberFormatException ex) {
    source=source.trim();
    return WordUtils.capitalize(source.toLowerCase());
  }
  return null;
}

Fixed version (ground truth):
private String formatAlbum(String source){
  source=EncodingConverter.getInstance().convertToUTF8(source);
  source=source.replaceAll("String_Node_Str","String_Node_Str");
  try {
    Integer.parseInt(source);
  }
 catch (  NumberFormatException ex) {
    source=source.trim();
    return WordUtils.capitalize(source.toLowerCase());
  }
  return null;
}
Program: 179759
Project: 179759
Buggy source:
public static void main(String[] args){
  EntityManagerFactory emf=Persistence.createEntityManagerFactory("String_Node_Str");
  EntityManager em=emf.createEntityManager();
  em.getTransaction().begin();
  Query q=em.createNamedQuery("String_Node_Str");
  q.setParameter("String_Node_Str","String_Node_Str");
  Artist mik=(Artist)q.getSingleResult();
  System.out.print("String_Node_Str" + mik.getName() + "String_Node_Str");
  Track t=new Track("String_Node_Str");
  mik.addTrack(t);
  t.setArtist(mik);
  em.persist(mik);
  em.getTransaction().commit();
  em.close();
  emf.close();
}

Fixed version (ground truth):
public static void main(String[] args){
  EntityManagerFactory emf=Persistence.createEntityManagerFactory("String_Node_Str");
  EntityManager em=emf.createEntityManager();
  em.getTransaction().begin();
  Genre gen=new Genre(1111,"String_Node_Str");
  em.persist(gen);
  em.getTransaction().commit();
  em.close();
  emf.close();
}
Program: 179760
Project: 179760
Buggy source:
private void predict(){
  System.out.println("String_Node_Str" + dx + "String_Node_Str"+ dy+ "String_Node_Str"+ dYaw);
  double xDrift, yDrift, dir;
  if (particleList.size() < PARTICLE_TOLERANCE * NUM_PARTICLES) {
    int[] indexCopyList=resample();
    for (int i=0; i < indexCopyList.length; i++) {
      Particle temp=(Particle)particleList.get(i).clone();
      dir=Math.random() - .5;
      xDrift=dir >= 0 ? Math.random() * 5.0 : Math.random() * -5.0;
      dir=Math.random() - .5;
      yDrift=dir >= 0 ? Math.random() * 5.0 : Math.random() * -5.0;
      temp.setX(temp.getX() + xDrift);
      temp.setY(temp.getY() + yDrift);
      if (temp.getX() < 0 || temp.getX() >= map.length || temp.getY() < 0 || temp.getY() >= map[0].length) {
        i--;
        continue;
      }
      double newYaw=Math.random() * 2 * Math.PI - Math.PI;
      temp.setPose(newYaw);
      temp.setWeight(1.0 / NUM_PARTICLES);
      particleList.add(temp);
    }
  }
  int m=particleList.size();
  for (int j=0; j < m; j++) {
    Particle temp=particleList.get(j);
    gmap.clearParticle(temp.getX(),temp.getY());
    double tx=temp.getX() + dx;
    double ty=temp.getY() + dy;
    double tp=temp.getPose() + dYaw;
    if (tp > Math.PI)     tp=tp - 2 * Math.PI;
    if (tp < -1 * Math.PI)     tp=tp + 2 * Math.PI;
    temp.move(tx,ty,tp);
    if (tx < 0 || tx >= map.length || ty < 0 || ty >= map[0].length) {
      temp.setWeight(0.0);
    }
 else     if (map[(int)tx][(int)ty] == 0) {
      temp.setWeight(0.0);
    }
    particleList.set(j,temp);
  }
}

Fixed version (ground truth):
private void predict(){
  System.out.println("String_Node_Str" + dx + "String_Node_Str"+ dy+ "String_Node_Str"+ dYaw);
  double xDrift, yDrift, dir;
  if (particleList.size() < PARTICLE_TOLERANCE * NUM_PARTICLES) {
    int[] indexCopyList=resample();
    for (int i=0; i < indexCopyList.length; i++) {
      Particle temp=(Particle)particleList.get(i).clone();
      dir=Math.random() - .5;
      xDrift=dir >= 0 ? Math.random() * 5.0 : Math.random() * -5.0;
      dir=Math.random() - .5;
      yDrift=dir >= 0 ? Math.random() * 5.0 : Math.random() * -5.0;
      temp.setX(temp.getX() + xDrift);
      temp.setY(temp.getY() + yDrift);
      if (temp.getX() < 0 || temp.getX() >= map.length || temp.getY() < 0 || temp.getY() >= map[0].length) {
        i--;
        continue;
      }
      double newYaw=Math.random() * 2 * Math.PI - Math.PI;
      temp.setPose(newYaw);
      temp.setWeight(1.0 / NUM_PARTICLES);
      particleList.add(temp);
    }
  }
  int m=particleList.size();
  for (int j=0; j < m; j++) {
    Particle temp=particleList.get(j);
    double pose=temp.getPose();
    gmap.clearParticle(temp.getX(),temp.getY());
    double tx=temp.getX() + dist * Math.cos(pose);
    double ty=temp.getY() - dist * Math.sin(pose);
    double tp=pose + dYaw;
    if (tp > Math.PI)     tp=tp - 2 * Math.PI;
    if (tp < -1 * Math.PI)     tp=tp + 2 * Math.PI;
    temp.move(tx,ty,tp);
    if (tx < 0 || tx >= map.length || ty < 0 || ty >= map[0].length) {
      temp.setWeight(0.0);
    }
 else     if (map[(int)tx][(int)ty] == 0) {
      temp.setWeight(0.0);
    }
  }
}
Program: 179761
Project: 179761
Buggy source:
/** 
 * Called by the wanderer to update the localizer with the robot's change in position and pose, as well as the newest sensor dataz
 */
public void receiveUpdate(double dx,double dy,double dYaw,double[] ranges){
  this.dx=dx;
  this.dy=dy;
  this.dYaw=dYaw;
  this.ranges=ranges;
}

Fixed version (ground truth):
/** 
 * Called by the wanderer to update the localizer with the robot's change in position and pose, as well as the newest sensor dataz
 */
public void receiveUpdate(double dx,double dy,double dYaw,double[] ranges){
  this.dx=dx;
  this.dy=dy;
  this.dist=Math.sqrt(dx * dx + dy * dy);
  this.dYaw=dYaw;
  this.ranges=ranges;
}
Program: 179762
Project: 179762
Buggy source:
/** 
 * Kill off bad points
 */
private void killBaddies(){
  int j=0;
  boolean oob=false;
  boolean obs=false;
  while (j < particleList.size()) {
    Particle p=particleList.get(j);
    if (p.getWeight() < .01 / (NUM_PARTICLES * NUM_PARTICLES) || p.getWeight() == 0) {
      oob=(p.getX() >= map.length || p.getY() >= map[0].length);
      oob=(p.getX() < 0 || p.getY() < 0);
      obs=oob ? true : map[(int)p.getX()][(int)p.getY()] == 0;
      if (!obs)       gmap.clearParticle(p.getX(),p.getY());
      particleList.remove(j);
      j--;
    }
    j++;
  }
  particleList.trimToSize();
}

Fixed version (ground truth):
/** 
 * Kill off bad points
 */
private void killBaddies(){
  int j=0;
  boolean oob=false;
  boolean obs=false;
  while (j < particleList.size()) {
    Particle p=particleList.get(j);
    if (p.getWeight() < .01 / (NUM_PARTICLES * NUM_PARTICLES) || p.getWeight() == 0) {
      oob=(p.getX() >= map.length || p.getY() >= map[0].length);
      oob=oob || p.getX() < 0 || p.getY() < 0;
      obs=oob ? true : map[(int)p.getX()][(int)p.getY()] == 0;
      if (!obs)       gmap.clearParticle(p.getX(),p.getY());
      particleList.remove(j);
      j--;
    }
    j++;
  }
  particleList.trimToSize();
}
Program: 179763
Project: 179763
Buggy source:
public synchronized void updateDataz(double x,double y,double yaw,double[] ranges){
  boolean compound=Wanderer.updateReady;
  Wanderer.dx=compound ? Wanderer.dx + this.x - x : this.x - x;
  Wanderer.dy=compound ? Wanderer.dy + this.y - y : this.y - y;
  Wanderer.dyaw=compound ? Wanderer.dyaw + this.yaw - yaw : this.yaw - yaw;
  Wanderer.ranges=ranges;
  Wanderer.updateReady=true;
}

Fixed version (ground truth):
public synchronized void updateDataz(double x,double y,double yaw,double[] ranges){
  boolean compound=Wanderer.updateReady;
  Wanderer.dx=compound ? Wanderer.dx + x - this.x : x - this.x;
  Wanderer.dy=compound ? Wanderer.dy + y - this.y : y - this.y;
  Wanderer.dyaw=compound ? Wanderer.dyaw + this.yaw - yaw : this.yaw - yaw;
  Wanderer.ranges=ranges;
  Wanderer.updateReady=true;
}
Program: 179764
Project: 179764
Buggy source:
public synchronized void updateDataz(double x,double y,double yaw,double[] ranges){
  boolean compound=Wanderer.updateReady;
  Wanderer.dx=compound ? Wanderer.dx + x - this.x : x - this.x;
  Wanderer.dy=compound ? Wanderer.dy + y - this.y : y - this.y;
  Wanderer.dyaw=compound ? Wanderer.dyaw + this.yaw - yaw : this.yaw - yaw;
  Wanderer.ranges=ranges;
  Wanderer.updateReady=true;
}

Fixed version (ground truth):
public synchronized void updateDataz(double x,double y,double yaw,double[] ranges){
  boolean compound=Wanderer.updateReady;
  Wanderer.dx=compound ? Wanderer.dx + x - this.x : x - this.x;
  Wanderer.dy=compound ? Wanderer.dy + y - this.y : y - this.y;
  Wanderer.dyaw=compound ? Wanderer.dyaw + yaw - this.yaw : yaw - this.yaw;
  Wanderer.ranges=ranges;
  Wanderer.updateReady=true;
}
Program: 179765
Project: 179765
Buggy source:
private void predict(){
  System.out.println("String_Node_Str" + dx + "String_Node_Str"+ dy+ "String_Node_Str"+ dYaw);
  if (particleList.size() < PARTICLE_TOLERANCE * NUM_PARTICLES) {
    int[] indexCopyList=resample();
    for (int i=0; i < indexCopyList.length; i++) {
      Particle temp=(Particle)particleList.get(i).clone();
      particleList.add(temp);
    }
  }
  int m=particleList.size();
  for (int j=0; j < m; j++) {
    Particle temp=particleList.get(j);
    gmap.clearParticle(temp.getX(),temp.getY());
    double tx=temp.getX() + dx;
    double ty=temp.getY() + dy;
    double tp=temp.getPose() + dYaw;
    if (tp > Math.PI)     tp=tp - 2 * Math.PI;
    temp.move(tx,ty,tp);
    if (tx < 0 || tx > map.length || ty < 0 || ty > map[0].length) {
      temp.setWeight(0.0);
    }
 else     if (map[(int)tx][(int)ty] == 0) {
      temp.setWeight(0.0);
    }
    particleList.set(j,temp);
  }
}

Fixed version (ground truth):
private void predict(){
  System.out.println("String_Node_Str" + dx + "String_Node_Str"+ dy+ "String_Node_Str"+ dYaw);
  if (particleList.size() < PARTICLE_TOLERANCE * NUM_PARTICLES) {
    int[] indexCopyList=resample();
    for (int i=0; i < indexCopyList.length; i++) {
      Particle temp=(Particle)particleList.get(i).clone();
      temp.setWeight(1 / NUM_PARTICLES);
      particleList.add(temp);
    }
  }
  int m=particleList.size();
  for (int j=0; j < m; j++) {
    Particle temp=particleList.get(j);
    gmap.clearParticle(temp.getX(),temp.getY());
    double tx=temp.getX() + dx;
    double ty=temp.getY() + dy;
    double tp=temp.getPose() + dYaw;
    if (tp > Math.PI)     tp=tp - 2 * Math.PI;
    temp.move(tx,ty,tp);
    if (tx < 0 || tx > map.length || ty < 0 || ty > map[0].length) {
      temp.setWeight(0.0);
    }
 else     if (map[(int)tx][(int)ty] == 0) {
      temp.setWeight(0.0);
    }
    particleList.set(j,temp);
  }
}
Program: 179766
Project: 179766
Buggy source:
/** 
 * Kill off bad points
 */
private void killBaddies(){
  for (  Particle p : particleList) {
    if (p.getWeight() < (1.0 / NUM_PARTICLES)) {
      if (map[(int)p.getX()][(int)p.getY()] != 0)       gmap.clearParticle(p.getX(),p.getY());
      particleList.remove(p);
    }
  }
  particleList.trimToSize();
}

Fixed version (ground truth):
/** 
 * Kill off bad points
 */
private void killBaddies(){
  int j=0;
  for (int i=0; i < particleList.size(); i++) {
    Particle p=particleList.get(i);
    if (p.getWeight() < (1.0 / NUM_PARTICLES)) {
      if (map[(int)p.getX()][(int)p.getY()] != 0)       gmap.clearParticle(p.getX(),p.getY());
      particleList.remove(i);
      j--;
    }
    j++;
  }
  particleList.trimToSize();
}
Program: 179767
Project: 179767
Buggy source:
/** 
 * Create a new Localizer object to be used in a map with the given dimensions. Fills the list of particles with NUM_PARTICLES particles or mapw*maph particles, whichever is smaller. All particles are initalized with equal weight, 1 divided by the number of particles.
 * @param map the map!
 */
public Localizer(int[][] map,GridMap gmap){
}

Fixed version (ground truth):
/** 
 * Create a new Localizer object to be used in a map with the given dimensions. Fills the list of particles with NUM_PARTICLES particles or mapw*maph particles, whichever is smaller. All particles are initalized with equal weight, 1 divided by the number of particles.
 * @param map the map!
 */
public Localizer(int[][] map,GridMap gmap){
  localized=false;
  this.map=map;
  this.gmap=gmap;
  int mapw=map.length;
  int maph=map[0].length;
  int numParticles=(NUM_PARTICLES > mapw * maph) ? mapw * maph : NUM_PARTICLES;
  int ppp=Math.round(mapw * maph / numParticles);
  particleList=new ArrayList<Particle>(numParticles);
  int x=0, y=0;
  double weight=1.0 / numParticles;
  for (int i=0; i < numParticles; i++) {
    if (map[x][y] != 0) {
      particleList.add(i,new Particle(x,y,0,weight));
    }
 else {
      for (int j=1; j < numParticles; j++) {
        if (map[(x + j) % mapw][(x + i) / mapw + y] == 255) {
          particleList.add(i,new Particle((x + j) % mapw,(x + i) / mapw + y,0,weight));
          break;
        }
      }
    }
    x=(x + ppp) % mapw;
    if (x < ppp)     y++;
  }
  expectedLocation=null;
  updateReady=false;
  drawMap();
  gmap.repaint();
}
Program: 179768
Project: 179768
Buggy source:
/** 
 * Checks all the particles to see if any of them are inside an obstacle. This is impossible, so any that it finds get a weight of zero. This ensures that they get wiped out and replaced on the next update.
 */
private void collisionCheck(){
  for (  Particle p : particleList) {
    if (map[p.getX()][p.getY()] == 0)     p.setWeight(0.0);
  }
}

Fixed version (ground truth):
/** 
 * Checks all the particles to see if any of them are inside an obstacle. This is impossible, so any that it finds get a weight of zero. This ensures that they get wiped out and replaced on the next update.
 */
private void collisionCheck(){
  for (  Particle p : particleList) {
    if (map[(int)Math.round(p.getX())][(int)Math.round(p.getY())] == 0)     p.setWeight(0.0);
  }
}
Program: 179769
Project: 179769
Buggy source:
/** 
 * Create a new Localizer object to be used in a map with the given dimensions. Fills the list of particles with NUM_PARTICLES particles or mapw*maph particles, whichever is smaller. All particles are initalized with equal weight, 1 divided by the number of particles.
 * @param map the map!
 */
public Localizer(int[][] map,GridMap gmap){
  localized=false;
  this.map=map;
  this.gmap=gmap;
  int mapw=map.length;
  int maph=map[0].length;
  int numParticles=(NUM_PARTICLES > mapw * maph) ? mapw * maph : NUM_PARTICLES;
  int ppp=Math.round(mapw * maph / numParticles);
  particleList=new ArrayList<Particle>(numParticles);
  int x=0, y=0;
  double weight=1.0 / numParticles;
  for (int i=0; i < numParticles; i++) {
    if (map[x][y] != 0) {
      particleList.add(i,new Particle(x,y,0,weight));
    }
 else {
      for (int j=1; j < numParticles; j++) {
        if (map[(x + j) % mapw][(x + i) / mapw + y] == 255) {
          particleList.add(i,new Particle((x + j) % mapw,(x + i) / mapw + y,0,weight));
          break;
        }
      }
    }
    x=(x + ppp) % mapw;
    if (x < ppp)     y++;
  }
  expectedLocation=null;
  updateReady=false;
  drawMap();
  gmap.repaint();
}

Fixed version (ground truth):
/** 
 * Create a new Localizer object to be used in a map with the given dimensions. Fills the list of particles with NUM_PARTICLES particles or mapw*maph particles, whichever is smaller. All particles are initalized with equal weight, 1 divided by the number of particles.
 * @param map the map!
 */
public Localizer(int[][] map,GridMap gmap){
  localized=false;
  this.map=map;
  this.gmap=gmap;
  int mapw=map.length;
  int maph=map[0].length;
  int numParticles=(NUM_PARTICLES > mapw * maph) ? mapw * maph : NUM_PARTICLES;
  int ppp=Math.round(mapw * maph / numParticles);
  particleList=new ArrayList<Particle>(numParticles);
  int x=0, y=0;
  double weight=1.0 / numParticles;
  for (int i=0; i < numParticles; i++) {
    if (map[x][y] != 0) {
      particleList.add(i,new Particle(x,y,0,weight));
    }
 else {
      for (int j=1; j < numParticles; j++) {
        if (map[(x + j) % mapw][((x + i) / mapw + y) % maph] == 255) {
          particleList.add(i,new Particle((x + j) % mapw,(x + i) / mapw + y,0,weight));
          break;
        }
      }
    }
    x=(x + ppp) % mapw;
    if (x < ppp)     y++;
  }
  expectedLocation=null;
  updateReady=false;
  drawMap();
  gmap.repaint();
  System.out.printf("String_Node_Str",NUM_PARTICLES,particleList.size());
}
Program: 179770
Project: 179770
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  initLayout();
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  initLayout();
  isExternalStorageAvailable=Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState());
  if (!isExternalStorageAvailable) {
    new Alerts(this,R.string.imagehelper_sdcard_unavailable).showAlert();
  }
}
Program: 179771
Project: 179771
Buggy source:
@Override public boolean onKeyDown(int keyCode,KeyEvent event){
  if (keyCode == KeyEvent.KEYCODE_BACK) {
    if (!m_order.orderItems.isEmpty()) {
      new Alerts(this).showAlert();
    }
 else {
      finish();
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean onKeyDown(int keyCode,KeyEvent event){
  if (keyCode == KeyEvent.KEYCODE_BACK) {
    if (!m_order.orderItems.isEmpty()) {
      new Alerts(this,R.string.alters_confirm_delete).showAlert();
    }
 else {
      finish();
    }
  }
  return true;
}
Program: 179772
Project: 179772
Buggy source:
public Alerts(Context context){
  m_context=context;
}

Fixed version (ground truth):
public Alerts(Context context,int messageType){
  m_context=context;
  m_messageType=messageType;
  initAlerts();
}
Program: 179773
Project: 179773
Buggy source:
public void showAlert(){
  Resources r=m_context.getResources();
  AlertDialog.Builder builderDialog=new AlertDialog.Builder(m_context);
  builderDialog.setMessage(r.getString(R.string.alters_confirm_delete));
  builderDialog.setCancelable(true);
  builderDialog.setPositiveButton(r.getString(R.string.yes),new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface arg0,    int arg1){
      ((Activity)m_context).finish();
    }
  }
);
  builderDialog.setNegativeButton(r.getString(R.string.no),new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface arg0,    int arg1){
      arg0.dismiss();
    }
  }
);
  AlertDialog alert=builderDialog.create();
  alert.show();
}

Fixed version (ground truth):
public void showAlert(){
  AlertDialog alert=builderDialog.create();
  alert.show();
}
Program: 179774
Project: 179774
Buggy source:
@Override protected File doInBackground(Void... arg0){
  File file=ImageHelper.getCachedFileUnchecked(imageUrl);
  if (Environment.MEDIA_MOUNTED.equals(packageDirectory)) {
    if (file != null && file.exists() == false) {
      ImageHelper.packageDirectory.mkdirs();
      try {
        InputStream in=HttpHelper.getRaw(imageUrl);
        FileOutputStream out=new FileOutputStream(file);
        byte[] buffer=new byte[4096];
        int bufferTemp=0;
        while ((bufferTemp=in.read(buffer)) > 0) {
          out.write(buffer,0,bufferTemp);
        }
        out.close();
      }
 catch (      IOException e) {
        e.printStackTrace();
      }
    }
    ImageHelper.m_cachedFiles.put(imageUrl,file);
    Log.i(FdConfig.DEBUG_TAG,"String_Node_Str" + file);
    return file;
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
@Override protected File doInBackground(Void... arg0){
  File file=ImageHelper.getCachedFileUnchecked(imageUrl);
  if (file != null && file.exists() == false) {
    ImageHelper.packageDirectory.mkdirs();
    try {
      InputStream in=HttpHelper.getRaw(imageUrl);
      FileOutputStream out=new FileOutputStream(file);
      byte[] buffer=new byte[4096];
      int bufferTemp=0;
      while ((bufferTemp=in.read(buffer)) > 0) {
        out.write(buffer,0,bufferTemp);
      }
      out.close();
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
  ImageHelper.m_cachedFiles.put(imageUrl,file);
  return file;
}
Program: 179775
Project: 179775
Buggy source:
/** 
 * Does various things to make sure user is logged in and has the proper permissions. At first it will check for previously logged in information. And then it tries to do an auto login. If the auto login request is sent, it will also stop (the auto login procedure will trigger another call to this method once it's done). If the auto login request wasn't sent, a verification request will set sent to entry-point/user-info. If the server validates our information, that's good news. Otherwise, it will display and error message and / or show a   {@link LoginDialog} and letuser identify himself / herself.
 * @see #doAutoLogin()
 */
protected void requireLoggedIn(){
  setLayoutEnabled();
  if (m_user.isLoggedIn()) {
    return;
  }
  if (doAutoLogin()) {
    return;
  }
  new HttpRequestAsyncTask(this,UriStringHelper.buildUriString("String_Node_Str")){
    @Override protected void onSuccess(    JSONObject jsonObject,    Object processed){
      try {
        JSONObject user=jsonObject.getJSONObject("String_Node_Str");
        m_user.parse(user);
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
      if (!m_user.isLoggedIn()) {
        showLoginDialog();
      }
 else {
        Toast.makeText(Main.this,getString(R.string.welcome_back,m_user.username),Toast.LENGTH_SHORT).show();
        setLayoutEnabled();
        syncSuggestion();
      }
    }
    @Override protected void onError(    JSONObject jsonObject,    String message){
      showLoginDialog();
    }
  }
.execute();
}

Fixed version (ground truth):
/** 
 * Does various things to make sure user is logged in and has the proper permissions. At first it will check for previously logged in information. And then it tries to do an auto login. If the auto login request is sent, it will also stop (the auto login procedure will trigger another call to this method once it's done). If the auto login request wasn't sent, a verification request will set sent to entry-point/user-info. If the server validates our information, that's good news. Otherwise, it will display and error message and / or show a   {@link LoginDialog} and letuser identify himself / herself.
 * @see #doAutoLogin()
 */
protected void requireLoggedIn(){
  setLayoutEnabled();
  if (m_user.isLoggedIn()) {
    return;
  }
  if (doAutoLogin()) {
    return;
  }
  new HttpRequestAsyncTask(this,UriStringHelper.buildUriString("String_Node_Str")){
    @Override protected void onSuccess(    JSONObject jsonObject,    Object processed){
      try {
        JSONObject user=jsonObject.getJSONObject("String_Node_Str");
        m_user.parse(user);
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
      if (!m_user.isLoggedIn()) {
        showLoginDialog();
      }
 else {
        Toast.makeText(Main.this,getString(R.string.welcome_back,m_user.username),Toast.LENGTH_SHORT).show();
        isExternalStorageAvailable();
        setLayoutEnabled();
        syncSuggestion();
      }
    }
    @Override protected void onError(    JSONObject jsonObject,    String message){
      showLoginDialog();
    }
  }
.execute();
}
Program: 179776
Project: 179776
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  initLayout();
  isExternalStorageAvailable=Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState());
  if (!isExternalStorageAvailable) {
    new Alerts(this,R.string.imagehelper_sdcard_unavailable).showAlert();
  }
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  initLayout();
}
Program: 179777
Project: 179777
Buggy source:
protected void initAlerts(){
  builderDialog=new AlertDialog.Builder(m_context);
  builderDialog.setCancelable(false);
switch (m_messageType) {
case R.string.alters_confirm_delete:
    Resources r=m_context.getResources();
  builderDialog.setMessage(R.string.alters_confirm_delete);
builderDialog.setPositiveButton(R.string.yes,new DialogInterface.OnClickListener(){
  @Override public void onClick(  DialogInterface arg0,  int arg1){
    ((Activity)m_context).finish();
  }
}
);
builderDialog.setNegativeButton(R.string.no,new DialogInterface.OnClickListener(){
@Override public void onClick(DialogInterface arg0,int arg1){
  arg0.dismiss();
}
}
);
break;
case R.string.imagehelper_sdcard_unavailable:
builderDialog.setMessage(R.string.imagehelper_sdcard_unavailable);
builderDialog.setPositiveButton(R.string.ok,new DialogInterface.OnClickListener(){
@Override public void onClick(DialogInterface arg0,int arg1){
arg0.dismiss();
}
}
);
}
}

Fixed version (ground truth):
protected void initAlerts(){
  builderDialog=new AlertDialog.Builder(m_context);
  builderDialog.setCancelable(false);
  builderDialog.setMessage(R.string.alters_confirm_delete);
  builderDialog.setPositiveButton(R.string.yes,new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface arg0,    int arg1){
      ((Activity)m_context).finish();
    }
  }
);
  builderDialog.setNegativeButton(R.string.no,new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface arg0,    int arg1){
      arg0.dismiss();
    }
  }
);
}
Program: 179778
Project: 179778
Buggy source:
@Override protected void onSuccess(File cachedFile){
  if (cachedFile != null) {
    setImage(cachedFile);
  }
 else {
    Toast.makeText(m_context,R.string.imagehelper_sdcard_unavailable,Toast.LENGTH_LONG);
  }
}

Fixed version (ground truth):
@Override protected void onSuccess(File cachedFile){
  setImage(cachedFile);
}
Program: 179779
Project: 179779
Buggy source:
public int getQuantity(){
  try {
    return Integer.valueOf(m_vwQuantity.getText().toString());
  }
 catch (  NumberFormatException e) {
    e.printStackTrace();
  }
  return 0;
}

Fixed version (ground truth):
public int getQuantity(){
  try {
    int quantity=Integer.valueOf(m_vwQuantity.getText().toString());
    if (quantity > 50) {
      quantity=50;
    }
    return quantity;
  }
 catch (  NumberFormatException e) {
    e.printStackTrace();
  }
  return 0;
}
Program: 179780
Project: 179780
Buggy source:
@Override public void onClick(View v){
switch (v.getId()) {
case R.id.btnSet:
    if (getQuantity() < 0) {
      Toast.makeText(getContext(),R.string.quantityselectordialog_please_enter_a_valid_quantity,Toast.LENGTH_SHORT);
      m_vwQuantity.requestFocus();
    }
 else {
      dismiss();
    }
  break;
case R.id.btnPlus:
quantity+=1;
m_vwQuantity.setText(String.valueOf(quantity));
break;
case R.id.btnSubtract:
quantity-=1;
if (quantity >= 0) {
m_vwQuantity.setText(String.valueOf(quantity));
}
break;
case R.id.btnCancel:
quantity=oldQuantity;
dismiss();
break;
}
}

Fixed version (ground truth):
@Override public void onClick(View v){
switch (v.getId()) {
case R.id.btnSet:
    if (getQuantity() < 0) {
      Toast.makeText(getContext(),R.string.quantityselectordialog_please_enter_a_valid_quantity,Toast.LENGTH_SHORT);
      m_vwQuantity.requestFocus();
    }
 else {
      dismiss();
    }
  break;
case R.id.btnPlus:
quantity+=1;
m_vwQuantity.setText(String.valueOf(quantity));
break;
case R.id.btnSubtract:
if (quantity > 0) {
quantity-=1;
}
 else {
quantity=0;
}
m_vwQuantity.setText(String.valueOf(quantity));
break;
case R.id.btnCancel:
quantity=oldQuantity;
dismiss();
break;
}
}
Program: 179781
Project: 179781
Buggy source:
@Override public void onClick(View v){
switch (v.getId()) {
case R.id.btnSet:
    if (getQuantity() == 0) {
      Toast.makeText(getContext(),R.string.quantityselectordialog_please_enter_a_valid_quantity,Toast.LENGTH_SHORT);
      m_vwQuantity.requestFocus();
    }
 else {
      dismiss();
    }
  break;
case R.id.btnPlus:
quantity+=1;
m_vwQuantity.setText(String.valueOf(quantity));
break;
case R.id.btnSubtract:
quantity-=1;
if (quantity >= 0) m_vwQuantity.setText(String.valueOf(quantity));
break;
case R.id.btnCancel:
quantity=oldQuantity;
cancelled=true;
dismiss();
break;
}
}

Fixed version (ground truth):
@Override public void onClick(View v){
switch (v.getId()) {
case R.id.btnSet:
    if (getQuantity() == 0) {
      Toast.makeText(getContext(),R.string.quantityselectordialog_please_enter_a_valid_quantity,Toast.LENGTH_SHORT);
      m_vwQuantity.requestFocus();
    }
 else {
      dismiss();
    }
  break;
case R.id.btnPlus:
quantity+=1;
m_vwQuantity.setText(String.valueOf(quantity));
break;
case R.id.btnSubtract:
if (quantity > 0) {
quantity-=1;
}
 else {
quantity=0;
}
m_vwQuantity.setText(String.valueOf(quantity));
break;
case R.id.btnCancel:
quantity=oldQuantity;
cancelled=true;
dismiss();
break;
}
}
Program: 179782
Project: 179782
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  initLayout();
  initListeners();
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  initLayout();
  initListeners();
  initDb();
}
Program: 179783
Project: 179783
Buggy source:
@Override public void onPause(){
  super.onPause();
  closeDb();
}

Fixed version (ground truth):
@Override public void onPause(){
  super.onPause();
}
Program: 179784
Project: 179784
Buggy source:
@Override public void onResume(){
  super.onResume();
  initDb();
}

Fixed version (ground truth):
@Override public void onResume(){
  super.onResume();
}
Program: 179785
Project: 179785
Buggy source:
@Override public void microTick(){
  if (nextTick == null || distance == -1) {
    return;
  }
  Location l=what.getLocation();
  double rotation=Math.atan2(l.getY() - nextTick.getY(),l.getX() - nextTick.getX());
  int x=l.getX();
  int y=l.getY();
  x+=(Math.sin(Math.PI / 2 - rotation) * distance) * -1;
  y+=(Math.cos(Math.PI / 2 - rotation) * distance) * -1;
  what.setLocation(x,y);
  if (what.getLocation().getDist(nextTick) < what.radius) {
    distance=-1;
  }
}

Fixed version (ground truth):
@Override public void microTick(){
  if (nextTick == null || turn > 10) {
    System.out.println("String_Node_Str");
    return;
  }
  int x=what.getLocation().getX();
  int y=what.getLocation().getY();
  Location loc=new Location(null,nextTick.getX(),nextTick.getY());
  double rotation=Math.atan2(loc.getY() - nextTick.getY(),loc.getX() - nextTick.getX());
  distance=loc.getDist(what.getLocation()) / 10 * turn;
  x+=((Math.sin(Math.PI / 2 - rotation) * distance) / 10) * -1;
  y+=((Math.cos(Math.PI / 2 - rotation) * distance) / 10) * -1;
  what.setLocation(x,y);
  turn++;
}
Program: 179786
Project: 179786
Buggy source:
@Override public void run(){
  if (jumps.isEmpty()) {
    return;
  }
  nextTick=jumps.poll();
  what.setLocation(nextTick);
  if (jumps != null) {
    return;
  }
  System.err.println("String_Node_Str");
  if (nextTick != null) {
    what.setLocation(nextTick);
  }
  int maxDist=what.getProperty("String_Node_Str");
  Location l=what.getLocation();
  double rotation=Math.atan2(l.getY() - where.getY(),l.getX() - where.getX());
  System.out.print("String_Node_Str" + rotation);
  what.rotateTo(Math.toDegrees(rotation));
  int x=l.getX();
  int y=l.getY();
  if (l.getDist(where) > maxDist) {
    x+=(Math.sin(Math.PI / 2 - rotation) * maxDist) * -1;
    y+=(Math.cos(Math.PI / 2 - rotation) * maxDist) * -1;
  }
 else {
    System.out.println("String_Node_Str");
    x=where.getX();
    y=where.getY();
  }
  nextTick=new Location(null,x,y);
  distance=l.getDist(nextTick) / 10.0;
}

Fixed version (ground truth):
@Override public void run(){
  if (jumps.isEmpty()) {
    return;
  }
  turn=1;
  nextTick=jumps.poll();
  System.out.println("String_Node_Str" + nextTick);
  double rotation=Math.atan2(what.getLocation().getY() - nextTick.getY(),what.getLocation().getX() - nextTick.getX());
  what.rotateTo(Math.toDegrees(rotation));
  what.setLocation(nextTick);
  if (jumps != null) {
    return;
  }
}
Program: 179787
Project: 179787
Buggy source:
public MoveEvent(Asset what,Point where){
  this.what=what;
  this.where=new Location(what.getLocation().getSector(),where.x,where.y);
  jumps=new LinkedList<Location>();
  int maxDist=what.getProperty("String_Node_Str");
  Location l=what.getLocation();
  double rotation=Math.atan2(l.getY() - where.getY(),l.getX() - where.getX());
  int x=l.getX();
  int y=l.getY();
  Location prev=new Location(null,600,600);
  while (prev.getDist(l) >= maxDist) {
    x+=(Math.sin(Math.PI / 2 - rotation) * maxDist) * -1;
    y+=(Math.cos(Math.PI / 2 - rotation) * maxDist) * -1;
    prev=new Location(null,x,y);
    jumps.add(prev);
  }
}

Fixed version (ground truth):
public MoveEvent(Asset what,Point where){
  this.turn=1;
  this.what=what;
  this.where=new Location(what.getLocation().getSector(),where.x,where.y);
  jumps=new LinkedList<Location>();
  int maxDist=what.getProperty("String_Node_Str");
  System.out.println("String_Node_Str" + where);
  System.out.println("String_Node_Str" + maxDist);
  Location l=what.getLocation();
  double rotation=Math.atan2(l.getY() - where.getY(),l.getX() - where.getX());
  int x=l.getX();
  int y=l.getY();
  Location prev;
  do {
    x+=(Math.sin(Math.PI / 2 - rotation) * maxDist) * -1;
    y+=(Math.cos(Math.PI / 2 - rotation) * maxDist) * -1;
    prev=new Location(null,x,y);
    jumps.add(prev);
  }
 while (prev.getDist(l) >= maxDist && prev.getDist(this.where) > maxDist);
}
Program: 179788
Project: 179788
Buggy source:
@Override public String getDescription(){
  return "String_Node_Str" + where;
}

Fixed version (ground truth):
@Override public String getDescription(){
  String jstr="String_Node_Str";
  if (jumps.size() != 1) {
    jstr="String_Node_Str" + jumps.size() + "String_Node_Str";
  }
  return "String_Node_Str" + where + jstr;
}
Program: 179789
Project: 179789
Buggy source:
private boolean checkItemPlacement(ItemInfo occupied[][][],ItemInfo item){
  for (int x=item.cellX; x < (item.cellX + item.spanX); x++) {
    for (int y=item.cellY; y < (item.cellY + item.spanY); y++) {
      if (occupied[item.screen][x][y] != null) {
        Log.e(TAG,"String_Node_Str" + item + "String_Node_Str"+ item.screen+ "String_Node_Str"+ x+ "String_Node_Str"+ y+ "String_Node_Str"+ occupied[item.screen][x][y]);
        return false;
      }
    }
  }
  for (int x=item.cellX; x < (item.cellX + item.spanX); x++) {
    for (int y=item.cellY; y < (item.cellY + item.spanY); y++) {
      occupied[item.screen][x][y]=item;
    }
  }
  return true;
}

Fixed version (ground truth):
private boolean checkItemPlacement(ItemInfo occupied[][][],ItemInfo item){
  if (item.container != LauncherSettings.Favorites.CONTAINER_DESKTOP) {
    return true;
  }
  for (int x=item.cellX; x < (item.cellX + item.spanX); x++) {
    for (int y=item.cellY; y < (item.cellY + item.spanY); y++) {
      if (occupied[item.screen][x][y] != null) {
        Log.e(TAG,"String_Node_Str" + item + "String_Node_Str"+ item.screen+ "String_Node_Str"+ x+ "String_Node_Str"+ y+ "String_Node_Str"+ occupied[item.screen][x][y]);
        return false;
      }
    }
  }
  for (int x=item.cellX; x < (item.cellX + item.spanX); x++) {
    for (int y=item.cellY; y < (item.cellY + item.spanY); y++) {
      occupied[item.screen][x][y]=item;
    }
  }
  return true;
}
Program: 179790
Project: 179790
Buggy source:
@Override protected void setChildrenDrawingCacheEnabled(boolean enabled){
  final int count=getChildCount();
  for (int i=0; i < count; i++) {
    final View view=getChildAt(i);
    view.setDrawingCacheEnabled(enabled);
    view.buildDrawingCache(false);
  }
}

Fixed version (ground truth):
@Override protected void setChildrenDrawingCacheEnabled(boolean enabled){
  final int count=getChildCount();
  for (int i=0; i < count; i++) {
    final View view=getChildAt(i);
    view.setDrawingCacheEnabled(enabled);
    view.buildDrawingCache(true);
  }
}
Program: 179793
Project: 179793
Buggy source:
/** 
 * Initializes various states for this workspace.
 */
private void initWorkspace(){
  Context context=getContext();
  mScroller=new Scroller(context,new OvershootInterpolator());
  mCurrentScreen=mDefaultScreen;
  Launcher.setScreen(mCurrentScreen);
  LauncherApplication app=(LauncherApplication)context.getApplicationContext();
  mIconCache=app.getIconCache();
  final ViewConfiguration configuration=ViewConfiguration.get(getContext());
  mTouchSlop=configuration.getScaledTouchSlop();
  mPagingTouchSlop=configuration.getScaledPagingTouchSlop();
  mMaximumVelocity=configuration.getScaledMaximumFlingVelocity();
}

Fixed version (ground truth):
/** 
 * Initializes various states for this workspace.
 */
private void initWorkspace(){
  Context context=getContext();
  mScrollInterpolator=new WorkspaceOvershootInterpolator();
  mScroller=new Scroller(context,mScrollInterpolator);
  mCurrentScreen=mDefaultScreen;
  Launcher.setScreen(mCurrentScreen);
  LauncherApplication app=(LauncherApplication)context.getApplicationContext();
  mIconCache=app.getIconCache();
  final ViewConfiguration configuration=ViewConfiguration.get(getContext());
  mTouchSlop=configuration.getScaledTouchSlop();
  mPagingTouchSlop=configuration.getScaledPagingTouchSlop();
  mMaximumVelocity=configuration.getScaledMaximumFlingVelocity();
}
Program: 179794
Project: 179794
Buggy source:
void snapToScreen(int whichScreen){
  whichScreen=Math.max(0,Math.min(whichScreen,getChildCount() - 1));
  clearVacantCache();
  enableChildrenCache(mCurrentScreen,whichScreen);
  final int screenDelta=Math.abs(whichScreen - mCurrentScreen);
  mNextScreen=whichScreen;
  mPreviousIndicator.setLevel(mNextScreen);
  mNextIndicator.setLevel(mNextScreen);
  View focusedChild=getFocusedChild();
  if (focusedChild != null && screenDelta != 0 && focusedChild == getChildAt(mCurrentScreen)) {
    focusedChild.clearFocus();
  }
  final int newX=whichScreen * getWidth();
  final int delta=newX - mScrollX;
  final int duration=screenDelta != 0 ? screenDelta * 300 : 300;
  awakenScrollBars(duration);
  if (!mScroller.isFinished())   mScroller.abortAnimation();
  mScroller.startScroll(mScrollX,0,delta,0,duration);
  invalidate();
}

Fixed version (ground truth):
void snapToScreen(int whichScreen){
  whichScreen=Math.max(0,Math.min(whichScreen,getChildCount() - 1));
  clearVacantCache();
  enableChildrenCache(mCurrentScreen,whichScreen);
  final int screenDelta=Math.abs(whichScreen - mCurrentScreen);
  mNextScreen=whichScreen;
  mPreviousIndicator.setLevel(mNextScreen);
  mNextIndicator.setLevel(mNextScreen);
  View focusedChild=getFocusedChild();
  if (focusedChild != null && screenDelta != 0 && focusedChild == getChildAt(mCurrentScreen)) {
    focusedChild.clearFocus();
  }
  final int newX=whichScreen * getWidth();
  final int delta=newX - mScrollX;
  final int duration=screenDelta != 0 ? 200 + screenDelta * 100 : 300;
  awakenScrollBars(duration);
  if (!mScroller.isFinished())   mScroller.abortAnimation();
  mScrollInterpolator.setDistance(screenDelta);
  mScroller.startScroll(mScrollX,0,delta,0,duration);
  invalidate();
}
Program: 179795
Project: 179795
Buggy source:
public void run(){
  mPosX=((float)mData[0]) / (1 << 16);
  mVelocity=((float)mData[1]) / (1 << 16);
  mZoom=((float)mData[2]) / (1 << 16);
  mZoomDirty=false;
}

Fixed version (ground truth):
public void run(){
  mRollo.mScrollPos=((float)mData[0]) / (1 << 16);
  mVelocity=((float)mData[1]) / (1 << 16);
  mZoom=((float)mData[2]) / (1 << 16);
  mZoomDirty=false;
}
Program: 179796
Project: 179796
Buggy source:
private boolean checkClickOK(){
  return (Math.abs(mAllApps.mVelocity) < 0.4f) && (Math.abs(mAllApps.mPosX - Math.round(mAllApps.mPosX)) < 0.4f);
}

Fixed version (ground truth):
private boolean checkClickOK(){
  return (Math.abs(mAllApps.mVelocity) < 0.4f) && (Math.abs(mScrollPos - Math.round(mScrollPos)) < 0.4f);
}
Program: 179797
Project: 179797
Buggy source:
private void gainFocus(){
  if (!mArrowNavigation && mRollo.mState.iconCount > 0) {
    mArrowNavigation=true;
    mRollo.selectIcon(Math.round(mPosX) * mColumnsPerPage,SELECTED_FOCUSED);
    mRollo.mState.save();
  }
}

Fixed version (ground truth):
private void gainFocus(){
  if (!mArrowNavigation && mRollo.mState.iconCount > 0) {
    mArrowNavigation=true;
    mRollo.selectIcon(Math.round(mRollo.mScrollPos) * mColumnsPerPage,SELECTED_FOCUSED);
    mRollo.mState.save();
  }
}
Program: 179800
Project: 179800
Buggy source:
int chooseTappedIcon(int x,int y,float pos){
  y+=(pos - ((int)pos)) * (mTouchYBorders[1] - mTouchYBorders[0]);
  int col=-1;
  int row=-1;
  final int columnsCount=mAllApps.mColumnsPerPage;
  for (int i=0; i < columnsCount; i++) {
    if (x >= mTouchXBorders[i] && x < mTouchXBorders[i + 1]) {
      col=i;
      break;
    }
  }
  final int rowsCount=mAllApps.mRowsPerPage;
  for (int i=0; i < rowsCount; i++) {
    if (y >= mTouchYBorders[i] && y < mTouchYBorders[i + 1]) {
      row=i;
      break;
    }
  }
  if (row < 0 || col < 0) {
    return -1;
  }
  int index=(((int)pos) * columnsCount) + (row * columnsCount) + col;
  if (index >= mState.iconCount) {
    return -1;
  }
 else {
    return index;
  }
}

Fixed version (ground truth):
int chooseTappedIcon(int x,int y){
  float pos=mScrollPos;
  y+=(pos - ((int)pos)) * (mTouchYBorders[1] - mTouchYBorders[0]);
  int col=-1;
  int row=-1;
  final int columnsCount=mAllApps.mColumnsPerPage;
  for (int i=0; i < columnsCount; i++) {
    if (x >= mTouchXBorders[i] && x < mTouchXBorders[i + 1]) {
      col=i;
      break;
    }
  }
  final int rowsCount=mAllApps.mRowsPerPage;
  for (int i=0; i < rowsCount; i++) {
    if (y >= mTouchYBorders[i] && y < mTouchYBorders[i + 1]) {
      row=i;
      break;
    }
  }
  if (row < 0 || col < 0) {
    return -1;
  }
  int index=(((int)pos) * columnsCount) + (row * columnsCount) + col;
  if (index >= mState.iconCount) {
    return -1;
  }
 else {
    return index;
  }
}
Program: 179801
Project: 179801
Buggy source:
@Override public void onWindowFocusChanged(boolean hasWindowFocus){
  super.onWindowFocusChanged(hasWindowFocus);
  if (mSurrendered)   return;
  if (mArrowNavigation) {
    if (!hasWindowFocus) {
      mLastSelectedIcon=mRollo.mState.selectedIconIndex;
      mRollo.setHomeSelected(SELECTED_NONE);
      mRollo.clearSelectedIcon();
      mRollo.mState.save();
    }
 else {
      if (mRollo.mState.iconCount > 0) {
        if (mLastSelection == SELECTION_ICONS) {
          int selection=mLastSelectedIcon;
          final int firstIcon=Math.round(mPosX) * mColumnsPerPage;
          if (selection < 0 || selection < firstIcon || selection >= mRollo.mState.iconCount || selection >= firstIcon + (mColumnsPerPage * mRowsPerPage)) {
            selection=firstIcon;
          }
          mRollo.selectIcon(selection,SELECTED_FOCUSED);
          mRollo.mState.save();
        }
 else         if (mLastSelection == SELECTION_HOME) {
          mRollo.setHomeSelected(SELECTED_FOCUSED);
          mRollo.mState.save();
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override public void onWindowFocusChanged(boolean hasWindowFocus){
  super.onWindowFocusChanged(hasWindowFocus);
  if (mSurrendered)   return;
  if (mArrowNavigation) {
    if (!hasWindowFocus) {
      mLastSelectedIcon=mRollo.mState.selectedIconIndex;
      mRollo.setHomeSelected(SELECTED_NONE);
      mRollo.clearSelectedIcon();
      mRollo.mState.save();
    }
 else {
      if (mRollo.mState.iconCount > 0) {
        if (mLastSelection == SELECTION_ICONS) {
          int selection=mLastSelectedIcon;
          final int firstIcon=Math.round(mRollo.mScrollPos) * mColumnsPerPage;
          if (selection < 0 || selection < firstIcon || selection >= mRollo.mState.iconCount || selection >= firstIcon + (mColumnsPerPage * mRowsPerPage)) {
            selection=firstIcon;
          }
          mRollo.selectIcon(selection,SELECTED_FOCUSED);
          mRollo.mState.save();
        }
 else         if (mLastSelection == SELECTION_HOME) {
          mRollo.setHomeSelected(SELECTED_FOCUSED);
          mRollo.mState.save();
        }
      }
    }
  }
}
Program: 179802
Project: 179802
Buggy source:
public void dumpState(){
  Log.d(TAG,"String_Node_Str" + mRS);
  Log.d(TAG,"String_Node_Str" + mRollo);
  ApplicationInfo.dumpApplicationInfoList(TAG,"String_Node_Str",mAllAppsList);
  Log.d(TAG,"String_Node_Str" + mArrowNavigation);
  Log.d(TAG,"String_Node_Str" + mStartedScrolling);
  Log.d(TAG,"String_Node_Str" + mLastSelection);
  Log.d(TAG,"String_Node_Str" + mLastSelectedIcon);
  Log.d(TAG,"String_Node_Str" + mVelocityTracker);
  Log.d(TAG,"String_Node_Str" + mTouchTracking);
  Log.d(TAG,"String_Node_Str" + mShouldGainFocus);
  Log.d(TAG,"String_Node_Str" + mZoomDirty);
  Log.d(TAG,"String_Node_Str" + mAnimateNextZoom);
  Log.d(TAG,"String_Node_Str" + mZoom);
  Log.d(TAG,"String_Node_Str" + mPosX);
  Log.d(TAG,"String_Node_Str" + mVelocity);
  Log.d(TAG,"String_Node_Str" + mMessageProc);
  if (mRollo != null) {
    mRollo.dumpState();
  }
  if (mRS != null) {
    mRS.contextDump(0);
  }
}

Fixed version (ground truth):
public void dumpState(){
  Log.d(TAG,"String_Node_Str" + mRS);
  Log.d(TAG,"String_Node_Str" + mRollo);
  ApplicationInfo.dumpApplicationInfoList(TAG,"String_Node_Str",mAllAppsList);
  Log.d(TAG,"String_Node_Str" + mArrowNavigation);
  Log.d(TAG,"String_Node_Str" + mStartedScrolling);
  Log.d(TAG,"String_Node_Str" + mLastSelection);
  Log.d(TAG,"String_Node_Str" + mLastSelectedIcon);
  Log.d(TAG,"String_Node_Str" + mVelocityTracker);
  Log.d(TAG,"String_Node_Str" + mTouchTracking);
  Log.d(TAG,"String_Node_Str" + mShouldGainFocus);
  Log.d(TAG,"String_Node_Str" + mZoomDirty);
  Log.d(TAG,"String_Node_Str" + mAnimateNextZoom);
  Log.d(TAG,"String_Node_Str" + mZoom);
  Log.d(TAG,"String_Node_Str" + mRollo.mScrollPos);
  Log.d(TAG,"String_Node_Str" + mVelocity);
  Log.d(TAG,"String_Node_Str" + mMessageProc);
  if (mRollo != null) {
    mRollo.dumpState();
  }
  if (mRS != null) {
    mRS.contextDump(0);
  }
}
Program: 179803
Project: 179803
Buggy source:
@Override public void surfaceDestroyed(SurfaceHolder holder){
  super.surfaceDestroyed(holder);
  mRS.mMessageCallback=null;
}

Fixed version (ground truth):
@Override public void surfaceDestroyed(SurfaceHolder holder){
  super.surfaceDestroyed(holder);
  mRS.mMessageCallback=null;
  mZoomDirty=true;
  mHaveSurface=false;
}
Program: 179804
Project: 179804
Buggy source:
void dirtyCheck(){
  if (mZoomDirty) {
    setZoom(mZoom,mAnimateNextZoom);
  }
}

Fixed version (ground truth):
void dirtyCheck(){
  if (mZoomDirty) {
    setZoom(mNextZoom,mAnimateNextZoom);
  }
}