nus-yam/ex-repair huggingface dataset:
Program: 1502
Project: 1502
Buggy source:
@Override public void sync(String name) throws IOException {
  File file=_localFileCache.getLocalFile(_dirName,name);
  Path dest=new Path(hdfsDirPath,name + "String_Node_Str");
  Path source=new Path(file.getAbsolutePath());
  int count=0;
  while (true) {
    try {
      LOG.debug("String_Node_Str",file.getAbsolutePath(),hdfsDirPath);
      fileSystem.copyFromLocalFile(source,dest);
      rename(name + "String_Node_Str",name);
      return;
    }
 catch (    IOException e) {
      if (count < _retryCount) {
        count++;
        LOG.error("String_Node_Str",e,count,source,dest);
      }
 else {
        throw e;
      }
    }
  }
}

Fixed version (ground truth):
@Override public void sync(String name) throws IOException {
  File file=_localFileCache.getLocalFile(_dirName,name);
  int count=0;
  while (true) {
    Path dest=new Path(hdfsDirPath,name + "String_Node_Str" + count);
    try {
      LOG.debug("String_Node_Str",file.getAbsolutePath(),hdfsDirPath);
      FSDataOutputStream outputStream=fileSystem.create(dest);
      InputStream inputStream=new BufferedInputStream(new FileInputStream(file));
      byte[] buffer=new byte[4096];
      int num;
      while ((num=inputStream.read(buffer)) != -1) {
        outputStream.write(buffer,0,num);
        _progressable.progress();
      }
      rename(name + "String_Node_Str" + count,name);
      return;
    }
 catch (    IOException e) {
      if (count < _retryCount) {
        LOG.error("String_Node_Str",e,count,file.getAbsolutePath(),dest);
        count++;
        try {
          fileSystem.delete(dest,false);
        }
 catch (        IOException ex) {
          LOG.error("String_Node_Str",ex,dest);
        }
      }
 else {
        throw e;
      }
    }
  }
}
Program: 1503
Project: 1503
Buggy source:
public IndexInput openFromLocal(String name,int bufferSize) throws IOException {
  if (Constants.WINDOWS) {
    return new FileIndexInput(_localFileCache.getLocalFile(_dirName,name),bufferSize);
  }
 else   if (name.endsWith("String_Node_Str")) {
    return new FileNIOIndexInput(_localFileCache.getLocalFile(_dirName,name),bufferSize);
  }
 else {
    return new MMapIndexInput(_localFileCache.getLocalFile(_dirName,name));
  }
}

Fixed version (ground truth):
public IndexInput openFromLocal(String name,int bufferSize) throws IOException {
  if (Constants.WINDOWS) {
    return new FileIndexInput(_localFileCache.getLocalFile(_dirName,name),bufferSize);
  }
 else   if (name.endsWith("String_Node_Str") || !Constants.JRE_IS_64BIT) {
    return new FileNIOIndexInput(_localFileCache.getLocalFile(_dirName,name),bufferSize);
  }
 else {
    return new MMapIndexInput(_localFileCache.getLocalFile(_dirName,name));
  }
}
Program: 1504
Project: 1504
Buggy source:
private File newFile(String dirName,String name){
  int index=random.nextInt(files.length);
  for (int i=0; i < files.length; i++) {
    File dir=new File(files[index],dirName);
    if (!dir.exists()) {
      dir.mkdirs();
    }
    try {
      File file=new File(dir,name);
      file.createNewFile();
      return file;
    }
 catch (    IOException e) {
      LOG.error("String_Node_Str",dir);
    }
    index++;
    if (index >= files.length) {
      index=0;
    }
  }
  fatalNoLocalDirs();
  return null;
}

Fixed version (ground truth):
private File newFile(String dirName,String name){
  int index=random.nextInt(files.length);
  for (int i=0; i < files.length; i++) {
    File dir=new File(files[index],dirName);
    if (!dir.exists()) {
      dir.mkdirs();
    }
    try {
      createDir(dir);
      File file=new File(dir,name);
      return file;
    }
 catch (    IOException e) {
      LOG.error("String_Node_Str",dir);
    }
    index++;
    if (index >= files.length) {
      index=0;
    }
  }
  fatalNoLocalDirs();
  return null;
}
Program: 1505
Project: 1505
Buggy source:
private static FieldSelector getFieldSelector(final Selector selector){
  return new FieldSelector(){
    private static final long serialVersionUID=4089164344758433000L;
    @Override public FieldSelectorResult accept(    String fieldName){
      if (ROW_ID.equals(fieldName)) {
        return FieldSelectorResult.LOAD;
      }
      if (RECORD_ID.equals(fieldName)) {
        return FieldSelectorResult.LOAD;
      }
      if (PRIME_DOC.equals(fieldName)) {
        return FieldSelectorResult.NO_LOAD;
      }
      if (selector.columnFamiliesToFetch == null && selector.columnsToFetch == null) {
        return FieldSelectorResult.LOAD;
      }
      String columnFamily=getColumnFamily(fieldName);
      if (selector.columnFamiliesToFetch != null) {
        if (selector.columnFamiliesToFetch.contains(columnFamily)) {
          return FieldSelectorResult.LOAD;
        }
        return FieldSelectorResult.NO_LOAD;
      }
      String columnName=getColumnName(fieldName);
      if (selector.columnsToFetch != null) {
        Set<String> columns=selector.columnsToFetch.get(columnFamily);
        if (columns != null && columns.contains(columnName)) {
          return FieldSelectorResult.LOAD;
        }
      }
      return FieldSelectorResult.NO_LOAD;
    }
  }
;
}

