nus-yam/ex-repair huggingface dataset:
Program: 142306
Project: 142306
Buggy source:
public TransactionParser getParser(String name,String namespace,KXmlParser parser){
  if (name.toLowerCase().equals("String_Node_Str")) {
    return new AndroidCaseXmlParser(parser,CommCareApplication._().getUserStorage(ACase.STORAGE_KEY,ACase.class),decrypter,null,f.getParentFile());
  }
  return null;
}

Fixed version (ground truth):
public TransactionParser getParser(String name,String namespace,KXmlParser parser){
  if (StockXmlParsers.STOCK_XML_NAMESPACE.equals(namespace)) {
    return new StockXmlParsers(parser,CommCareApplication._().getUserStorage(Stock.STORAGE_KEY,Stock.class));
  }
 else   if (name.toLowerCase().equals("String_Node_Str")) {
    return new AndroidCaseXmlParser(parser,CommCareApplication._().getUserStorage(ACase.STORAGE_KEY,ACase.class),decrypter,null,f.getParentFile());
  }
  return null;
}
Program: 142308
Project: 142308
Buggy source:
@Override protected Boolean doTaskBackground(String... params){
  Log.d(CommCareWiFiDirectActivity.TAG,"String_Node_Str");
  for (int i=0; i < records.length; ++i) {
    FormRecord record=records[i];
    FormRecordCleanupTask.wipeRecord(c,platform,record);
  }
  return true;
}

Fixed version (ground truth):
@Override protected Boolean doTaskBackground(String... params){
  Log.d(CommCareWiFiDirectActivity.TAG,"String_Node_Str");
  for (int i=0; i < records.length; ++i) {
    FormRecord record=records[i];
    FormRecordCleanupTask.wipeRecord(c,record);
  }
  return true;
}
Program: 142309
Project: 142309
Buggy source:
public void fail(NotificationMessage message,boolean alwaysNotify,boolean canRetry){
  Toast.makeText(this,message.getTitle(),Toast.LENGTH_LONG).show();
  setUiState(UiState.error);
  retryCount++;
  if (retryCount > RETRY_LIMIT) {
    canRetry=false;
  }
  if (isAuto || alwaysNotify) {
    CommCareApplication._().reportNotificationMessage(message);
  }
  if (isAuto) {
    done(false);
  }
 else {
    if (alwaysNotify) {
      this.displayMessage=Localization.get("String_Node_Str",new String[]{message.getDetails()});
      this.canRetry=canRetry;
    }
 else {
      this.displayMessage=message.getDetails();
      this.canRetry=canRetry;
      String fullErrorMessage=message.getDetails();
      if (alwaysNotify) {
        fullErrorMessage=fullErrorMessage + message.getAction();
      }
      mainMessage.setText(fullErrorMessage);
    }
  }
  refreshView();
}

Fixed version (ground truth):
public void fail(NotificationMessage message,boolean alwaysNotify,boolean canRetry){
  Toast.makeText(this,message.getTitle(),Toast.LENGTH_LONG).show();
  setUiState(UiState.error);
  retryCount++;
  if (retryCount > RETRY_LIMIT) {
    canRetry=false;
  }
  if (isAuto || alwaysNotify) {
    CommCareApplication._().reportNotificationMessage(message);
  }
  if (isAuto) {
    done(false);
  }
 else {
    if (alwaysNotify) {
      this.displayMessage=Localization.get("String_Node_Str",new String[]{message.getDetails()});
      this.canRetry=canRetry;
      mainMessage.setText(displayMessage);
    }
 else {
      this.displayMessage=message.getDetails();
      this.canRetry=canRetry;
      String fullErrorMessage=message.getDetails();
      if (alwaysNotify) {
        fullErrorMessage=fullErrorMessage + message.getAction();
      }
      mainMessage.setText(fullErrorMessage);
    }
  }
  refreshView();
}
Program: 142311
Project: 142311
Buggy source:
/** 
 * Set the callback to null so we don't accidentally leak the  Activity instance.
 */
@Override public void onDetach(){
  super.onDetach();
  if (this.lastActivity != null) {
    lastActivity=boundActivity;
  }
  if (currentTask != null) {
    Log.i("String_Node_Str","String_Node_Str" + this.currentTask);
    currentTask.disconnect();
    unlock();
  }
}

Fixed version (ground truth):
/** 
 * Set the callback to null so we don't accidentally leak the  Activity instance.
 */
@Override public void onDetach(){
  super.onDetach();
  if (this.boundActivity != null) {
    lastActivity=boundActivity;
  }
  if (currentTask != null) {
    Log.i("String_Node_Str","String_Node_Str" + this.currentTask);
    currentTask.disconnect();
    unlock();
  }
}
Program: 142312
Project: 142312
Buggy source:
public void setModeToBasic(String message){
  this.uiState=UiState.basic;
  editProfileRef.setText("String_Node_Str");
  this.incomingRef=null;
  mainMessage.setText(message);
  addressEntryButton.setVisibility(View.VISIBLE);
  advancedView.setVisibility(View.GONE);
  mScanBarcodeButton.setVisibility(View.VISIBLE);
  startOverButton.setVisibility(View.GONE);
  installButton.setVisibility(View.GONE);
  retryButton.setVisibility(View.GONE);
}

Fixed version (ground truth):
public void setModeToBasic(String message){
  this.uiState=UiState.basic;
  buttonView.setVisibility(View.VISIBLE);
  editProfileRef.setText("String_Node_Str");
  this.incomingRef=null;
  mainMessage.setText(message);
  addressEntryButton.setVisibility(View.VISIBLE);
  advancedView.setVisibility(View.GONE);
  mScanBarcodeButton.setVisibility(View.VISIBLE);
  startOverButton.setVisibility(View.GONE);
  installButton.setVisibility(View.GONE);
  retryButton.setVisibility(View.GONE);
}
Program: 142313
Project: 142313
Buggy source:
public void setModeToError(String message,boolean canRetry){
  this.uiState=UiState.error;
  mainMessage.setText(message);
  advancedView.setVisibility(View.GONE);
  mScanBarcodeButton.setVisibility(View.GONE);
  installButton.setVisibility(View.GONE);
  startOverButton.setVisibility(View.VISIBLE);
  addressEntryButton.setVisibility(View.GONE);
  if (upgradeMode) {
    retryButton.setText(Localization.get("String_Node_Str"));
    startOverButton.setText(Localization.get("String_Node_Str"));
  }
 else {
    retryButton.setText(Localization.get("String_Node_Str"));
    startOverButton.setText(Localization.get("String_Node_Str"));
  }
  if (canRetry) {
    retryButton.setVisibility(View.VISIBLE);
  }
 else {
    retryButton.setVisibility(View.GONE);
  }
}

Fixed version (ground truth):
public void setModeToError(String message,boolean canRetry){
  buttonView.setVisibility(View.VISIBLE);
  this.uiState=UiState.error;
  mainMessage.setText(message);
  advancedView.setVisibility(View.GONE);
  mScanBarcodeButton.setVisibility(View.GONE);
  installButton.setVisibility(View.GONE);
  startOverButton.setVisibility(View.VISIBLE);
  addressEntryButton.setVisibility(View.GONE);
  if (upgradeMode) {
    retryButton.setText(Localization.get("String_Node_Str"));
    startOverButton.setText(Localization.get("String_Node_Str"));
  }
 else {
    retryButton.setText(Localization.get("String_Node_Str"));
    startOverButton.setText(Localization.get("String_Node_Str"));
  }
  if (canRetry) {
    retryButton.setVisibility(View.VISIBLE);
  }
 else {
    retryButton.setVisibility(View.GONE);
  }
}
Program: 142314
Project: 142314
Buggy source:
public void setModeToAutoUpgrade(){
  mScanBarcodeButton.setVisibility(View.GONE);
  installButton.setVisibility(View.GONE);
  startOverButton.setVisibility(View.GONE);
  addressEntryButton.setVisibility(View.GONE);
  retryButton.setVisibility(View.GONE);
}

Fixed version (ground truth):
public void setModeToAutoUpgrade(){
  buttonView.setVisibility(View.INVISIBLE);
}
Program: 142316
Project: 142316
Buggy source:
public void setModeToReady(String incomingRef){
  this.uiState=UiState.ready;
  mainMessage.setText(Localization.get("String_Node_Str"));
  editProfileRef.setText(incomingRef);
  advancedView.setVisibility(View.GONE);
  mScanBarcodeButton.setVisibility(View.GONE);
  installButton.setVisibility(View.VISIBLE);
  startOverButton.setText(Localization.get("String_Node_Str"));
  startOverButton.setVisibility(View.VISIBLE);
  addressEntryButton.setVisibility(View.GONE);
  retryButton.setVisibility(View.GONE);
}

Fixed version (ground truth):
public void setModeToReady(String incomingRef){
  buttonView.setVisibility(View.VISIBLE);
  this.uiState=UiState.ready;
  mainMessage.setText(Localization.get("String_Node_Str"));
  editProfileRef.setText(incomingRef);
  advancedView.setVisibility(View.GONE);
  mScanBarcodeButton.setVisibility(View.GONE);
  installButton.setVisibility(View.VISIBLE);
  startOverButton.setText(Localization.get("String_Node_Str"));
  startOverButton.setVisibility(View.VISIBLE);
  addressEntryButton.setVisibility(View.GONE);
  retryButton.setVisibility(View.GONE);
}
Program: 142317
Project: 142317
Buggy source:
public void setModeToAdvanced(){
  if (this.uiState == uiState.ready) {
    previousUrlPosition=-1;
    urlSpinner.setSelection(2);
  }
  this.uiState=UiState.advanced;
  mainMessage.setText(Localization.get("String_Node_Str"));
  advancedView.setVisibility(View.VISIBLE);
  mScanBarcodeButton.setVisibility(View.GONE);
  addressEntryButton.setVisibility(View.GONE);
  installButton.setVisibility(View.VISIBLE);
  startOverButton.setText(Localization.get("String_Node_Str"));
  startOverButton.setVisibility(View.VISIBLE);
  installButton.setEnabled(true);
  retryButton.setVisibility(View.GONE);
}

Fixed version (ground truth):
public void setModeToAdvanced(){
  if (this.uiState == uiState.ready) {
    previousUrlPosition=-1;
    urlSpinner.setSelection(2);
  }
  buttonView.setVisibility(View.VISIBLE);
  this.uiState=UiState.advanced;
  mainMessage.setText(Localization.get("String_Node_Str"));
  advancedView.setVisibility(View.VISIBLE);
  mScanBarcodeButton.setVisibility(View.GONE);
  addressEntryButton.setVisibility(View.GONE);
  installButton.setVisibility(View.VISIBLE);
  startOverButton.setText(Localization.get("String_Node_Str"));
  startOverButton.setVisibility(View.VISIBLE);
  installButton.setEnabled(true);
  retryButton.setVisibility(View.GONE);
}
Program: 142318
Project: 142318
Buggy source:
@Override public void writeTo(OutputStream outstream) throws IOException {
  super.writeTo(new CountingOutputStream(outstream,listener,submissionId));
}