Fixed version (ground truth):
private static FieldSelector getFieldSelector(final Selector selector){
  return new FieldSelector(){
    private static final long serialVersionUID=4089164344758433000L;
    @Override public FieldSelectorResult accept(    String fieldName){
      if (ROW_ID.equals(fieldName)) {
        return FieldSelectorResult.LOAD;
      }
      if (RECORD_ID.equals(fieldName)) {
        return FieldSelectorResult.LOAD;
      }
      if (PRIME_DOC.equals(fieldName)) {
        return FieldSelectorResult.NO_LOAD;
      }
      if (selector.columnFamiliesToFetch == null && selector.columnsToFetch == null) {
        return FieldSelectorResult.LOAD;
      }
      String columnFamily=getColumnFamily(fieldName);
      if (selector.columnFamiliesToFetch != null) {
        if (selector.columnFamiliesToFetch.contains(columnFamily)) {
          return FieldSelectorResult.LOAD;
        }
      }
      String columnName=getColumnName(fieldName);
      if (selector.columnsToFetch != null) {
        Set<String> columns=selector.columnsToFetch.get(columnFamily);
        if (columns != null && columns.contains(columnName)) {
          return FieldSelectorResult.LOAD;
        }
      }
      return FieldSelectorResult.NO_LOAD;
    }
  }
;
}
Program: 1506
Project: 1506
Buggy source:
@Override public FieldSelectorResult accept(String fieldName){
  if (ROW_ID.equals(fieldName)) {
    return FieldSelectorResult.LOAD;
  }
  if (RECORD_ID.equals(fieldName)) {
    return FieldSelectorResult.LOAD;
  }
  if (PRIME_DOC.equals(fieldName)) {
    return FieldSelectorResult.NO_LOAD;
  }
  if (selector.columnFamiliesToFetch == null && selector.columnsToFetch == null) {
    return FieldSelectorResult.LOAD;
  }
  String columnFamily=getColumnFamily(fieldName);
  if (selector.columnFamiliesToFetch != null) {
    if (selector.columnFamiliesToFetch.contains(columnFamily)) {
      return FieldSelectorResult.LOAD;
    }
    return FieldSelectorResult.NO_LOAD;
  }
  String columnName=getColumnName(fieldName);
  if (selector.columnsToFetch != null) {
    Set<String> columns=selector.columnsToFetch.get(columnFamily);
    if (columns != null && columns.contains(columnName)) {
      return FieldSelectorResult.LOAD;
    }
  }
  return FieldSelectorResult.NO_LOAD;
}

Fixed version (ground truth):
@Override public FieldSelectorResult accept(String fieldName){
  if (ROW_ID.equals(fieldName)) {
    return FieldSelectorResult.LOAD;
  }
  if (RECORD_ID.equals(fieldName)) {
    return FieldSelectorResult.LOAD;
  }
  if (PRIME_DOC.equals(fieldName)) {
    return FieldSelectorResult.NO_LOAD;
  }
  if (selector.columnFamiliesToFetch == null && selector.columnsToFetch == null) {
    return FieldSelectorResult.LOAD;
  }
  String columnFamily=getColumnFamily(fieldName);
  if (selector.columnFamiliesToFetch != null) {
    if (selector.columnFamiliesToFetch.contains(columnFamily)) {
      return FieldSelectorResult.LOAD;
    }
  }
  String columnName=getColumnName(fieldName);
  if (selector.columnsToFetch != null) {
    Set<String> columns=selector.columnsToFetch.get(columnFamily);
    if (columns != null && columns.contains(columnName)) {
      return FieldSelectorResult.LOAD;
    }
  }
  return FieldSelectorResult.NO_LOAD;
}
Program: 1507
Project: 1507
Buggy source:
public void init(){
  super.init();
  startIndexReaderCloserDaemon();
  startIndexReopenerDaemon();
}

Fixed version (ground truth):
public void init(){
  super.init();
  startIndexReaderCloserDaemon();
}
Program: 1508
Project: 1508
Buggy source:
protected void closeOldReaders(String table){
  Set<String> shardsToServe=getShardsToServe(table);
  Map<String,IndexReader> tableReaders=readers.get(table);
  if (tableReaders == null) {
    return;
  }
  Set<String> shardsOpen=new HashSet<String>(tableReaders.keySet());
  shardsOpen.removeAll(shardsToServe);
  if (shardsOpen.isEmpty()) {
    return;
  }
  for (  String shard : shardsOpen) {
    LOG.info("String_Node_Str",table,shard);
    IndexReader indexReader=tableReaders.remove(shard);
    beforeClose(shard,indexReader);
    try {
      indexReader.close();
    }
 catch (    IOException e) {
      LOG.error("String_Node_Str",e,indexReader);
    }
    cleanupLocallyCachedIndexes(table,shard);
  }
}

Fixed version (ground truth):
protected void closeOldReaders(String table){
  Set<String> shardsToServe=getShardsToServe(table);
  Map<String,IndexReader> tableReaders=readers.get(table);
  if (tableReaders == null) {
    return;
  }
  Set<String> shardsOpen=new HashSet<String>(tableReaders.keySet());
  shardsOpen.removeAll(shardsToServe);
  if (shardsOpen.isEmpty()) {
    return;
  }
  for (  String shard : shardsOpen) {
    IndexReader indexReader=tableReaders.remove(shard);
    closeIndex(table,shard,indexReader);
  }
}
Program: 1509
Project: 1509
Buggy source:
@Override protected IndexReader openShard(String table,String shard) throws IOException {
  LOG.info("String_Node_Str",shard,table);
  Path tablePath=new Path(blurBasePath,table);
  if (!exists(tablePath)) {
    throw new FileNotFoundException(tablePath.toString());
  }
  Path hdfsDirPath=new Path(tablePath,shard);
  if (!exists(hdfsDirPath)) {
    throw new FileNotFoundException(hdfsDirPath.toString());
  }
  ReplicaHdfsDirectory directory=new ReplicaHdfsDirectory(table,shard,hdfsDirPath,fileSystem,localFileCache,lockFactory,new Progressable(){
    @Override public void progress(){
    }
  }
,replicationDaemon);
  touchFiles(directory,table,shard);
  return IndexReader.open(directory);
}