Fixed version (ground truth):
@Override public void writeTo(OutputStream outstream) throws IOException {
  if (attempt != 1) {
    Log.i("String_Node_Str","String_Node_Str" + attempt);
  }
  super.writeTo(new CountingOutputStream(outstream,listener,submissionId));
  attempt++;
}
Program: 142319
Project: 142319
Buggy source:
private boolean submit(DeviceReportRecord slr,int index){
  File f=new File(slr.getFilePath());
  if (f.length() == 0) {
    return true;
  }
  this.startSubmission(index,f.length());
  HttpRequestGenerator generator;
  User user=CommCareApplication._().getSession().getLoggedInUser();
  if (user.getUserType().equals(User.TYPE_DEMO)) {
    generator=new HttpRequestGenerator();
  }
 else {
    generator=new HttpRequestGenerator(CommCareApplication._().getSession().getLoggedInUser());
  }
  MultipartEntity entity=new DataSubmissionEntity(this,index);
  EncryptedFileBody fb=new EncryptedFileBody(f,getDecryptCipher(new SecretKeySpec(slr.getKey(),"String_Node_Str")),"String_Node_Str");
  entity.addPart("String_Node_Str",fb);
  HttpResponse response=null;
  try {
    response=generator.postData(submissionUrl,entity);
  }
 catch (  ClientProtocolException e) {
    e.printStackTrace();
    return false;
  }
catch (  IOException e) {
    e.printStackTrace();
    return false;
  }
catch (  IllegalStateException e) {
    e.printStackTrace();
    return false;
  }
  int responseCode=response.getStatusLine().getStatusCode();
  ByteArrayOutputStream bos=new ByteArrayOutputStream();
  try {
    AndroidStreamUtil.writeFromInputToOutput(response.getEntity().getContent(),bos);
  }
 catch (  IllegalStateException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
  if (responseCode >= 200 && responseCode < 300) {
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
private boolean submit(DeviceReportRecord slr,int index){
  File f=new File(slr.getFilePath());
  if (f.length() == 0) {
    return true;
  }
  this.startSubmission(index,f.length());
  HttpRequestGenerator generator;
  User user=CommCareApplication._().getSession().getLoggedInUser();
  if (user.getUserType().equals(User.TYPE_DEMO)) {
    generator=new HttpRequestGenerator();
  }
 else {
    generator=new HttpRequestGenerator(user);
  }
  MultipartEntity entity=new DataSubmissionEntity(this,index);
  EncryptedFileBody fb=new EncryptedFileBody(f,getDecryptCipher(new SecretKeySpec(slr.getKey(),"String_Node_Str")),"String_Node_Str");
  entity.addPart("String_Node_Str",fb);
  HttpResponse response=null;
  try {
    response=generator.postData(submissionUrl,entity);
  }
 catch (  ClientProtocolException e) {
    e.printStackTrace();
    return false;
  }
catch (  IOException e) {
    e.printStackTrace();
    return false;
  }
catch (  IllegalStateException e) {
    e.printStackTrace();
    return false;
  }
  int responseCode=response.getStatusLine().getStatusCode();
  ByteArrayOutputStream bos=new ByteArrayOutputStream();
  try {
    AndroidStreamUtil.writeFromInputToOutput(response.getEntity().getContent(),bos);
  }
 catch (  IllegalStateException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
  if (responseCode >= 200 && responseCode < 300) {
    return true;
  }
 else {
    return false;
  }
}
Program: 142320
Project: 142320
Buggy source:
/** 
 * This method wipes out all local user data (users, referrals, etc) but leaves application resources in place. It makes no attempt to make sure this is a safe operation when called, so it shouldn't be used lightly.
 */
public void clearUserData() throws SessionUnavailableException {
  final String username=this.getSession().getLoggedInUser().getUsername();
  final Set<String> dbIdsToRemove=new HashSet<String>();
  this.getAppStorage(UserKeyRecord.class).removeAll(new EntityFilter<UserKeyRecord>(){
    @Override public boolean matches(    UserKeyRecord ukr){
      dbIdsToRemove.add(ukr.getUuid());
      return ukr.getUsername().toLowerCase().equals(username.toLowerCase());
    }
  }
);
  logout();
  Editor sharedPreferencesEditor=CommCareApplication._().getCurrentApp().getAppPreferences().edit();
  sharedPreferencesEditor.putString(CommCarePreferences.LAST_LOGGED_IN_USER,null);
  sharedPreferencesEditor.commit();
  for (  String id : dbIdsToRemove) {
    this.getDatabasePath(CommCareUserOpenHelper.getDbName(id));
  }
}

Fixed version (ground truth):
/** 
 * This method wipes out all local user data (users, referrals, etc) but leaves application resources in place. It makes no attempt to make sure this is a safe operation when called, so it shouldn't be used lightly.
 */
public void clearUserData() throws SessionUnavailableException {
  final String username=this.getSession().getLoggedInUser().getUsername();
  final Set<String> dbIdsToRemove=new HashSet<String>();
  this.getAppStorage(UserKeyRecord.class).removeAll(new EntityFilter<UserKeyRecord>(){
    @Override public boolean matches(    UserKeyRecord ukr){
      dbIdsToRemove.add(ukr.getUuid());
      return ukr.getUsername().toLowerCase().equals(username.toLowerCase());
    }
  }
);
  logout();
  Editor sharedPreferencesEditor=CommCareApplication._().getCurrentApp().getAppPreferences().edit();
  sharedPreferencesEditor.putString(CommCarePreferences.LAST_LOGGED_IN_USER,null);
  sharedPreferencesEditor.commit();
  for (  String id : dbIdsToRemove) {
    this.getDatabasePath(CommCareUserOpenHelper.getDbName(id)).delete();
  }
}
Program: 142321
Project: 142321
Buggy source:
private void fire(){
  CommCareVerificationActivity last=(CommCareVerificationActivity)this.getLastNonConfigurationInstance();
  if (last == null) {
    missingMediaPrompt.setText("String_Node_Str");
    retryButton.setText("String_Node_Str");
    verifyResourceInstall();
  }
 else {
    missingMediaPrompt.setText(last.missingMediaPrompt.getText());
    if (last.task != null && last.task.getStatus() == Status.RUNNING) {
      this.task=last.task;
      last.task.setListener(this);
    }
 else {
    }
  }
}

Fixed version (ground truth):
private void fire(){
  CommCareVerificationActivity last=(CommCareVerificationActivity)this.getDestroyedActivityState();
  if (last == null) {
    missingMediaPrompt.setText("String_Node_Str");
    retryButton.setText("String_Node_Str");
    verifyResourceInstall();
  }
 else {
    missingMediaPrompt.setText(last.missingMediaPrompt.getText());
    if (last.task != null && last.task.getStatus() == Status.RUNNING) {
      this.task=last.task;
      last.task.setListener(this);
    }
 else {
    }
  }
}
Program: 142323
Project: 142323
Buggy source:
@Override protected Boolean doTaskBackground(FormRecord... params){
  publishProgress(Localization.get("String_Node_Str"));
  if (!(dumpDirectory.isDirectory())) {
    return false;
  }
  File[] files=dumpDirectory.listFiles();
  int counter=0;
  results=new Long[files.length];
  for (int i=0; i < files.length; ++i) {
    results[i]=FormUploadUtil.FAILURE;
  }
  boolean allSuccessful=true;
  for (int i=0; i < files.length; i++) {
    publishProgress(Localization.get("String_Node_Str",new String[]{"String_Node_Str" + (i + 1)}));
    File f=files[i];
    if (!(f.isDirectory())) {
      return false;
    }
    try {
      User user=CommCareApplication._().getSession().getLoggedInUser();
      results[i]=FormUploadUtil.sendInstance(counter,f,url,user);
      if (results[i] == FormUploadUtil.FULL_SUCCESS) {
        FileUtil.deleteFile(f);
      }
 else       if (results[i] == FormUploadUtil.TRANSPORT_FAILURE) {
        allSuccessful=false;
        publishProgress(Localization.get("String_Node_Str"));
      }
 else {
        allSuccessful=false;
        publishProgress(Localization.get("String_Node_Str",new String[]{f.getAbsolutePath()}));
      }
      counter++;
    }
 catch (    FileNotFoundException fe) {
      Log.e("String_Node_Str",Localization.get("String_Node_Str",new String[]{f.getAbsolutePath()}),fe);
      publishProgress(Localization.get("String_Node_Str",new String[]{fe.getMessage()}));
    }
  }
  return allSuccessful;
}

Fixed version (ground truth):
@Override protected Boolean doTaskBackground(FormRecord... params){
  publishProgress(Localization.get("String_Node_Str"));
  if (!(dumpDirectory.isDirectory())) {
    return false;
  }
  File[] files=dumpDirectory.listFiles();
  int counter=0;
  results=new Long[files.length];
  for (int i=0; i < files.length; ++i) {
    results[i]=FormUploadUtil.FAILURE;
  }
  boolean allSuccessful=true;
  for (int i=0; i < files.length; i++) {
    publishProgress(Localization.get("String_Node_Str",new String[]{"String_Node_Str" + (i + 1)}));
    File f=files[i];
    if (!(f.isDirectory())) {
      return false;
    }
    try {
      User user=CommCareApplication._().getSession().getLoggedInUser();
      results[i]=FormUploadUtil.sendInstance(counter,f,url,user);
      if (results[i] == FormUploadUtil.FULL_SUCCESS) {
        FileUtil.deleteFile(f);
      }
 else       if (results[i] == FormUploadUtil.TRANSPORT_FAILURE) {
        allSuccessful=false;
        publishProgress(Localization.get("String_Node_Str"));
        return allSuccessful;
      }
 else {
        allSuccessful=false;
        publishProgress(Localization.get("String_Node_Str",new String[]{f.getAbsolutePath()}));
      }
      counter++;
    }
 catch (    FileNotFoundException fe) {
      Log.e("String_Node_Str",Localization.get("String_Node_Str",new String[]{f.getAbsolutePath()}),fe);
      publishProgress(Localization.get("String_Node_Str",new String[]{fe.getMessage()}));
    }
  }
  return allSuccessful;
}
Program: 142327
Project: 142327
Buggy source:
public DumpTask(Context c,CommCarePlatform platform,TextView outputTextView) throws SessionUnavailableException {
  this.c=c;
  storage=CommCareApplication._().getUserStorage(FormRecord.class);
  this.outputTextView=outputTextView;
  platform=this.platform;
}

Fixed version (ground truth):
public DumpTask(Context c,CommCarePlatform platform,TextView outputTextView) throws SessionUnavailableException {
  this.c=c;
  storage=CommCareApplication._().getUserStorage(FormRecord.class);
  this.outputTextView=outputTextView;
  taskId=CommCareFormDumpActivity.BULK_DUMP_ID;
  platform=this.platform;
}
Program: 142328
Project: 142328
Buggy source:
public SendTask(Context c,CommCarePlatform platform,String url,TextView outputTextView) throws SessionUnavailableException {
  this.c=c;
  this.url=url;
  storage=CommCareApplication._().getUserStorage(FormRecord.class);
  this.outputTextView=outputTextView;
  platform=this.platform;
}

Fixed version (ground truth):
public SendTask(Context c,CommCarePlatform platform,String url,TextView outputTextView) throws SessionUnavailableException {
  this.c=c;
  this.url=url;
  storage=CommCareApplication._().getUserStorage(FormRecord.class);
  this.outputTextView=outputTextView;
  taskId=CommCareFormDumpActivity.BULK_SEND_ID;
  platform=this.platform;
}
Program: 142333
Project: 142333
Buggy source:
public static File[] getDumpFiles(){
  ArrayList<String> externalMounts=FileUtil.getExternalMounts();
  if (externalMounts.size() == 0) {
    return new File[]{};
  }
  String baseDir=externalMounts.get(0);
  String folderName=Localization.get("String_Node_Str");
  File dumpDirectory=new File(baseDir + "String_Node_Str" + folderName);
  File[] files=dumpDirectory.listFiles();
  return files;
}

Fixed version (ground truth):
public static File[] getDumpFiles(){
  ArrayList<String> externalMounts=FileUtil.getExternalMounts();
  if (externalMounts.size() == 0) {
    return new File[]{};
  }
  String baseDir=externalMounts.get(0);
  String folderName=Localization.get("String_Node_Str");
  File dumpDirectory=new File(baseDir + "String_Node_Str" + folderName);
  File[] files=dumpDirectory.listFiles();
  if (files == null) {
    files=new File[]{};
  }
  return files;
}
Program: 142334
Project: 142334
Buggy source:
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,String key){
  Localization.setLocale(sharedPreferences.getString(key,"String_Node_Str"));
}

Fixed version (ground truth):
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,String key){
  if (key.equals("String_Node_Str")) {
    Localization.setLocale(sharedPreferences.getString(key,"String_Node_Str"));
  }
}
Program: 142335
Project: 142335
Buggy source:
public static FormInstance loadFixture(String refId,String userId){
  IStorageUtilityIndexed<FormInstance> userFixtureStorage=CommCareApplication._().getUserStorage("String_Node_Str",FormInstance.class);
  IStorageUtilityIndexed<FormInstance> appFixtureStorage=CommCareApplication._().getAppStorage("String_Node_Str",FormInstance.class);
  Vector<Integer> userFixtures=userFixtureStorage.getIDsForValue(FormInstance.META_ID,refId);
  if (userFixtures.size() == 1) {
    return (FormInstance)userFixtureStorage.read(userFixtures.elementAt(0).intValue());
  }
 else   if (userFixtures.size() > 1) {
    Vector<Integer> relevantUserFixtures=userFixtureStorage.getIDsForValue(FormInstance.META_XMLNS,userId);
    if (relevantUserFixtures.size() != 0) {
      Integer userFixture=ArrayUtilities.intersectSingle(userFixtures,relevantUserFixtures);
      if (userFixture != null) {
        return (FormInstance)userFixtureStorage.read(userFixture.intValue());
      }
    }
  }
  Vector<Integer> appFixtures=appFixtureStorage.getIDsForValue(FormInstance.META_ID,refId);
  Integer globalFixture=ArrayUtilities.intersectSingle(appFixtureStorage.getIDsForValue(FormInstance.META_XMLNS,"String_Node_Str"),appFixtures);
  if (globalFixture != null) {
    return (FormInstance)appFixtureStorage.read(globalFixture.intValue());
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
public static FormInstance loadFixture(String refId,String userId){
  IStorageUtilityIndexed<FormInstance> userFixtureStorage=CommCareApplication._().getUserStorage("String_Node_Str",FormInstance.class);
  IStorageUtilityIndexed<FormInstance> appFixtureStorage=CommCareApplication._().getAppStorage("String_Node_Str",FormInstance.class);
  Vector<Integer> userFixtures=userFixtureStorage.getIDsForValue(FormInstance.META_ID,refId);
  if (userFixtures.size() == 1) {
    return (FormInstance)userFixtureStorage.read(userFixtures.elementAt(0).intValue());
  }
 else   if (userFixtures.size() > 1) {
    Vector<Integer> relevantUserFixtures=userFixtureStorage.getIDsForValue(FormInstance.META_XMLNS,userId);
    if (relevantUserFixtures.size() != 0) {
      Integer userFixture=ArrayUtilities.intersectSingle(userFixtures,relevantUserFixtures);
      if (userFixture != null) {
        return (FormInstance)userFixtureStorage.read(userFixture.intValue());
      }
    }
  }
  Vector<Integer> appFixtures=appFixtureStorage.getIDsForValue(FormInstance.META_ID,refId);
  Integer globalFixture=ArrayUtilities.intersectSingle(appFixtureStorage.getIDsForValue(FormInstance.META_XMLNS,"String_Node_Str"),appFixtures);
  if (globalFixture != null) {
    return (FormInstance)appFixtureStorage.read(globalFixture.intValue());
  }
 else {
    Integer userFixture=ArrayUtilities.intersectSingle(appFixtureStorage.getIDsForValue(FormInstance.META_XMLNS,userId),appFixtures);
    if (userFixture != null) {
      return (FormInstance)appFixtureStorage.read(userFixture.intValue());
    }
    return null;
  }
}
Program: 142337
Project: 142337
Buggy source:
private View getView(Context context,String text,String form){
  System.out.println("String_Node_Str");
  View retVal;
  if ("String_Node_Str".equals(form)) {
    ImageView iv=(ImageView)View.inflate(context,R.layout.entity_item_image,null);
    retVal=iv;
    if (text != null) {
      try {
        Bitmap b=BitmapFactory.decodeStream(ReferenceManager._().DeriveReference(text).getStream());
        iv.setImageBitmap(b);
      }
 catch (      IOException e) {
        e.printStackTrace();
      }
catch (      InvalidReferenceException e) {
        e.printStackTrace();
      }
    }
  }
 else {
    TextView tv=(TextView)View.inflate(context,R.layout.entity_item_text,null);
    retVal=tv;
    if (text != null) {
      tv.setText(text);
    }
  }
  return retVal;
}

Fixed version (ground truth):
private View getView(Context context,String text,String form){
  View retVal;
  if ("String_Node_Str".equals(form)) {
    ImageView iv=(ImageView)View.inflate(context,R.layout.entity_item_image,null);
    retVal=iv;
    if (text != null) {
      try {
        Bitmap b=BitmapFactory.decodeStream(ReferenceManager._().DeriveReference(text).getStream());
        iv.setImageBitmap(b);
      }
 catch (      IOException e) {
        e.printStackTrace();
      }
catch (      InvalidReferenceException e) {
        e.printStackTrace();
      }
    }
  }
 else {
    TextView tv=(TextView)View.inflate(context,R.layout.entity_item_text,null);
    retVal=tv;
    if (text != null) {
      tv.setText(text);
    }
  }
  return retVal;
}
Program: 142344
Project: 142344
Buggy source:
protected boolean checkAndStartUnsentTask(ProcessTaskListener listener) throws SessionUnavailableException {
  SqlIndexedStorageUtility<FormRecord> storage=CommCareApplication._().getStorage(FormRecord.STORAGE_KEY,FormRecord.class);
  Vector<Integer> ids=storage.getIDsForValues(new String[]{FormRecord.META_STATUS},new Object[]{FormRecord.STATUS_UNSENT});
  ids.addAll(storage.getIDsForValues(new String[]{FormRecord.META_STATUS},new Object[]{FormRecord.STATUS_COMPLETE}));
  if (ids.size() > 0) {
    FormRecord[] records=new FormRecord[ids.size()];
    for (int i=0; i < ids.size(); ++i) {
      records[i]=storage.read(ids.elementAt(i).intValue());
    }
    SharedPreferences settings=PreferenceManager.getDefaultSharedPreferences(CommCareApplication._());
    mProcess=new ProcessAndSendTask(this,platform,settings.getString("String_Node_Str",this.getString(R.string.PostURL)));
    mProcess.setListeners(this,CommCareApplication._().getSession().startDataSubmissionListener());
    showDialog(DIALOG_SEND_UNSENT);
    mProcess.execute(records);
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
protected boolean checkAndStartUnsentTask(ProcessTaskListener listener) throws SessionUnavailableException {
  SqlIndexedStorageUtility<FormRecord> storage=CommCareApplication._().getStorage(FormRecord.STORAGE_KEY,FormRecord.class);
  Vector<Integer> ids=storage.getIDsForValues(new String[]{FormRecord.META_STATUS},new Object[]{FormRecord.STATUS_UNSENT});
  ids.addAll(storage.getIDsForValues(new String[]{FormRecord.META_STATUS},new Object[]{FormRecord.STATUS_COMPLETE}));
  if (ids.size() > 0) {
    FormRecord[] records=new FormRecord[ids.size()];
    for (int i=0; i < ids.size(); ++i) {
      records[i]=storage.read(ids.elementAt(i).intValue());
    }
    SharedPreferences settings=PreferenceManager.getDefaultSharedPreferences(CommCareApplication._());
    mProcess=new ProcessAndSendTask(this,platform,settings.getString("String_Node_Str",this.getString(R.string.PostURL)));
    mProcess.setListeners(listener,CommCareApplication._().getSession().startDataSubmissionListener());
    showDialog(DIALOG_SEND_UNSENT);
    mProcess.execute(records);
    return true;
  }
 else {
    return false;
  }
}
Program: 142346
Project: 142346
Buggy source:
/** 
 * Called when the activity is first created. 
 */
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (savedInstanceState != null) {
    wasExternal=savedInstanceState.getBoolean("String_Node_Str");
  }
  currentHome=this;
  setContentView(R.layout.mainnew);
  configUi();
  Intent startup=this.getIntent();
  if (startup != null && startup.hasExtra(SESSION_REQUEST)) {
    wasExternal=true;
    String sessionRequest=startup.getStringExtra(SESSION_REQUEST);
    SessionStateDescriptor ssd=new SessionStateDescriptor();
    ssd.fromBundle(sessionRequest);
    CommCareApplication._().getCurrentSessionWrapper().loadFromStateDescription(ssd);
    this.startNextFetch();
    return;
  }
}

Fixed version (ground truth):
/** 
 * Called when the activity is first created. 
 */
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (savedInstanceState != null) {
    wasExternal=savedInstanceState.getBoolean("String_Node_Str");
  }
  if (currentHome != null) {
    this.mCurrentDialog=currentHome.mCurrentDialog;
  }
  currentHome=this;
  setContentView(R.layout.mainnew);
  configUi();
  Intent startup=this.getIntent();
  if (startup != null && startup.hasExtra(SESSION_REQUEST)) {
    wasExternal=true;
    String sessionRequest=startup.getStringExtra(SESSION_REQUEST);
    SessionStateDescriptor ssd=new SessionStateDescriptor();
    ssd.fromBundle(sessionRequest);
    CommCareApplication._().getCurrentSessionWrapper().loadFromStateDescription(ssd);
    this.startNextFetch();
    return;
  }
}
Program: 142347
Project: 142347
Buggy source:
@Override public void onConfigurationChanged(Configuration newConfig){
  super.onConfigurationChanged(newConfig);
  setContentView(R.layout.mainnew);
  CommCareHomeActivity.currentHome=this;
  configUi();
}

Fixed version (ground truth):
@Override public void onConfigurationChanged(Configuration newConfig){
  super.onConfigurationChanged(newConfig);
  setContentView(R.layout.mainnew);
  if (currentHome != null) {
    this.mCurrentDialog=currentHome.mCurrentDialog;
  }
  CommCareHomeActivity.currentHome=this;
  configUi();
  refreshView();
}
Program: 142349
Project: 142349
Buggy source:
private void returnToLogin(String message){
  Toast.makeText(this,message,Toast.LENGTH_LONG);
  Intent i=new Intent(getApplicationContext(),LoginActivity.class);
  startActivityForResult(i,LOGIN_USER);
}

Fixed version (ground truth):
private void returnToLogin(String message){
  Toast.makeText(this,message,Toast.LENGTH_LONG);
  Intent i=new Intent(getApplicationContext(),LoginActivity.class);
  i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
  startActivityForResult(i,LOGIN_USER);
}
Program: 142350
Project: 142350
Buggy source:
@Override protected Dialog onCreateDialog(int id){
  AlertDialog mNoStorageDialog=new AlertDialog.Builder(this).create();
  mNoStorageDialog.setTitle(title);
  mNoStorageDialog.setMessage(message + "String_Node_Str" + Localization.get("String_Node_Str"));
  DialogInterface.OnClickListener noStorageButton=new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int i){
      Intent intent=new Intent(UnrecoverableErrorActivity.this,CommCareHomeActivity.class);
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
      UnrecoverableErrorActivity.this.startActivity(intent);
      System.runFinalizersOnExit(true);
      System.exit(0);
    }
  }
;
  mNoStorageDialog.setCancelable(false);
  mNoStorageDialog.setButton(Localization.get("String_Node_Str"),noStorageButton);
  return mNoStorageDialog;
}

Fixed version (ground truth):
@Override protected Dialog onCreateDialog(int id){
  AlertDialog mNoStorageDialog=new AlertDialog.Builder(this).create();
  mNoStorageDialog.setTitle(title);
  mNoStorageDialog.setMessage(message + "String_Node_Str" + Localization.get("String_Node_Str"));
  DialogInterface.OnClickListener noStorageButton=new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int i){
      Intent intent=new Intent(UnrecoverableErrorActivity.this,CommCareHomeActivity.class);
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
      UnrecoverableErrorActivity.this.startActivity(intent);
      UnrecoverableErrorActivity.this.moveTaskToBack(true);
      System.runFinalizersOnExit(true);
      System.exit(0);
    }
  }
;
  mNoStorageDialog.setCancelable(false);
  mNoStorageDialog.setButton(Localization.get("String_Node_Str"),noStorageButton);
  return mNoStorageDialog;
}
Program: 142351
Project: 142351
Buggy source:
public void onClick(DialogInterface dialog,int i){
  Intent intent=new Intent(UnrecoverableErrorActivity.this,CommCareHomeActivity.class);
  intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
  UnrecoverableErrorActivity.this.startActivity(intent);
  System.runFinalizersOnExit(true);
  System.exit(0);
}