Fixed version (ground truth):
@Override protected IndexReader openShard(String table,String shard) throws IOException {
  LOG.info("String_Node_Str",shard,table);
  Path tablePath=new Path(blurBasePath,table);
  if (!exists(tablePath)) {
    throw new FileNotFoundException(tablePath.toString());
  }
  Path hdfsDirPath=new Path(tablePath,shard);
  if (!exists(hdfsDirPath)) {
    throw new FileNotFoundException(hdfsDirPath.toString());
  }
  ReplicaHdfsDirectory directory=new ReplicaHdfsDirectory(table,shard,hdfsDirPath,fileSystem,localFileCache,lockFactory,new Progressable(){
    @Override public void progress(){
    }
  }
,replicationDaemon);
  return warmUp(IndexReader.open(directory));
}
Program: 1510
Project: 1510
Buggy source:
@Override public List<String> getShardList(String table){
  List<String> result=new ArrayList<String>();
  try {
    FileStatus[] listStatus=fileSystem.listStatus(new Path(blurBasePath,table));
    for (    FileStatus status : listStatus) {
      if (status.isDir()) {
        result.add(status.getPath().getName());
      }
    }
    return result;
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
@Override public List<String> getShardList(String table){
  List<String> result=new ArrayList<String>();
  try {
    FileStatus[] listStatus=fileSystem.listStatus(new Path(blurBasePath,table));
    for (    FileStatus status : listStatus) {
      if (status.isDir()) {
        String name=status.getPath().getName();
        if (name.startsWith(SHARD_PREFIX)) {
          result.add(name);
        }
      }
    }
    return result;
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}
Program: 1513
Project: 1513
Buggy source:
private void populateFields(){
  try {
    Cursor note=NotesDbAdapter.getInstance(this).fetchNote(mRowId);
    startManagingCursor(note);
    blob=note.getBlob(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_DATA));
    setupView(blob != null);
    if (blob != null) {
      BitmapFactory.Options bmpFactoryOptions=new BitmapFactory.Options();
      bmpFactoryOptions.inSampleSize=3;
      Bitmap blobb=BitmapFactory.decodeByteArray(blob,0,blob.length,bmpFactoryOptions);
      mImageView.setImageBitmap(blobb);
    }
 else {
      mBodyText.setText(note.getString(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_BODY)));
    }
    mTitleText.setText(note.getString(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_TITLE)));
  }
 catch (  Exception e) {
    Log.e("String_Node_Str","String_Node_Str",e);
  }
}

Fixed version (ground truth):
private void populateFields(){
  try {
    Cursor note=NotesDbAdapter.getInstance(this).fetchNote(mRowId);
    startManagingCursor(note);
    blob=note.getBlob(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_DATA));
    setupView(blob != null);
    if (blob != null) {
      BitmapFactory.Options bmpFactoryOptions=new BitmapFactory.Options();
      bmpFactoryOptions.inSampleSize=4;
      Bitmap blobb=BitmapFactory.decodeByteArray(blob,0,blob.length,bmpFactoryOptions);
      mImageView.setImageBitmap(blobb);
      System.gc();
    }
 else {
      mBodyText.setText(note.getString(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_BODY)));
    }
    mTitleText.setText(note.getString(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_TITLE)));
  }
 catch (  Exception e) {
    Log.e("String_Node_Str","String_Node_Str",e);
    Toast.makeText(this,"String_Node_Str" + e.getMessage(),Toast.LENGTH_LONG).show();
  }
}
Program: 1514
Project: 1514
Buggy source:
@Override protected void onResume(){
  super.onResume();
  Bundle extras=getIntent().getExtras();
  if (mRowId != -1) {
    populateFields();
  }
 else   if (extras != null) {
    mRowId=extras.getLong(NotesDbAdapter.KEY_ROWID);
    populateFields();
  }
 else {
    setupView(false);
  }
  populateFields();
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  Bundle extras=getIntent().getExtras();
  if (mRowId != -1) {
    populateFields();
  }
 else   if (extras != null) {
    mRowId=extras.getLong(NotesDbAdapter.KEY_ROWID);
    populateFields();
  }
 else {
    setupView(false);
  }
}
Program: 1515
Project: 1515
Buggy source:
private void importDataStream(){
  Intent passingIntent=new Intent(this,ImageStore.class);
  passingIntent.setData(dataStream);
  startActivityForResult(passingIntent,1);
  dataStream=null;
}

Fixed version (ground truth):
private void importDataStream(){
  try {
    InputStream is=getContentResolver().openInputStream(dataStream);
    String mimeType=getContentResolver().getType(dataStream);
    byte[] data=NoteUtils.readBytesAndClose(is);
    String title=dataStream.getLastPathSegment();
    String body=dataStream.getPath();
    NotesDbAdapter.getInstance(this).createNote(title,body,data,mimeType);
    data=null;
    Toast.makeText(this,"String_Node_Str" + title,Toast.LENGTH_LONG).show();
    handleDelete();
    fillData();
  }
 catch (  FileNotFoundException e) {
    Log.e(TAG,e.getMessage(),e);
  }
catch (  IOException e) {
    Log.e(TAG,e.getMessage(),e);
  }
catch (  OutOfMemoryError e) {
    Toast.makeText(this,"String_Node_Str",Toast.LENGTH_LONG).show();
  }
 finally {
  }
}
Program: 1516
Project: 1516
Buggy source:
private void unlockDatabase(String password){
  try {
    mDbHelper.open(password);
    fillData();
  }
 catch (  Exception e) {
    Toast.makeText(this,"String_Node_Str",Toast.LENGTH_LONG).show();
    showPassword();
  }
}

Fixed version (ground truth):
private void unlockDatabase(String password){
  try {
    mDbHelper.open(password);
    if (dataStream != null)     importDataStream();
 else     fillData();
  }
 catch (  Exception e) {
    Toast.makeText(this,"String_Node_Str",Toast.LENGTH_LONG).show();
    showPassword();
  }
}
Program: 1517
Project: 1517
Buggy source:
@Override public void onAttachedToWindow(){
  super.onAttachedToWindow();
  findViewById(R.id.listlayout).setOnTouchListener(new OnTouchListener(){
    @Override public boolean onTouch(    View v,    MotionEvent event){
      createNote();
      return false;
    }
  }
);
}

Fixed version (ground truth):
@Override public void onAttachedToWindow(){
  super.onAttachedToWindow();
  findViewById(R.id.listlayout).setOnTouchListener(new OnTouchListener(){
    @Override public boolean onTouch(    View v,    MotionEvent event){
      if (mDbHelper != null && mDbHelper.isOpen())       createNote();
      return false;
    }
  }
);
}
Program: 1518
Project: 1518
Buggy source:
@Override protected void onResume(){
  super.onResume();
  mDbHelper=NotesDbAdapter.getInstance(this);
  if (!mDbHelper.isOpen())   showPassword();
 else   fillData();
  if (dataStream != null)   importDataStream();
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  mDbHelper=NotesDbAdapter.getInstance(this);
  if (!mDbHelper.isOpen())   showPassword();
 else   if (dataStream != null)   importDataStream();
 else   fillData();
}
Program: 1519
Project: 1519
Buggy source:
@Override public boolean onTouch(View v,MotionEvent event){
  createNote();
  return false;
}

Fixed version (ground truth):
@Override public boolean onTouch(View v,MotionEvent event){
  if (mDbHelper != null && mDbHelper.isOpen())   createNote();
  return false;
}
Program: 1520
Project: 1520
Buggy source:
private void populateFields(){
  try {
    Cursor note=NotesDbAdapter.getInstance(this).fetchNote(mRowId);
    startManagingCursor(note);
    blob=note.getBlob(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_DATA));
    setupView(blob != null);
    if (blob != null) {
      BitmapFactory.Options bmpFactoryOptions=new BitmapFactory.Options();
      bmpFactoryOptions.inSampleSize=4;
      Bitmap blobb=BitmapFactory.decodeByteArray(blob,0,blob.length,bmpFactoryOptions);
      mImageView.setImageBitmap(blobb);
      System.gc();
    }
 else {
      mBodyText.setText(note.getString(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_BODY)));
    }
    mTitleText.setText(note.getString(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_TITLE)));
  }
 catch (  Exception e) {
    Log.e("String_Node_Str","String_Node_Str",e);
    Toast.makeText(this,"String_Node_Str" + e.getMessage(),Toast.LENGTH_LONG).show();
  }
}

Fixed version (ground truth):
private void populateFields(){
  try {
    Cursor note=NotesDbAdapter.getInstance(this).fetchNote(mRowId);
    startManagingCursor(note);
    blob=note.getBlob(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_DATA));
    setupView(blob != null);
    if (blob != null) {
      BitmapFactory.Options bmpFactoryOptions=new BitmapFactory.Options();
      if (blob.length > 100000)       bmpFactoryOptions.inSampleSize=4;
 else       bmpFactoryOptions.inSampleSize=2;
      Bitmap blobb=BitmapFactory.decodeByteArray(blob,0,blob.length,bmpFactoryOptions);
      mImageView.setImageBitmap(blobb);
      System.gc();
    }
 else {
      mBodyText.setText(note.getString(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_BODY)));
    }
    mTitleText.setText(note.getString(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_TITLE)));
  }
 catch (  Exception e) {
    Log.e("String_Node_Str","String_Node_Str",e);
    Toast.makeText(this,"String_Node_Str" + e.getMessage(),Toast.LENGTH_LONG).show();
  }
}
Program: 1521
Project: 1521
Buggy source:
@Override protected void onSaveInstanceState(Bundle outState){
  super.onSaveInstanceState(outState);
  if (mRowId != -1)   outState.putLong(NotesDbAdapter.KEY_ROWID,mRowId);
}

Fixed version (ground truth):
@Override protected void onSaveInstanceState(Bundle outState){
  super.onSaveInstanceState(outState);
  saveState();
  if (mRowId != -1)   outState.putLong(NotesDbAdapter.KEY_ROWID,mRowId);
}
Program: 1522
Project: 1522
Buggy source:
@Override protected void onPause(){
  super.onPause();
  saveState();
}

Fixed version (ground truth):
@Override protected void onPause(){
  super.onPause();
  saveState();
  if (mTitleText != null)   mTitleText.setText(ZERO_TEXT);
  if (mBodyText != null)   mBodyText.setText(ZERO_TEXT);
  if (mImageView != null)   mImageView.setImageBitmap(null);
}
Program: 1523
Project: 1523
Buggy source:
private void importDataStream(){
  try {
    InputStream is=getContentResolver().openInputStream(dataStream);
    String mimeType=getContentResolver().getType(dataStream);
    byte[] data=NoteUtils.readBytesAndClose(is);
    String title=dataStream.getLastPathSegment();
    String body=dataStream.getPath();
    NotesDbAdapter.getInstance(this).createNote(title,body,data,mimeType);
    data=null;
    Toast.makeText(this,"String_Node_Str" + title,Toast.LENGTH_LONG).show();
    handleDelete();
    fillData();
  }
 catch (  FileNotFoundException e) {
    Log.e(TAG,e.getMessage(),e);
  }
catch (  IOException e) {
    Log.e(TAG,e.getMessage(),e);
  }
catch (  OutOfMemoryError e) {
    Toast.makeText(this,"String_Node_Str",Toast.LENGTH_LONG).show();
  }
 finally {
  }
}

Fixed version (ground truth):
private void importDataStream(){
  try {
    InputStream is=getContentResolver().openInputStream(dataStream);
    String mimeType=getContentResolver().getType(dataStream);
    byte[] data=NoteUtils.readBytesAndClose(is);
    String title=dataStream.getLastPathSegment();
    String body=dataStream.getPath();
    NotesDbAdapter.getInstance(this).createNote(title,body,data,mimeType);
    Toast.makeText(this,getString(R.string.on_import) + "String_Node_Str" + title,Toast.LENGTH_LONG).show();
    handleDelete();
    data=null;
    dataStream=null;
    title=null;
    body=null;
    System.gc();
    fillData();
  }
 catch (  FileNotFoundException e) {
    Log.e(TAG,e.getMessage(),e);
  }
catch (  IOException e) {
    Log.e(TAG,e.getMessage(),e);
  }
catch (  OutOfMemoryError e) {
    Toast.makeText(this,getString(R.string.err_size),Toast.LENGTH_LONG).show();
  }
 finally {
  }
}
Program: 1524
Project: 1524
Buggy source:
private void fillData(){
  Cursor notesCursor=mDbHelper.fetchAllNotes();
  startManagingCursor(notesCursor);
  String[] from=new String[]{NotesDbAdapter.KEY_TITLE};
  int[] to=new int[]{R.id.text1};
  SimpleCursorAdapter notes=new SimpleCursorAdapter(this,R.layout.notes_row,notesCursor,from,to);
  setListAdapter(notes);
  if (notes.isEmpty()) {
    Toast.makeText(this,"String_Node_Str",Toast.LENGTH_LONG).show();
  }
}