Fixed version (ground truth):
public void onClick(DialogInterface dialog,int i){
  Intent intent=new Intent(UnrecoverableErrorActivity.this,CommCareHomeActivity.class);
  intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
  UnrecoverableErrorActivity.this.startActivity(intent);
  UnrecoverableErrorActivity.this.moveTaskToBack(true);
  System.runFinalizersOnExit(true);
  System.exit(0);
}
Program: 142353
Project: 142353
Buggy source:
@Override protected void onSaveInstanceState(Bundle outState){
  super.onSaveInstanceState(outState);
  outState.putString("String_Node_Str",uiState.toString());
  outState.putString("String_Node_Str",uiState == UiState.advanced ? editProfileRef.getText().toString() : incomingRef);
  outState.putBoolean(KEY_UPGRADE_MODE,upgradeMode);
  outState.putBoolean(KEY_AUTO,isAuto);
}

Fixed version (ground truth):
@Override protected void onSaveInstanceState(Bundle outState){
  super.onSaveInstanceState(outState);
  outState.putString("String_Node_Str",uiState.toString());
  outState.putString("String_Node_Str",incomingRef);
  outState.putBoolean(KEY_UPGRADE_MODE,upgradeMode);
  outState.putBoolean(KEY_AUTO,isAuto);
}
Program: 142354
Project: 142354
Buggy source:
private int initResources(){
  try {
    AndroidCommCarePlatform platform=CommCareApplication._().getCommCarePlatform();
    ResourceTable global=platform.getGlobalResourceTable();
    Resource profile=global.getResourceWithId("String_Node_Str");
    if (profile != null && profile.getStatus() == Resource.RESOURCE_STATUS_INSTALLED) {
      platform.initialize(global);
      Localization.setLocale(Localization.getGlobalLocalizerAdvanced().getAvailableLocales()[0]);
      SizeBoundVector<UnresolvedResourceException> problems=new SizeBoundVector<UnresolvedResourceException>(10);
      if (problems.size() > 0) {
        System.out.println("String_Node_Str");
      }
      global.verifyInstallation(problems);
      return STATE_READY;
    }
 else {
      return STATE_UNINSTALLED;
    }
  }
 catch (  Exception e) {
    Log.i("String_Node_Str","String_Node_Str");
    Log.i("String_Node_Str","String_Node_Str" + e.getMessage());
    e.printStackTrace();
    ExceptionReportTask ert=new ExceptionReportTask();
    ert.execute(e);
    return STATE_CORRUPTED;
  }
}