Fixed version (ground truth):
private void fillData(){
  Cursor notesCursor=mDbHelper.fetchAllNotes();
  startManagingCursor(notesCursor);
  String[] from=new String[]{NotesDbAdapter.KEY_TITLE};
  int[] to=new int[]{R.id.text1};
  SimpleCursorAdapter notes=new SimpleCursorAdapter(this,R.layout.notes_row,notesCursor,from,to);
  setListAdapter(notes);
  if (notes.isEmpty()) {
    Toast.makeText(this,getString(R.string.on_start),Toast.LENGTH_LONG).show();
  }
}
Program: 1525
Project: 1525
Buggy source:
private void unlockDatabase(String password){
  try {
    mDbHelper.open(password);
    if (dataStream != null)     importDataStream();
 else     fillData();
  }
 catch (  Exception e) {
    Toast.makeText(this,"String_Node_Str",Toast.LENGTH_LONG).show();
    showPassword();
  }
}

Fixed version (ground truth):
private void unlockDatabase(String password){
  try {
    mDbHelper.open(password);
    if (dataStream != null)     importDataStream();
 else     fillData();
  }
 catch (  Exception e) {
    Toast.makeText(this,getString(R.string.err_pin),Toast.LENGTH_LONG).show();
    showPassword();
  }
}
Program: 1526
Project: 1526
Buggy source:
private void shareEntry(long id){
  Cursor note=mDbHelper.fetchNote(id);
  startManagingCursor(note);
  byte[] blob=note.getBlob(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_DATA));
  if (blob != null) {
    try {
      NoteUtils.shareImage(this,blob);
    }
 catch (    IOException e) {
      Toast.makeText(this,"String_Node_Str" + e.getMessage(),Toast.LENGTH_LONG).show();
    }
  }
 else {
    String body=note.getString(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_BODY));
    NoteUtils.shareText(this,body);
  }
  note.close();
}

Fixed version (ground truth):
private void shareEntry(long id){
  Cursor note=mDbHelper.fetchNote(id);
  startManagingCursor(note);
  byte[] blob=note.getBlob(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_DATA));
  if (blob != null) {
    try {
      NoteUtils.shareImage(this,blob);
    }
 catch (    IOException e) {
      Toast.makeText(this,getString(R.string.err_export) + e.getMessage(),Toast.LENGTH_LONG).show();
    }
  }
 else {
    String body=note.getString(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_BODY));
    NoteUtils.shareText(this,body);
  }
  note.close();
}
Program: 1527
Project: 1527
Buggy source:
private void showPassword(){
  LayoutInflater factory=LayoutInflater.from(this);
  final View textEntryView=factory.inflate(R.layout.alert_dialog_text_entry,null);
  new AlertDialog.Builder(this).setTitle(getString(R.string.app_name)).setView(textEntryView).setPositiveButton("String_Node_Str",new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int whichButton){
      EditText eText=((android.widget.EditText)textEntryView.findViewById(R.id.password_edit));
      String password=eText.getText().toString();
      unlockDatabase(password);
      eText.setText("String_Node_Str");
      System.gc();
    }
  }
).setNegativeButton("String_Node_Str",new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int whichButton){
    }
  }
).create().show();
}

Fixed version (ground truth):
private void showPassword(){
  String dialogMessage;
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(this);
  boolean firstTime=prefs.getBoolean("String_Node_Str",true);
  if (firstTime) {
    dialogMessage=getString(R.string.new_pin);
    Editor pEdit=prefs.edit();
    pEdit.putBoolean("String_Node_Str",false);
    pEdit.commit();
  }
 else   dialogMessage=getString(R.string.enter_pin);
  LayoutInflater factory=LayoutInflater.from(this);
  final View textEntryView=factory.inflate(R.layout.alert_dialog_text_entry,null);
  new AlertDialog.Builder(this).setTitle(getString(R.string.app_name)).setView(textEntryView).setMessage(dialogMessage).setPositiveButton(getString(R.string.button_ok),new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int whichButton){
      EditText eText=((android.widget.EditText)textEntryView.findViewById(R.id.password_edit));
      String password=eText.getText().toString();
      unlockDatabase(password);
      eText.setText("String_Node_Str");
      System.gc();
    }
  }
).setNegativeButton(getString(R.string.button_cancel),new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int whichButton){
    }
  }
).create().show();
}
Program: 1528
Project: 1528
Buggy source:
private void showRekeyDialog(){
  LayoutInflater factory=LayoutInflater.from(this);
  final View textEntryView=factory.inflate(R.layout.alert_dialog_text_entry,null);
  new AlertDialog.Builder(this).setTitle(getString(R.string.app_name)).setView(textEntryView).setPositiveButton("String_Node_Str",new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int whichButton){
      EditText eText=((android.widget.EditText)textEntryView.findViewById(R.id.password_edit));
      String newPassword=eText.getText().toString();
      rekeyDatabase(newPassword);
      eText.setText("String_Node_Str");
      System.gc();
    }
  }
).setNegativeButton("String_Node_Str",new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int whichButton){
    }
  }
).create().show();
}

Fixed version (ground truth):
private void showRekeyDialog(){
  LayoutInflater factory=LayoutInflater.from(this);
  final View textEntryView=factory.inflate(R.layout.alert_dialog_text_entry,null);
  new AlertDialog.Builder(this).setTitle(getString(R.string.app_name)).setView(textEntryView).setMessage(getString(R.string.rekey_message)).setPositiveButton(getString(R.string.button_ok),new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int whichButton){
      EditText eText=((android.widget.EditText)textEntryView.findViewById(R.id.password_edit));
      String newPassword=eText.getText().toString();
      rekeyDatabase(newPassword);
      eText.setText("String_Node_Str");
      System.gc();
    }
  }
).setNegativeButton(getString(R.string.button_cancel),new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int whichButton){
    }
  }
).create().show();
}
Program: 1529
Project: 1529
Buggy source:
private void rekeyDatabase(String password){
  try {
    mDbHelper.rekey(password);
  }
 catch (  Exception e) {
    Toast.makeText(this,e.getMessage(),Toast.LENGTH_LONG).show();
  }
}

Fixed version (ground truth):
private void rekeyDatabase(String password){
  try {
    Toast.makeText(this,getString(R.string.do_rekey),Toast.LENGTH_LONG).show();
    mDbHelper.rekey(password);
  }
 catch (  Exception e) {
    Toast.makeText(this,e.getMessage(),Toast.LENGTH_LONG).show();
  }
}
Program: 1530
Project: 1530
Buggy source:
private void loadInputStream(){
  try {
    InputStream is=getContentResolver().openInputStream(stream);
    byte[] data=null;
    data=readBytesAndClose(is);
    String title=stream.getLastPathSegment();
    String body=stream.getPath();
    mDbHelper.createNote(title,body,data);
    data=null;
    Toast.makeText(this,"String_Node_Str" + title,Toast.LENGTH_LONG).show();
    mDbHelper.close();
    handleDelete();
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
catch (  OutOfMemoryError e) {
    Toast.makeText(this,"String_Node_Str",Toast.LENGTH_LONG).show();
  }
 finally {
  }
}

Fixed version (ground truth):
private void loadInputStream(){
  try {
    InputStream is=getContentResolver().openInputStream(stream);
    String mimeType=getContentResolver().getType(stream);
    byte[] data=readBytesAndClose(is);
    String title=stream.getLastPathSegment();
    String body=stream.getPath();
    mDbHelper.createNote(title,body,data,mimeType);
    data=null;
    Toast.makeText(this,"String_Node_Str" + title,Toast.LENGTH_LONG).show();
    mDbHelper.close();
    handleDelete();
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
catch (  OutOfMemoryError e) {
    Toast.makeText(this,"String_Node_Str",Toast.LENGTH_LONG).show();
  }
 finally {
  }
}
Program: 1531
Project: 1531
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  mDbHelper=new NotesDbAdapter(this);
  String password=this.getIntent().getStringExtra("String_Node_Str");
  mDbHelper.open(password);
  setContentView(R.layout.note_edit);
  mTitleText=(EditText)findViewById(R.id.title);
  mBodyText=(EditText)findViewById(R.id.body);
  mImageView=(ImageView)findViewById(R.id.odata);
  mRowId=savedInstanceState != null ? savedInstanceState.getLong(NotesDbAdapter.KEY_ROWID) : null;
  if (mRowId == null) {
    Bundle extras=getIntent().getExtras();
    mRowId=extras != null ? extras.getLong(NotesDbAdapter.KEY_ROWID) : null;
    if (mRowId == 0)     mRowId=null;
  }
  populateFields();
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  mDbHelper=new NotesDbAdapter(this);
  String password=this.getIntent().getStringExtra("String_Node_Str");
  mDbHelper.open(password);
  mRowId=savedInstanceState != null ? savedInstanceState.getLong(NotesDbAdapter.KEY_ROWID) : null;
  if (mRowId == null) {
    Bundle extras=getIntent().getExtras();
    mRowId=extras != null ? extras.getLong(NotesDbAdapter.KEY_ROWID) : null;
    if (mRowId == 0)     mRowId=null;
  }
  populateFields();
}
Program: 1532
Project: 1532
Buggy source:
private void populateFields(){
  try {
    if (mRowId != null) {
      Cursor note=mDbHelper.fetchNote(mRowId);
      startManagingCursor(note);
      mTitleText.setText(note.getString(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_TITLE)));
      mBodyText.setText(note.getString(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_BODY)));
      byte[] blob=note.getBlob(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_DATA));
      if (blob != null) {
        BitmapFactory.Options bmpFactoryOptions=new BitmapFactory.Options();
        bmpFactoryOptions.inSampleSize=3;
        Bitmap blobb=BitmapFactory.decodeByteArray(blob,0,blob.length,bmpFactoryOptions);
        mImageView.setImageBitmap(blobb);
      }
    }
  }
 catch (  Exception e) {
    Log.e("String_Node_Str","String_Node_Str",e);
  }
}

Fixed version (ground truth):
private void populateFields(){
  try {
    if (mRowId != null) {
      Cursor note=mDbHelper.fetchNote(mRowId);
      startManagingCursor(note);
      byte[] blob=note.getBlob(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_DATA));
      setupView(blob != null);
      if (blob != null) {
        BitmapFactory.Options bmpFactoryOptions=new BitmapFactory.Options();
        bmpFactoryOptions.inSampleSize=3;
        Bitmap blobb=BitmapFactory.decodeByteArray(blob,0,blob.length,bmpFactoryOptions);
        mImageView.setImageBitmap(blobb);
      }
      mTitleText.setText(note.getString(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_TITLE)));
      mBodyText.setText(note.getString(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_BODY)));
    }
 else     setupView(false);
  }
 catch (  Exception e) {
    Log.e("String_Node_Str","String_Node_Str",e);
  }
}
Program: 1533
Project: 1533
Buggy source:
private void saveState(){
  String title=mTitleText.getText().toString();
  String body=mBodyText.getText().toString();
  if (title != null && title.length() > 0) {
    if (mRowId == null) {
      long id=mDbHelper.createNote(title,body,null);
      if (id > 0) {
        mRowId=id;
      }
    }
 else {
      mDbHelper.updateNote(mRowId,title,body,null);
    }
  }
  mDbHelper.close();
}

Fixed version (ground truth):
private void saveState(){
  if (mTitleText != null && mTitleText.getText() != null) {
    String title=mTitleText.getText().toString();
    String body=mBodyText.getText().toString();
    if (title != null && title.length() > 0) {
      if (mRowId == null) {
        long id=mDbHelper.createNote(title,body,null,null);
        if (id > 0) {
          mRowId=id;
        }
      }
 else {
        mDbHelper.updateNote(mRowId,title,body,null,null);
      }
    }
    mDbHelper.close();
  }
}
Program: 1534
Project: 1534
Buggy source:
private void fillData(){
  Cursor notesCursor=mDbHelper.fetchAllNotes();
  startManagingCursor(notesCursor);
  String[] from=new String[]{NotesDbAdapter.KEY_TITLE};
  int[] to=new int[]{R.id.text1};
  SimpleCursorAdapter notes=new SimpleCursorAdapter(this,R.layout.notes_row,notesCursor,from,to);
  setListAdapter(notes);
}