Fixed version (ground truth):
private int initResources(){
  try {
    AndroidCommCarePlatform platform=CommCareApplication._().getCommCarePlatform();
    ResourceTable global=platform.getGlobalResourceTable();
    Resource profile=global.getResourceWithId("String_Node_Str");
    if (profile != null && profile.getStatus() == Resource.RESOURCE_STATUS_INSTALLED) {
      platform.initialize(global);
      Localization.setLocale(Localization.getGlobalLocalizerAdvanced().getAvailableLocales()[0]);
      return STATE_READY;
    }
 else {
      return STATE_UNINSTALLED;
    }
  }
 catch (  Exception e) {
    Log.i("String_Node_Str","String_Node_Str");
    Log.i("String_Node_Str","String_Node_Str" + e.getMessage());
    e.printStackTrace();
    ExceptionReportTask ert=new ExceptionReportTask();
    ert.execute(e);
    return STATE_CORRUPTED;
  }
}
Program: 142355
Project: 142355
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (savedInstanceState != null) {
    mResultIsMap=savedInstanceState.getBoolean(EXTRA_IS_MAP,false);
  }
  setContentView(R.layout.entity_select_layout);
  searchbox=(EditText)findViewById(R.id.searchbox);
  header=(LinearLayout)findViewById(R.id.entity_select_header);
  barcodeButton=(ImageButton)findViewById(R.id.barcodeButton);
  searchbox.addTextChangedListener(this);
  searchbox.requestFocus();
  session=CommCareApplication._().getCurrentSession();
  Vector<Entry> entries=session.getEntriesForCommand(session.getCommand());
  prototype=entries.elementAt(0);
  setTitle(getString(R.string.application_name) + "String_Node_Str" + "String_Node_Str");
  selectDatum=session.getNeededDatum();
  barcodeButton.setOnClickListener(new OnClickListener(){
    public void onClick(    View v){
      Intent i=new Intent("String_Node_Str");
      try {
        startActivityForResult(i,BARCODE_FETCH);
      }
 catch (      ActivityNotFoundException anfe) {
        Toast noReader=Toast.makeText(EntitySelectActivity.this,"String_Node_Str",Toast.LENGTH_LONG);
        noReader.show();
      }
    }
  }
);
  if (selectDatum.getLongDetail() != null && this.getIntent().hasExtra(EXTRA_ENTITY_KEY)) {
    TreeReference entity=getEntityFromID(this.getIntent().getStringExtra(EXTRA_ENTITY_KEY));
    if (entity != null) {
      Intent i=getDetailIntent(entity);
      startActivityForResult(i,CONFIRM_SELECT);
    }
 else {
      refreshView();
    }
  }
 else {
    refreshView();
  }
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (savedInstanceState != null) {
    mResultIsMap=savedInstanceState.getBoolean(EXTRA_IS_MAP,false);
  }
  setContentView(R.layout.entity_select_layout);
  searchbox=(EditText)findViewById(R.id.searchbox);
  header=(LinearLayout)findViewById(R.id.entity_select_header);
  barcodeButton=(ImageButton)findViewById(R.id.barcodeButton);
  session=CommCareApplication._().getCurrentSession();
  Vector<Entry> entries=session.getEntriesForCommand(session.getCommand());
  prototype=entries.elementAt(0);
  setTitle(getString(R.string.application_name) + "String_Node_Str" + "String_Node_Str");
  selectDatum=session.getNeededDatum();
  barcodeButton.setOnClickListener(new OnClickListener(){
    public void onClick(    View v){
      Intent i=new Intent("String_Node_Str");
      try {
        startActivityForResult(i,BARCODE_FETCH);
      }
 catch (      ActivityNotFoundException anfe) {
        Toast noReader=Toast.makeText(EntitySelectActivity.this,"String_Node_Str",Toast.LENGTH_LONG);
        noReader.show();
      }
    }
  }
);
  searchbox.addTextChangedListener(this);
  searchbox.requestFocus();
}
Program: 142356
Project: 142356
Buggy source:
public void afterTextChanged(Editable s){
  if (searchbox.getText() == s) {
    adapter.applyFilter(s.toString());
  }
}