Fixed version (ground truth):
private void fillData(){
  Cursor notesCursor=mDbHelper.fetchAllNotes();
  startManagingCursor(notesCursor);
  String[] from=new String[]{NotesDbAdapter.KEY_TITLE};
  int[] to=new int[]{R.id.text1};
  SimpleCursorAdapter notes=new SimpleCursorAdapter(this,R.layout.notes_row,notesCursor,from,to);
  setListAdapter(notes);
  if (notes.isEmpty()) {
    createNote();
  }
}
Program: 1535
Project: 1535
Buggy source:
private boolean savePublicImage(String title,byte[] outdata){
  File path=getExternalFilesDir("String_Node_Str");
  File file=new File(path,title + "String_Node_Str");
  try {
    path.mkdirs();
    InputStream is=new ByteArrayInputStream(outdata);
    OutputStream os=new FileOutputStream(file);
    byte[] data=new byte[is.available()];
    is.read(data);
    os.write(data);
    is.close();
    os.close();
    MediaScannerConnection.scanFile(this,new String[]{file.toString()},null,new MediaScannerConnection.OnScanCompletedListener(){
      public void onScanCompleted(      String path,      Uri uri){
        Log.i("String_Node_Str","String_Node_Str" + path + "String_Node_Str");
        Log.i("String_Node_Str","String_Node_Str" + uri);
        Intent intent=new Intent();
        intent.setAction(android.content.Intent.ACTION_VIEW);
        intent.setDataAndType(uri,"String_Node_Str");
        startActivity(intent);
      }
    }
);
    MediaScannerConnection.scanFile(this,new String[]{path.toString()},null,new MediaScannerConnection.OnScanCompletedListener(){
      public void onScanCompleted(      String path,      Uri uri){
      }
    }
);
    return true;
  }
 catch (  IOException e) {
    Log.w("String_Node_Str","String_Node_Str" + file,e);
    return false;
  }
}

Fixed version (ground truth):
private boolean savePublicImage(String title,byte[] outdata){
  File path=getExternalFilesDirEclair("String_Node_Str");
  File file=new File(path,title);
  try {
    path.mkdirs();
    InputStream is=new ByteArrayInputStream(outdata);
    OutputStream os=new FileOutputStream(file);
    byte[] data=new byte[is.available()];
    is.read(data);
    os.write(data);
    is.close();
    os.close();
    return true;
  }
 catch (  IOException e) {
    Log.w("String_Node_Str","String_Node_Str" + file,e);
    return false;
  }
}
Program: 1536
Project: 1536
Buggy source:
@Override protected void onStop(){
  super.onStop();
  File file=new File(getExternalFilesDir(null),"String_Node_Str");
  if (file.exists())   file.delete();
}

Fixed version (ground truth):
@Override protected void onStop(){
  super.onStop();
  File file=new File(getExternalFilesDirEclair(null),"String_Node_Str");
  if (file.exists())   file.delete();
}
Program: 1537
Project: 1537
Buggy source:
private boolean saveTmpImage(byte[] outdata){
  File path=this.getExternalFilesDir(null);
  File file=new File(path,"String_Node_Str");
  try {
    path.mkdirs();
    InputStream is=new ByteArrayInputStream(outdata);
    OutputStream os=new FileOutputStream(file);
    byte[] data=new byte[is.available()];
    is.read(data);
    os.write(data);
    is.close();
    os.close();
    tmpImageUri=Uri.fromFile(file);
    return true;
  }
 catch (  IOException e) {
    Log.w("String_Node_Str","String_Node_Str" + file,e);
    return false;
  }
}

Fixed version (ground truth):
private boolean saveTmpImage(byte[] outdata){
  File path=getExternalFilesDirEclair(null);
  File file=new File(path,"String_Node_Str");
  try {
    path.mkdirs();
    InputStream is=new ByteArrayInputStream(outdata);
    OutputStream os=new FileOutputStream(file);
    byte[] data=new byte[is.available()];
    is.read(data);
    os.write(data);
    is.close();
    os.close();
    tmpImageUri=Uri.fromFile(file);
    return true;
  }
 catch (  IOException e) {
    Log.w("String_Node_Str","String_Node_Str" + file,e);
    return false;
  }
}
Program: 1538
Project: 1538
Buggy source:
/** 
 * Return a Cursor positioned at the note that matches the given rowId
 * @param rowId id of note to retrieve
 * @return Cursor positioned to matching note, if found
 * @throws SQLException if note could not be found/retrieved
 */
public Cursor fetchNote(long rowId) throws SQLException {
  Cursor mCursor=mDb.query(true,DATABASE_TABLE,new String[]{KEY_ROWID,KEY_TITLE,KEY_BODY,KEY_DATA},KEY_ROWID + "String_Node_Str" + rowId,null,null,null,null,null);
  if (mCursor != null) {
    mCursor.moveToFirst();
  }
  return mCursor;
}

Fixed version (ground truth):
/** 
 * Return a Cursor positioned at the note that matches the given rowId
 * @param rowId id of note to retrieve
 * @return Cursor positioned to matching note, if found
 * @throws SQLException if note could not be found/retrieved
 */
public Cursor fetchNote(long rowId) throws SQLException {
  Cursor mCursor=mDb.query(true,DATABASE_TABLE,new String[]{KEY_ROWID,KEY_TITLE,KEY_BODY,KEY_DATA,KEY_TYPE},KEY_ROWID + "String_Node_Str" + rowId,null,null,null,null,null);
  if (mCursor != null) {
    mCursor.moveToFirst();
  }
  return mCursor;
}
Program: 1539
Project: 1539
Buggy source:
/** 
 * Update the note using the details provided. The note to be updated is specified using the rowId, and it is altered to use the title and body values passed in
 * @param rowId id of note to update
 * @param title value to set note title to
 * @param body value to set note body to
 * @return true if the note was successfully updated, false otherwise
 */
public boolean updateNote(long rowId,String title,String body,byte[] data){
  ContentValues args=new ContentValues();
  args.put(KEY_TITLE,title);
  args.put(KEY_BODY,body);
  if (data != null)   args.put(KEY_DATA,data);
  return mDb.update(DATABASE_TABLE,args,KEY_ROWID + "String_Node_Str" + rowId,null) > 0;
}

Fixed version (ground truth):
/** 
 * Update the note using the details provided. The note to be updated is specified using the rowId, and it is altered to use the title and body values passed in
 * @param rowId id of note to update
 * @param title value to set note title to
 * @param body value to set note body to
 * @return true if the note was successfully updated, false otherwise
 */