Fixed version (ground truth):
public void afterTextChanged(Editable s){
  if (searchbox.getText() == s) {
    if (adapter != null) {
      adapter.applyFilter(s.toString());
    }
  }
}
Program: 142357
Project: 142357
Buggy source:
@Override protected void onActivityResult(int requestCode,int resultCode,Intent intent){
switch (requestCode) {
case BARCODE_FETCH:
    if (resultCode == Activity.RESULT_OK) {
      String result=intent.getStringExtra("String_Node_Str");
      this.searchbox.setText(result);
    }
  break;
case CONFIRM_SELECT:
if (resultCode == RESULT_OK) {
  Intent i=new Intent(this.getIntent());
  i.putExtras(intent.getExtras());
  setResult(RESULT_OK,i);
  finish();
  return;
}
 else {
  if (mResultIsMap) {
    mResultIsMap=false;
    Intent i=new Intent(this,EntityMapActivity.class);
    this.startActivityForResult(i,MAP_SELECT);
    return;
  }
  Intent i=new Intent(this.getIntent());
  setResult(RESULT_CANCELED,i);
  if (this.getIntent().hasExtra(EXTRA_ENTITY_KEY)) {
    refreshView();
  }
  return;
}
case MAP_SELECT:
if (resultCode == RESULT_OK) {
TreeReference r=CommCareApplication._().deserializeFromIntent(intent,EntityDetailActivity.CONTEXT_REFERENCE,TreeReference.class);
Intent i=this.getDetailIntent(r);
mResultIsMap=true;
startActivityForResult(i,CONFIRM_SELECT);
return;
}
 else {
refreshView();
return;
}
default :
super.onActivityResult(requestCode,resultCode,intent);
}
}

Fixed version (ground truth):
@Override protected void onActivityResult(int requestCode,int resultCode,Intent intent){
switch (requestCode) {
case BARCODE_FETCH:
    if (resultCode == Activity.RESULT_OK) {
      String result=intent.getStringExtra("String_Node_Str");
      this.searchbox.setText(result);
    }
  break;
case CONFIRM_SELECT:
if (resultCode == RESULT_OK) {
  Intent i=new Intent(this.getIntent());
  i.putExtras(intent.getExtras());
  setResult(RESULT_OK,i);
  finish();
  return;
}
 else {
  if (mResultIsMap) {
    mResultIsMap=false;
    Intent i=new Intent(this,EntityMapActivity.class);
    this.startActivityForResult(i,MAP_SELECT);
    return;
  }
  resuming=true;
  return;
}
case MAP_SELECT:
if (resultCode == RESULT_OK) {
TreeReference r=CommCareApplication._().deserializeFromIntent(intent,EntityDetailActivity.CONTEXT_REFERENCE,TreeReference.class);
Intent i=this.getDetailIntent(r);
mResultIsMap=true;
startActivityForResult(i,CONFIRM_SELECT);
return;
}
 else {
refreshView();
return;
}
default :
super.onActivityResult(requestCode,resultCode,intent);
}
}
Program: 142358
Project: 142358
Buggy source:
@Override protected void onActivityResult(int requestCode,int resultCode,Intent intent){
switch (requestCode) {
case BARCODE_FETCH:
    if (resultCode == Activity.RESULT_OK) {
      String result=intent.getStringExtra("String_Node_Str");
      this.searchbox.setText(result);
    }
  break;
case CONFIRM_SELECT:
if (resultCode == RESULT_OK) {
  Intent i=new Intent(this.getIntent());
  i.putExtras(intent.getExtras());
  setResult(RESULT_OK,i);
  finish();
  return;
}
 else {
  if (mResultIsMap) {
    mResultIsMap=false;
    Intent i=new Intent(this,EntityMapActivity.class);
    this.startActivityForResult(i,MAP_SELECT);
    return;
  }
  resuming=true;
  return;
}
case MAP_SELECT:
if (resultCode == RESULT_OK) {
TreeReference r=CommCareApplication._().deserializeFromIntent(intent,EntityDetailActivity.CONTEXT_REFERENCE,TreeReference.class);
Intent i=this.getDetailIntent(r);
mResultIsMap=true;
startActivityForResult(i,CONFIRM_SELECT);
return;
}
 else {
refreshView();
return;
}
default :
super.onActivityResult(requestCode,resultCode,intent);
}
}