public boolean updateNote(long rowId,String title,String body,byte[] data,String dataType){
  ContentValues args=new ContentValues();
  args.put(KEY_TITLE,title);
  args.put(KEY_BODY,body);
  if (data != null) {
    args.put(KEY_DATA,data);
    args.put(KEY_DATA,dataType);
  }
  return mDb.update(DATABASE_TABLE,args,KEY_ROWID + "String_Node_Str" + rowId,null) > 0;
}
Program: 1540
Project: 1540
Buggy source:
/** 
 * Create a new note using the title and body provided. If the note is successfully created return the new rowId for that note, otherwise return a -1 to indicate failure.
 * @param title the title of the note
 * @param body the body of the note
 * @return rowId or -1 if failed
 */
public long createNote(String title,String body,byte[] data){
  ContentValues initialValues=new ContentValues();
  initialValues.put(KEY_TITLE,title);
  initialValues.put(KEY_BODY,body);
  if (data != null)   initialValues.put(KEY_DATA,data);
  return mDb.insert(DATABASE_TABLE,null,initialValues);
}

Fixed version (ground truth):
/** 
 * Create a new note using the title and body provided. If the note is successfully created return the new rowId for that note, otherwise return a -1 to indicate failure.
 * @param title the title of the note
 * @param body the body of the note
 * @return rowId or -1 if failed
 */
public long createNote(String title,String body,byte[] data,String dataType){
  ContentValues initialValues=new ContentValues();
  initialValues.put(KEY_TITLE,title);
  initialValues.put(KEY_BODY,body);
  if (data != null) {
    initialValues.put(KEY_DATA,data);
    initialValues.put(KEY_TYPE,dataType);
  }
  return mDb.insert(DATABASE_TABLE,null,initialValues);
}
Program: 1541
Project: 1541
Buggy source:
public final void process(){
  processEntities(actives);
}

Fixed version (ground truth):
public final void process(){
  begin();
  processEntities(actives);
  end();
}
Program: 1542
Project: 1542
Buggy source:
@Override protected final void processEntities(ImmutableBag<Entity> entities,int accumulatedDelta){
  for (int i=0, s=entities.size(); s > i; i++) {
    Entity entity=entities.get(i);
    if (entity != null)     process(entity,accumulatedDelta);
  }
}

Fixed version (ground truth):
@Override protected final void processEntities(ImmutableBag<Entity> entities,int accumulatedDelta){
  for (int i=0, s=entities.size(); s > i; i++) {
    process(entities.get(i),accumulatedDelta);
  }
}
Program: 1543
Project: 1543
Buggy source:
protected Entity(World world,int id){
  this.entityManager=world.getEntityManager();
  this.id=id;
}

Fixed version (ground truth):
protected Entity(World world,int id){
  this.world=world;
  this.entityManager=world.getEntityManager();
  this.id=id;
}
Program: 1544
Project: 1544
Buggy source:
/** 
 * Refresh all changes to components for this entity. After adding or removing components, you must call this method. It will update all relevant systems. It is typical to call this after adding components to a newly created entity.
 */
public void refresh(){
  entityManager.refresh(this);
}

Fixed version (ground truth):
/** 
 * Refresh all changes to components for this entity. After adding or removing components, you must call this method. It will update all relevant systems. It is typical to call this after adding components to a newly created entity.
 */
public void refresh(){
  world.refreshEntity(this);
}
Program: 1545
Project: 1545
Buggy source:
@Override protected final void processEntities(ImmutableBag<Entity> entities){
  for (int i=0, s=entities.size(); s > i; i++) {
    Entity entity=entities.get(i);
    if (entity != null)     process(entity);
  }
}

Fixed version (ground truth):
@Override protected final void processEntities(ImmutableBag<Entity> entities){
  for (int i=0, s=entities.size(); s > i; i++) {
    process(entities.get(i));
  }
}
Program: 1546
Project: 1546
Buggy source:
@Override protected void processEntities(ImmutableBag<Entity> entities){
  for (int i=0, s=entities.size(); s > i; i++) {
    Entity entity=entities.get(i);
    if (entity != null)     process(entity);
  }
}

Fixed version (ground truth):
@Override protected void processEntities(ImmutableBag<Entity> entities){
  for (int i=0, s=entities.size(); s > i; i++) {
    process(entities.get(i));
  }
}
Program: 1547
Project: 1547
Buggy source:
public void deleteEntity(Entity e){
  groupManager.remove(e);
  entityManager.remove(e);
}

Fixed version (ground truth):
public void deleteEntity(Entity e){
  deleted.add(e);
}
Program: 1548
Project: 1548
Buggy source:
public World(){
  entityManager=new EntityManager(this);
  systemManager=new SystemManager(this);
  tagManager=new TagManager(this);
  groupManager=new GroupManager(this);
}

Fixed version (ground truth):
public World(){
  entityManager=new EntityManager(this);
  systemManager=new SystemManager(this);
  tagManager=new TagManager(this);
  groupManager=new GroupManager(this);
  refreshed=new Bag<Entity>();
  deleted=new Bag<Entity>();
}
Program: 1549
Project: 1549
Buggy source:
public ComponentMapper(Class<T> type,World world){
  this.em=world.getEntityManager();
  this.type=ComponentTypeManager.getTypeFor(type);
  this.classType=type;
}

Fixed version (ground truth):
public ComponentMapper(Class<T> type,World world){
  this.em=world.getEntityManager();
  this.type=ComponentTypeManager.getTypeFor(type,world);
  this.classType=type;
}
Program: 1550
Project: 1550
Buggy source:
public static final ComponentType getTypeFor(Class<? extends Component> c){
  ComponentType type=componentTypes.get(c);
  if (type == null) {
    type=new ComponentType();
    componentTypes.put(c,type);
  }
  return type;
}

Fixed version (ground truth):
public static final ComponentType getTypeFor(Class<? extends Component> c,World world){
  ComponentType type=componentTypes.get(c);
  if (type == null) {
    type=new ComponentType();
    componentTypes.put(c,type);
    world.getEntityManager().componentTypeAdded(type);
  }
  return type;
}
Program: 1551
Project: 1551
Buggy source:
public static int getId(Class<? extends Component> c){
  return getTypeFor(c).getId();
}

Fixed version (ground truth):
public static int getId(Class<? extends Component> c,World world){
  return getTypeFor(c,world).getId();
}
Program: 1552
Project: 1552
Buggy source:
public static long getBit(Class<? extends Component> c){
  return getTypeFor(c).getBit();
}

Fixed version (ground truth):
public static long getBit(Class<? extends Component> c,World world){
  return getTypeFor(c,world).getBit();
}