Fixed version (ground truth):
@Override protected void onActivityResult(int requestCode,int resultCode,Intent intent){
switch (requestCode) {
case BARCODE_FETCH:
    if (resultCode == Activity.RESULT_OK) {
      String result=intent.getStringExtra("String_Node_Str");
      this.searchbox.setText(result);
    }
  break;
case CONFIRM_SELECT:
resuming=true;
if (resultCode == RESULT_OK) {
Intent i=new Intent(this.getIntent());
i.putExtras(intent.getExtras());
setResult(RESULT_OK,i);
finish();
return;
}
 else {
if (mResultIsMap) {
  mResultIsMap=false;
  Intent i=new Intent(this,EntityMapActivity.class);
  this.startActivityForResult(i,MAP_SELECT);
  return;
}
return;
}
case MAP_SELECT:
if (resultCode == RESULT_OK) {
TreeReference r=CommCareApplication._().deserializeFromIntent(intent,EntityDetailActivity.CONTEXT_REFERENCE,TreeReference.class);
Intent i=this.getDetailIntent(r);
mResultIsMap=true;
startActivityForResult(i,CONFIRM_SELECT);
return;
}
 else {
refreshView();
return;
}
default :
super.onActivityResult(requestCode,resultCode,intent);
}
}
Program: 142360
Project: 142360
Buggy source:
private boolean upgradeTwoEighttoTwoNine(SQLiteDatabase database){
  String ssdTable=TableBuilder.scrubName(SessionStateDescriptor.STORAGE_KEY);
  String tempssdTable=TableBuilder.scrubName(SessionStateDescriptor.STORAGE_KEY + "String_Node_Str");
  int oldRows=countRows(database,ssdTable);
  try {
    database.beginTransaction();
    TableBuilder builder=new TableBuilder(AndroidLogEntry.STORAGE_KEY);
    builder.addData(new AndroidLogEntry());
    database.execSQL(builder.getTableCreateString());
    builder=new TableBuilder(DeviceReportRecord.STORAGE_KEY);
    builder.addData(new DeviceReportRecord());
    database.execSQL(builder.getTableCreateString());
    database.execSQL(String.format("String_Node_Str",ssdTable,tempssdTable));
    builder=new TableBuilder(SessionStateDescriptor.STORAGE_KEY);
    builder.setUnique(SessionStateDescriptor.META_FORM_RECORD_ID);
    builder.addData(new SessionStateDescriptor());
    database.execSQL(builder.getTableCreateString());
    String cols=builder.getColumns();
    database.execSQL(String.format("String_Node_Str" + "String_Node_Str" + "String_Node_Str",ssdTable,cols,cols,tempssdTable));
    database.execSQL(String.format("String_Node_Str",tempssdTable));
    database.setTransactionSuccessful();
    int newRows=countRows(database,ssdTable);
    if (oldRows != newRows) {
      Logger.log(AndroidLogger.TYPE_MAINTENANCE,"String_Node_Str");
    }
    return true;
  }
  finally {
    database.endTransaction();
  }
}

Fixed version (ground truth):
private boolean upgradeTwoEighttoTwoNine(SQLiteDatabase database){
  String ssdTable=TableBuilder.scrubName(SessionStateDescriptor.STORAGE_KEY);
  String tempssdTable=TableBuilder.scrubName(SessionStateDescriptor.STORAGE_KEY + "String_Node_Str");
  int oldRows=countRows(database,ssdTable);
  try {
    database.beginTransaction();
    TableBuilder builder=new TableBuilder(AndroidLogEntry.STORAGE_KEY);
    builder.addData(new AndroidLogEntry());
    database.execSQL(builder.getTableCreateString());
    builder=new TableBuilder(DeviceReportRecord.STORAGE_KEY);
    builder.addData(new DeviceReportRecord());
    database.execSQL(builder.getTableCreateString());
    database.execSQL(String.format("String_Node_Str",ssdTable,tempssdTable));
    builder=new TableBuilder(SessionStateDescriptor.STORAGE_KEY);
    builder.setUnique(SessionStateDescriptor.META_FORM_RECORD_ID);
    builder.addData(new SessionStateDescriptor());
    database.execSQL(builder.getTableCreateString());
    String cols=builder.getColumns();
    database.execSQL(String.format("String_Node_Str" + "String_Node_Str" + "String_Node_Str",ssdTable,cols,cols,tempssdTable));
    database.execSQL(String.format("String_Node_Str",tempssdTable));
    database.setTransactionSuccessful();
    int newRows=countRows(database,ssdTable);
    if (oldRows != newRows) {
      Logger.log(AndroidLogger.TYPE_MAINTENANCE,String.format("String_Node_Str",String.valueOf(newRows - oldRows)));
    }
    return true;
  }
  finally {
    database.endTransaction();
  }
}
Program: 142361
Project: 142361
Buggy source:
private int countRows(SQLiteDatabase database,String table){
  try {
    Cursor c=database.rawQuery(String.format("String_Node_Str",table),new String[0]);
    return c.getInt(0);
  }
 catch (  Exception e) {
    return -1;
  }
}

Fixed version (ground truth):
private int countRows(SQLiteDatabase database,String table){
  try {
    Cursor c=database.rawQuery(String.format("String_Node_Str",table),new String[0]);
    c.moveToFirst();
    return c.getInt(0);
  }
 catch (  Exception e) {
    return -1;
  }
}