nus-yam/ex-repair huggingface dataset:
Program: 141958
Project: 141958
Buggy source:
private void handleFormLoadCompletion(AndroidFormController fc){
  if (GeoUtils.ACTION_CHECK_GPS_ENABLED.equals(locationRecieverErrorAction)) {
    FormEntryDialogs.handleNoGpsBroadcast(this);
  }
 else   if (PollSensorAction.XPATH_ERROR_ACTION.equals(locationRecieverErrorAction)) {
    handleXpathErrorBroadcast();
  }
  mFormController=fc;
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
    invalidateOptionsMenu();
  }
  registerSessionFormSaveCallback();
  boolean isRestartAfterSessionExpiration=getIntent().getBooleanExtra(KEY_IS_RESTART_AFTER_EXPIRATION,false);
  if (FormEntryInstanceState.mInstancePath == null || isRestartAfterSessionExpiration) {
    instanceState.initInstancePath();
  }
 else {
    Intent i=new Intent(this,FormHierarchyActivity.class);
    startActivityForResult(i,FormEntryConstants.HIERARCHY_ACTIVITY_FIRST_START);
    return;
  }
  reportFormEntryTime();
  formEntryRestoreSession.replaySession(this);
  uiController.refreshView();
  FormNavigationUI.updateNavigationCues(this,mFormController,uiController.questionsView);
  if (isRestartAfterSessionExpiration) {
    Toast.makeText(this,Localization.get("String_Node_Str"),Toast.LENGTH_LONG).show();
  }
}

Fixed version (ground truth):
private void handleFormLoadCompletion(AndroidFormController fc){
  if (GeoUtils.ACTION_CHECK_GPS_ENABLED.equals(locationRecieverErrorAction)) {
    FormEntryDialogs.handleNoGpsBroadcast(this);
  }
 else   if (PollSensorAction.XPATH_ERROR_ACTION.equals(locationRecieverErrorAction)) {
    handleXpathErrorBroadcast();
  }
  mFormController=fc;
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
    invalidateOptionsMenu();
  }
  registerSessionFormSaveCallback();
  boolean isRestartAfterSessionExpiration=getIntent().getBooleanExtra(KEY_IS_RESTART_AFTER_EXPIRATION,false);
  if (FormEntryInstanceState.mInstancePath == null) {
    instanceState.initInstancePath();
  }
 else   if (!isRestartAfterSessionExpiration) {
    Intent i=new Intent(this,FormHierarchyActivity.class);
    startActivityForResult(i,FormEntryConstants.HIERARCHY_ACTIVITY_FIRST_START);
    return;
  }
  reportFormEntryTime();
  formEntryRestoreSession.replaySession(this);
  uiController.refreshView();
  FormNavigationUI.updateNavigationCues(this,mFormController,uiController.questionsView);
  if (isRestartAfterSessionExpiration) {
    Toast.makeText(this,Localization.get("String_Node_Str"),Toast.LENGTH_LONG).show();
  }
}
Program: 141959
Project: 141959
Buggy source:
public void showOrHideErrorMessage(){
  Activity currentActivity=getActivity();
  if (currentActivity instanceof CommCareSetupActivity) {
    String msg=((CommCareSetupActivity)currentActivity).getErrorMessageToDisplay();
    if (msg != null && !"String_Node_Str".equals(msg)) {
      mErrorMessageView.setText(msg);
      mErrorMessageView.setVisibility(View.VISIBLE);
      if (((CommCareSetupActivity)this.getActivity()).shouldShowNotificationErrorButton()) {
        mViewErrorContainer.setVisibility(View.VISIBLE);
      }
    }
 else {
      mErrorMessageView.setVisibility(View.GONE);
      mViewErrorContainer.setVisibility(View.GONE);
    }
  }
}

Fixed version (ground truth):
public void showOrHideErrorMessage(){
  Activity currentActivity=getActivity();
  if (currentActivity instanceof CommCareSetupActivity) {
    String msg=((CommCareSetupActivity)currentActivity).getErrorMessageToDisplay();
    if (msg != null && !"String_Node_Str".equals(msg)) {
      mErrorMessageView.setText(msg);
      mErrorMessageView.setVisibility(View.VISIBLE);
      if (((CommCareSetupActivity)this.getActivity()).shouldShowNotificationErrorButton() && CommCareApplication.notificationManager().messagesForCommCareArePending()) {
        mViewErrorContainer.setVisibility(View.VISIBLE);
      }
    }
 else {
      mErrorMessageView.setVisibility(View.GONE);
      mViewErrorContainer.setVisibility(View.GONE);
    }
  }
}
Program: 141960
Project: 141960
Buggy source:
/** 
 * Scan SMS messages for texts with profile references.
 * @param installTriggeredManually if scan was triggered manually, theninstall automatically if reference is found
 */
private void performSMSInstall(boolean installTriggeredManually){
  if (ContextCompat.checkSelfPermission(this,Manifest.permission.READ_SMS) != PackageManager.PERMISSION_GRANTED) {
    manualSMSInstall=installTriggeredManually;
    if (ActivityCompat.shouldShowRequestPermissionRationale(this,Manifest.permission.READ_SMS)) {
      DialogCreationHelpers.buildPermissionRequestDialog(this,this,SMS_PERMISSIONS_REQUEST,Localization.get("String_Node_Str"),Localization.get("String_Node_Str")).showNonPersistentDialog();
    }
 else {
      requestNeededPermissions(SMS_PERMISSIONS_REQUEST);
    }
  }
 else {
    scanSMSLinks();
  }
}

Fixed version (ground truth):
/** 
 * Scan SMS messages for texts with profile references.
 * @param installTriggeredManually if scan was triggered manually, theninstall automatically if reference is found
 */
private void performSMSInstall(boolean installTriggeredManually){
  manualSMSInstall=installTriggeredManually;
  if (ContextCompat.checkSelfPermission(this,Manifest.permission.READ_SMS) != PackageManager.PERMISSION_GRANTED) {
    if (ActivityCompat.shouldShowRequestPermissionRationale(this,Manifest.permission.READ_SMS)) {
      DialogCreationHelpers.buildPermissionRequestDialog(this,this,SMS_PERMISSIONS_REQUEST,Localization.get("String_Node_Str"),Localization.get("String_Node_Str")).showNonPersistentDialog();
    }
 else {
      requestNeededPermissions(SMS_PERMISSIONS_REQUEST);
    }
  }
 else {
    scanSMSLinks();
  }
}
Program: 141961
Project: 141961
Buggy source:
/** 
 * Call when the user is ready to save and return the current form as complete
 */
protected void triggerUserFormComplete(){
  if (mFormController.isFormReadOnly()) {
    finishReturnInstance(false);
  }
 else {
    saveCompletedFormToDisk(FormEntryInstanceState.getDefaultFormTitle(this,getIntent()));
  }
}

Fixed version (ground truth):
/** 
 * Call when the user is ready to save and return the current form as complete
 */
protected void triggerUserFormComplete(){
  if (mFormController.isFormReadOnly()) {
    finishReturnInstance(false);
  }
 else {
    int instanceId=getIntent().getIntExtra(KEY_INSTANCE_ID,-1);
    saveCompletedFormToDisk(FormEntryInstanceState.getDefaultFormTitle(instanceId));
  }
}
Program: 141963
Project: 141963
Buggy source:
/** 
 * Get the default title for ODK's "Form title" field
 */
public static String getDefaultFormTitle(Context context,Intent intent){
  String saveName=FormEntryActivity.mFormController.getFormTitle();
  if (InstanceProviderAPI.InstanceColumns.CONTENT_ITEM_TYPE.equals(context.getContentResolver().getType(intent.getData()))) {
    Uri instanceUri=intent.getData();
    Cursor instance=null;
    try {
      instance=context.getContentResolver().query(instanceUri,null,null,null,null);
      if (instance != null && instance.getCount() == 1) {
        instance.moveToFirst();
        saveName=instance.getString(instance.getColumnIndex(InstanceProviderAPI.InstanceColumns.DISPLAY_NAME));
      }
    }
  finally {
      if (instance != null) {
        instance.close();
      }
    }
  }
  return saveName;
}

Fixed version (ground truth):
/** 
 * Get the default title for ODK's "Form title" field
 */
public static String getDefaultFormTitle(int instanceId){
  String saveName=FormEntryActivity.mFormController.getFormTitle();
  if (instanceId != -1) {
    saveName=InstanceRecord.getInstance(instanceId).getDisplayName();
  }
  return saveName;
}
Program: 141964
Project: 141964
Buggy source:
public int save(){
  if (StringUtils.isEmpty(mFormFilePath)) {
    throw new SQLException("String_Node_Str");
  }
  if (mDate == -1) {
    mDate=System.currentTimeMillis();
  }
  if (mDisplaySubtext == null) {
    mDisplaySubtext=getDisplaySubtext();
  }
  File form=new File(mFormFilePath);
  if (StringUtils.isEmpty(mDisplayName)) {
    mDisplayName=form.getName();
  }
  mMd5Hash=FileUtil.getMd5Hash(form);
  if (StringUtils.isEmpty(mJrcacheFilePath)) {
    mJrcacheFilePath=getCachePath(mMd5Hash);
  }
  if (StringUtils.isEmpty(mFormMediaPath)) {
    mFormMediaPath=getMediaPath(mFormFilePath);
  }
  getFormDefStorage().write(this);
  if (recordId == -1) {
    throw new SQLException("String_Node_Str" + toString());
  }
  return recordId;
}

Fixed version (ground truth):
public int save(){
  if (StringUtils.isEmpty(mFormFilePath)) {
    throw new SQLException("String_Node_Str");
  }
  if (mDate == null) {
    mDate=new Date();
  }
  if (mDisplaySubtext == null) {
    mDisplaySubtext=getDisplaySubtext();
  }
  File form=new File(mFormFilePath);
  if (StringUtils.isEmpty(mDisplayName)) {
    mDisplayName=form.getName();
  }
  mMd5Hash=FileUtil.getMd5Hash(form);
  if (StringUtils.isEmpty(mJrcacheFilePath)) {
    mJrcacheFilePath=getCachePath(mMd5Hash);
  }
  if (StringUtils.isEmpty(mFormMediaPath)) {
    mFormMediaPath=getMediaPath(mFormFilePath);
  }
  getFormDefStorage().write(this);
  if (recordId == -1) {
    throw new SQLException("String_Node_Str" + toString());
  }
  return recordId;
}
Program: 141965
Project: 141965
Buggy source:
public static SqlStorage<FormDefRecord> getFormDefStorage(){
  return CommCareApplication.instance().getAppStorage(FormDefRecord.class);
}

Fixed version (ground truth):
public static SqlStorage<FormDefRecord> getFormDefStorage(){
  if (sFormDefStorage == null) {
    sFormDefStorage=CommCareApplication.instance().getAppStorage(FormDefRecord.class);
  }
  return sFormDefStorage;
}
Program: 141966
Project: 141966
Buggy source:
public void updateStatus(@InstanceStatus String instanceStatus,String displayName,String canEditWhenComplete){
  mDisplayName=displayName;
  mStatus=instanceStatus;
  mCanEditWhenComplete=canEditWhenComplete;
  mDisplaySubtext=getDisplaySubtext(mStatus);
  mLastStatusChangeDate=System.currentTimeMillis();
  getInstanceRecordStorage().update(getID(),this);
  finalizeSessionLinkedInsertion();
}

Fixed version (ground truth):
public void updateStatus(@InstanceStatus String instanceStatus,String displayName,String canEditWhenComplete){
  mDisplayName=displayName;
  mStatus=instanceStatus;
  mCanEditWhenComplete=canEditWhenComplete;
  mDisplaySubtext=getDisplaySubtext(mStatus);
  mLastStatusChangeDate=new Date();
  getInstanceRecordStorage().update(getID(),this);
  finalizeSessionLinkedInsertion();
}
Program: 141968
Project: 141968
Buggy source:
/** 
 * Perform any custom installation actions required for this resource.
 */
protected abstract int customInstall(Resource r,Reference local,boolean upgrade) throws IOException, UnresolvedResourceException ;

Fixed version (ground truth):
/** 
 * Perform any custom installation actions required for this resource.
 */
protected abstract int customInstall(Resource r,Reference local,boolean upgrade,AndroidCommCarePlatform platform) throws IOException, UnresolvedResourceException ;
Program: 141969
Project: 141969
Buggy source:
@Override protected int customInstall(Resource r,Reference local,boolean upgrade) throws IOException, UnresolvedResourceException {
  return upgrade ? Resource.RESOURCE_STATUS_UPGRADE : Resource.RESOURCE_STATUS_INSTALLED;
}

Fixed version (ground truth):
@Override protected int customInstall(Resource r,Reference local,boolean upgrade,AndroidCommCarePlatform platform) throws IOException, UnresolvedResourceException {
  return upgrade ? Resource.RESOURCE_STATUS_UPGRADE : Resource.RESOURCE_STATUS_INSTALLED;
}
Program: 141970
Project: 141970
Buggy source:
@Override protected int customInstall(Resource r,Reference local,boolean upgrade) throws IOException, UnresolvedResourceException {
  return upgrade ? Resource.RESOURCE_STATUS_UPGRADE : Resource.RESOURCE_STATUS_INSTALLED;
}

Fixed version (ground truth):
@Override protected int customInstall(Resource r,Reference local,boolean upgrade,AndroidCommCarePlatform platform) throws IOException, UnresolvedResourceException {
  return upgrade ? Resource.RESOURCE_STATUS_UPGRADE : Resource.RESOURCE_STATUS_INSTALLED;
}
Program: 141971
Project: 141971
Buggy source:
@Override protected int customInstall(Resource r,Reference local,boolean upgrade) throws IOException, UnresolvedResourceException {
  try {
    initDemoUserRestore();
  }
 catch (  RuntimeException e) {
    throw new UnresolvedResourceException(r,e,e.getMessage(),true);
  }
  if (upgrade) {
    OfflineUserRestore currentOfflineUserRestore=CommCareApplication.instance().getCommCarePlatform().getDemoUserRestore();
    if (currentOfflineUserRestore != null) {
      AppUtils.wipeSandboxForUser(currentOfflineUserRestore.getUsername());
    }
    return Resource.RESOURCE_STATUS_UPGRADE;
  }
 else {
    return Resource.RESOURCE_STATUS_INSTALLED;
  }
}

Fixed version (ground truth):
@Override protected int customInstall(Resource r,Reference local,boolean upgrade,AndroidCommCarePlatform platform) throws IOException, UnresolvedResourceException {
  try {
    initDemoUserRestore();
  }
 catch (  RuntimeException e) {
    throw new UnresolvedResourceException(r,e,e.getMessage(),true);
  }
  if (upgrade) {
    OfflineUserRestore currentOfflineUserRestore=CommCareApplication.instance().getCommCarePlatform().getDemoUserRestore();
    if (currentOfflineUserRestore != null) {
      AppUtils.wipeSandboxForUser(currentOfflineUserRestore.getUsername());
    }
    return Resource.RESOURCE_STATUS_UPGRADE;
  }
 else {
    return Resource.RESOURCE_STATUS_INSTALLED;
  }
}
Program: 141972
Project: 141972
Buggy source:
@Override protected int customInstall(Resource r,Reference local,boolean upgrade) throws IOException, UnresolvedResourceException {
  return Resource.RESOURCE_STATUS_LOCAL;
}

Fixed version (ground truth):
@Override protected int customInstall(Resource r,Reference local,boolean upgrade,AndroidCommCarePlatform platform) throws IOException, UnresolvedResourceException {
  return Resource.RESOURCE_STATUS_LOCAL;
}
Program: 141973
Project: 141973
Buggy source:
@Override protected int customInstall(Resource r,Reference local,boolean upgrade) throws IOException, UnresolvedResourceException {
  return Resource.RESOURCE_STATUS_LOCAL;
}

Fixed version (ground truth):
@Override protected int customInstall(Resource r,Reference local,boolean upgrade,AndroidCommCarePlatform platform) throws IOException, UnresolvedResourceException {
  return Resource.RESOURCE_STATUS_LOCAL;
}
Program: 141974
Project: 141974
Buggy source:
@Override protected int customInstall(Resource r,Reference local,boolean upgrade) throws IOException, UnresolvedResourceException {
  registerAndroidLevelFormParsers();
  FormDef formDef;
  try {
    formDef=XFormExtensionUtils.getFormFromInputStream(local.getStream());
  }
 catch (  XFormParseException xfpe) {
    throw new UnresolvedResourceException(r,xfpe.getMessage(),true);
  }
  this.namespace=formDef.getInstance().schema;
  if (namespace == null) {
    throw new UnresolvedResourceException(r,"String_Node_Str",true);
  }
  Vector<Integer> existingforms=FormDefRecord.getFormDefIdsByJrFormId(formDef.getMainInstance().schema);
  if (existingforms != null && existingforms.size() > 0) {
    if (!upgrade) {
      Logger.log(LogTypes.SOFT_ASSERT,"String_Node_Str" + formDef.getMainInstance().schema + "String_Node_Str");
    }
    formDefId=existingforms.get(0);
    if (existingforms.size() > 1) {
      Logger.log(LogTypes.SOFT_ASSERT,"String_Node_Str" + formDef.getMainInstance().schema + "String_Node_Str");
    }
  }
 else {
    FormDefRecord formDefRecord=new FormDefRecord("String_Node_Str","String_Node_Str",formDef.getMainInstance().schema,local.getLocalURI(),GlobalConstants.MEDIA_REF);
    formDefId=formDefRecord.save();
  }
  return upgrade ? Resource.RESOURCE_STATUS_UPGRADE : Resource.RESOURCE_STATUS_INSTALLED;
}

Fixed version (ground truth):
@Override protected int customInstall(Resource r,Reference local,boolean upgrade,AndroidCommCarePlatform platform) throws IOException, UnresolvedResourceException {
  registerAndroidLevelFormParsers();
  FormDef formDef;
  try {
    formDef=XFormExtensionUtils.getFormFromInputStream(local.getStream());
  }
 catch (  XFormParseException xfpe) {
    throw new UnresolvedResourceException(r,xfpe.getMessage(),true);
  }
  this.namespace=formDef.getInstance().schema;
  if (namespace == null) {
    throw new UnresolvedResourceException(r,"String_Node_Str",true);
  }
  FormDefRecord.setFormDefStorage(platform.getFormDefStorage());
  Vector<Integer> existingforms=FormDefRecord.getFormDefIdsByJrFormId(formDef.getMainInstance().schema);
  if (existingforms != null && existingforms.size() > 0) {
    if (!upgrade) {
      Logger.log(LogTypes.SOFT_ASSERT,"String_Node_Str" + formDef.getMainInstance().schema + "String_Node_Str");
    }
    formDefId=existingforms.get(0);
    if (existingforms.size() > 1) {
      Logger.log(LogTypes.SOFT_ASSERT,"String_Node_Str" + formDef.getMainInstance().schema + "String_Node_Str");
    }
  }
 else {
    FormDefRecord formDefRecord=new FormDefRecord("String_Node_Str","String_Node_Str",formDef.getMainInstance().schema,local.getLocalURI(),GlobalConstants.MEDIA_REF);
    formDefId=formDefRecord.save();
  }
  return upgrade ? Resource.RESOURCE_STATUS_UPGRADE : Resource.RESOURCE_STATUS_INSTALLED;
}
Program: 141975
Project: 141975
Buggy source:
protected void playAudio(){
  Intent i=new Intent("String_Node_Str");
  File audioFile=new File(mInstanceFolder + mBinaryName);
  Uri audioUri=FileUtil.getUriForExternalFile(getContext(),audioFile);
  i.setDataAndType(audioUri,"String_Node_Str");
  UriToFilePath.grantPermissionForUri(getContext(),i,audioUri,Intent.FLAG_GRANT_READ_URI_PERMISSION);
  try {
    getContext().startActivity(i);
  }
 catch (  ActivityNotFoundException e) {
    Toast.makeText(getContext(),StringUtils.getStringSpannableRobust(getContext(),R.string.activity_not_found,"String_Node_Str"),Toast.LENGTH_SHORT).show();
  }
}

Fixed version (ground truth):
protected void playAudio(){
  playMedia("String_Node_Str");
}
Program: 141976
Project: 141976
Buggy source:
protected abstract String createFilePath(Object binaryUri);

Fixed version (ground truth):
/** 
 * If file is chosen by user, the file selection intent will return an URI If file is auto-selected after recording_fragment, then the recordingfragment will provide a string file path Set value of customFileTag if the file is a recent recording from the RecordingFragment
 */
protected String createFilePath(Object binaryuri){
  String path="String_Node_Str";
  destMediaPath="String_Node_Str";
  if (binaryuri instanceof Uri) {
    try {
      path=UriToFilePath.getPathFromUri(CommCareApplication.instance(),(Uri)binaryuri);
    }
 catch (    UriToFilePath.NoDataColumnForUriException e) {
      InputStream inputStream;
      try {
        inputStream=getContext().getContentResolver().openInputStream((Uri)binaryuri);
      }
 catch (      FileNotFoundException e1) {
        showToast("String_Node_Str");
        e1.printStackTrace();
        return "String_Node_Str";
      }
      recordedFileName=FileUtil.getFileName(((Uri)binaryuri).getPath());
      destMediaPath=mInstanceFolder + System.currentTimeMillis() + FileUtil.getExtension(((Uri)binaryuri).getPath());
      try {
        FileUtil.copyFile(inputStream,new File(destMediaPath));
      }
 catch (      IOException e1) {
        e1.printStackTrace();
        showToast("String_Node_Str");
        return "String_Node_Str";
      }
      path=destMediaPath;
    }
    customFileTag="String_Node_Str";
  }
 else {
    path=(String)binaryuri;
    customFileTag=CUSTOM_TAG;
  }
  return path;
}
Program: 141977
Project: 141977
Buggy source:
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) private void readFromNfcTag(Tag tag){
  Ndef ndefObject=Ndef.get(tag);
  try {
    ndefObject.connect();
    NdefMessage msg=ndefObject.getNdefMessage();
    if (msg == null) {
      finishWithErrorToast("String_Node_Str");
      return;
    }
    NdefRecord firstRecord=msg.getRecords()[0];
    Pair<String,Boolean> resultAndSuccess=NdefRecordUtil.readValueFromRecord(firstRecord,this.acceptableTypes,this.domainForType);
    if (resultAndSuccess.second) {
      this.valueRead=resultAndSuccess.first;
      finishWithToast("String_Node_Str",true);
    }
 else {
      finishWithErrorToast(resultAndSuccess.first);
    }
  }
 catch (  IOException e) {
    finishWithErrorToast("String_Node_Str");
  }
catch (  FormatException e) {
    finishWithErrorToast("String_Node_Str");
  }
 finally {
    try {
      ndefObject.close();
    }
 catch (    IOException e) {
    }
  }
}

Fixed version (ground truth):
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) private void readFromNfcTag(Tag tag){
  Ndef ndefObject=Ndef.get(tag);
  if (ndefObject == null) {
    finishWithErrorToast("String_Node_Str");
    return;
  }
  try {
    ndefObject.connect();
    NdefMessage msg=ndefObject.getNdefMessage();
    if (msg == null) {
      finishWithErrorToast("String_Node_Str");
      return;
    }
    NdefRecord firstRecord=msg.getRecords()[0];
    Pair<String,Boolean> resultAndSuccess=NdefRecordUtil.readValueFromRecord(firstRecord,this.acceptableTypes,this.domainForType);
    if (resultAndSuccess.second) {
      this.valueRead=resultAndSuccess.first;
      finishWithToast("String_Node_Str",true);
    }
 else {
      finishWithErrorToast(resultAndSuccess.first);
    }
  }
 catch (  IOException e) {
    finishWithErrorToast("String_Node_Str");
  }
catch (  FormatException e) {
    finishWithErrorToast("String_Node_Str");
  }
 finally {
    try {
      ndefObject.close();
    }
 catch (    IOException e) {
    }
  }
}
Program: 141978
Project: 141978
Buggy source:
public static Set<String> getAllIndexedFixtureNames(SQLiteDatabase db){
  Cursor c=db.query(IndexedFixturePathsConstants.INDEXED_FIXTURE_PATHS_TABLE,new String[]{IndexedFixturePathsConstants.INDEXED_FIXTURE_PATHS_COL_NAME},null,null,null,null,null);
  Set<String> fixtureNames=new HashSet<>();
  try {
    if (c.moveToFirst()) {
      int desiredColumnIndex=c.getColumnIndexOrThrow(IndexedFixturePathsConstants.INDEXED_FIXTURE_PATHS_COL_NAME);
      while (!c.isAfterLast()) {
        String name=c.getString(desiredColumnIndex);
        fixtureNames.add(name);
        c.moveToNext();
      }
    }
    return fixtureNames;
  }
  finally {
    if (c != null) {
      c.close();
    }
  }
}

Fixed version (ground truth):
public static List<String> getAllIndexedFixtureNames(SQLiteDatabase db){
  Cursor c=db.query(IndexedFixturePathsConstants.INDEXED_FIXTURE_PATHS_TABLE,new String[]{IndexedFixturePathsConstants.INDEXED_FIXTURE_PATHS_COL_NAME},null,null,null,null,null);
  List<String> fixtureNames=new ArrayList<>();
  try {
    if (c.moveToFirst()) {
      int desiredColumnIndex=c.getColumnIndexOrThrow(IndexedFixturePathsConstants.INDEXED_FIXTURE_PATHS_COL_NAME);
      while (!c.isAfterLast()) {
        String name=c.getString(desiredColumnIndex);
        fixtureNames.add(name);
        c.moveToNext();
      }
    }
    return fixtureNames;
  }
  finally {
    if (c != null) {
      c.close();
    }
  }
}
Program: 141979
Project: 141979
Buggy source:
private boolean upgradeNineteenTwenty(SQLiteDatabase db){
  db.beginTransaction();
  try {
    Set<String> allIndexedFixtures=IndexedFixturePathUtils.getAllIndexedFixtureNames(db);
    for (    String fixtureName : allIndexedFixtures) {
      String tableName=StorageIndexedTreeElementModel.getTableName(fixtureName);
      SqlStorage<StorageIndexedTreeElementModel> storageForThisFixture=new SqlStorage<>(tableName,StorageIndexedTreeElementModel.class,new ConcreteAndroidDbHelper(c,db));
      StorageIndexedTreeElementModel exampleChildElement=storageForThisFixture.iterate().nextRecord();
      IndexedFixturePathUtils.buildFixtureIndices(db,tableName,exampleChildElement.getIndexColumnNames());
    }
    db.setTransactionSuccessful();
    return true;
  }
  finally {
    db.endTransaction();
  }
}

Fixed version (ground truth):
private boolean upgradeNineteenTwenty(SQLiteDatabase db){
  db.beginTransaction();
  try {
    List<String> allIndexedFixtures=IndexedFixturePathUtils.getAllIndexedFixtureNames(db);
    for (    String fixtureName : allIndexedFixtures) {
      String tableName=StorageIndexedTreeElementModel.getTableName(fixtureName);
      SqlStorage<StorageIndexedTreeElementModel> storageForThisFixture=new SqlStorage<>(tableName,StorageIndexedTreeElementModel.class,new ConcreteAndroidDbHelper(c,db));
      StorageIndexedTreeElementModel exampleChildElement=storageForThisFixture.iterate().nextRecord();
      IndexedFixturePathUtils.buildFixtureIndices(db,tableName,exampleChildElement.getIndexColumnNames());
    }
    db.setTransactionSuccessful();
    return true;
  }
  finally {
    db.endTransaction();
  }
}
Program: 141980
Project: 141980
Buggy source:
@Test public void testIndexedFixturePathsTableSoundness(){
  AndroidSandbox sandbox=StoreFixturesOnFilesystemTests.installAppWithFixtureData(this.getClass(),"String_Node_Str");
  try {
    StoreFixturesOnFilesystemTests.parseIntoSandbox(this.getClass().getClassLoader().getResourceAsStream("String_Node_Str"),false);
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  SQLiteDatabase db=sandbox.getUserDb();
  List<String> allIndexedFixtures=IndexedFixturePathUtils.getAllIndexedFixtureNamesAsList(db);
  List<String> comparisonList=new ArrayList<>();
  for (  String fixtureName : allIndexedFixtures) {
    if (comparisonList.contains(fixtureName)) {
      fail("String_Node_Str");
    }
    comparisonList.add(fixtureName);
  }
  assertEquals("String_Node_Str",1,allIndexedFixtures.size());
}

Fixed version (ground truth):
@Test public void testIndexedFixturePathsTableSoundness(){
  AndroidSandbox sandbox=StoreFixturesOnFilesystemTests.installAppWithFixtureData(this.getClass(),"String_Node_Str");
  try {
    StoreFixturesOnFilesystemTests.parseIntoSandbox(this.getClass().getClassLoader().getResourceAsStream("String_Node_Str"),false);
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  SQLiteDatabase db=sandbox.getUserDb();
  List<String> allIndexedFixtures=IndexedFixturePathUtils.getAllIndexedFixtureNames(db);
  List<String> comparisonList=new ArrayList<>();
  for (  String fixtureName : allIndexedFixtures) {
    if (comparisonList.contains(fixtureName)) {
      fail("String_Node_Str");
    }
    comparisonList.add(fixtureName);
  }
  assertEquals("String_Node_Str",1,allIndexedFixtures.size());
}
Program: 141982
Project: 141982
Buggy source:
private void processFromLoginLaunch(){
  if (getIntent().getBooleanExtra(DispatchActivity.START_FROM_LOGIN,false) && !loginExtraWasConsumed) {
    getIntent().removeExtra(DispatchActivity.START_FROM_LOGIN);
    loginExtraWasConsumed=true;
    CommCareSession session=CommCareApplication.instance().getCurrentSession();
    if (session.getCommand() != null) {
      isRestoringSession=true;
      sessionNavigator.startNextSessionStep();
      return;
    }
    if (!CommCareApplication.instance().isSyncPending(false)) {
      checkAndStartUnsentFormsTask(false,false);
    }
    if (isDemoUser()) {
      showDemoModeWarning();
      return;
    }
    if (UpdatePromptHelper.promptForUpdateIfNeeded(this,PROMPT_FOR_UPDATE)) {
      return;
    }
    if (checkForPinLaunchConditions()) {
      return;
    }
  }
}

Fixed version (ground truth):
private void processFromLoginLaunch(){
  if (getIntent().getBooleanExtra(DispatchActivity.START_FROM_LOGIN,false) && !loginExtraWasConsumed) {
    getIntent().removeExtra(DispatchActivity.START_FROM_LOGIN);
    loginExtraWasConsumed=true;
    CommCareSession session=CommCareApplication.instance().getCurrentSession();
    if (session.getCommand() != null) {
      isRestoringSession=true;
      sessionNavigator.startNextSessionStep();
      return;
    }
    if (!CommCareApplication.instance().isSyncPending(false)) {
      checkAndStartUnsentFormsTask(false,false);
    }
    if (isDemoUser()) {
      showDemoModeWarning();
      return;
    }
    if (checkForPinLaunchConditions()) {
      return;
    }
  }
}
Program: 141983
Project: 141983
Buggy source:
/** 
 * Decides if we should actually be on the home screen, or else should redirect elsewhere
 */
private void attemptDispatchHomeScreen(){
  try {
    CommCareApplication.instance().getSession();
  }
 catch (  SessionUnavailableException e) {
    setResult(RESULT_OK);
    this.finish();
    return;
  }
  if (CommCareApplication.instance().isSyncPending(false)) {
    handlePendingSync();
  }
 else {
    refreshUI();
  }
}

Fixed version (ground truth):
/** 
 * Decides if we should actually be on the home screen, or else should redirect elsewhere
 */
private void attemptDispatchHomeScreen(){
  try {
    CommCareApplication.instance().getSession();
  }
 catch (  SessionUnavailableException e) {
    setResult(RESULT_OK);
    this.finish();
    return;
  }
  if (CommCareApplication.instance().isSyncPending(false)) {
    handlePendingSync();
  }
 else   if (UpdatePromptHelper.promptForUpdateIfNeeded(this)) {
    return;
  }
 else {
    refreshUI();
  }
}
Program: 141984
Project: 141984
Buggy source:
/** 
 * @return - If the user was prompted to update
 */
public static boolean promptForUpdateIfNeeded(Activity context,int requestCode){
  try {
    CommCareSessionService currentSession=CommCareApplication.instance().getSession();
    if (!currentSession.apkUpdatePromptWasShown() && getCurrentUpdateToPrompt(UpdateToPrompt.Type.APK_UPDATE) != null) {
      Intent i=new Intent(context,PromptApkUpdateActivity.class);
      context.startActivityForResult(i,requestCode);
      return true;
    }
 else     if (!currentSession.cczUpdatePromptWasShown() && getCurrentUpdateToPrompt(UpdateToPrompt.Type.CCZ_UPDATE) != null) {
      Intent i=new Intent(context,PromptCczUpdateActivity.class);
      context.startActivityForResult(i,requestCode);
      return true;
    }
  }
 catch (  SessionUnavailableException e) {
  }
  return false;
}

Fixed version (ground truth):
/** 
 * @return - If the user was prompted to update
 */
public static boolean promptForUpdateIfNeeded(Activity context){
  try {
    CommCareSessionService currentSession=CommCareApplication.instance().getSession();
    if (!currentSession.apkUpdatePromptWasShown() && getCurrentUpdateToPrompt(UpdateToPrompt.Type.APK_UPDATE) != null) {
      Intent i=new Intent(context,PromptApkUpdateActivity.class);
      context.startActivity(i);
      return true;
    }
 else     if (!currentSession.cczUpdatePromptWasShown() && getCurrentUpdateToPrompt(UpdateToPrompt.Type.CCZ_UPDATE) != null) {
      Intent i=new Intent(context,PromptCczUpdateActivity.class);
      context.startActivity(i);
      return true;
    }
  }
 catch (  SessionUnavailableException e) {
  }
  return false;
}
Program: 141987
Project: 141987
Buggy source:
@Override public void onBackPressed(){
  FragmentManager fm=this.getSupportFragmentManager();
  BreadcrumbBarFragment bar=(BreadcrumbBarFragment)fm.findFragmentByTag("String_Node_Str");
  if (bar != null && bar.persistentCaseTileIsExpanded) {
    bar.collapsePersistentCaseTile(this);
  }
 else {
    super.onBackPressed();
    AudioController.INSTANCE.releaseCurrentMediaEntity();
  }
}

Fixed version (ground truth):
@Override public void onBackPressed(){
  FragmentManager fm=this.getSupportFragmentManager();
  BreadcrumbBarFragment bar=(BreadcrumbBarFragment)fm.findFragmentByTag("String_Node_Str");
  if (bar != null) {
    if (bar.collapseTileIfExpanded(this)) {
      return;
    }
  }
  super.onBackPressed();
  AudioController.INSTANCE.releaseCurrentMediaEntity();
}
Program: 141988
Project: 141988
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  FragmentManager fm=this.getSupportFragmentManager();
  stateHolder=(TaskConnectorFragment<R>)fm.findFragmentByTag("String_Node_Str");
  if (stateHolder == null) {
    stateHolder=new TaskConnectorFragment<>();
    fm.beginTransaction().add(stateHolder,"String_Node_Str").commit();
    AudioController.INSTANCE.releaseCurrentMediaEntity();
  }
  if (usesUIController()) {
    ((WithUIController)this).initUIController();
  }
  persistManagedUiState(fm);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && shouldShowBreadcrumbBar()) {
    getActionBar().setDisplayShowCustomEnabled(true);
    BreadcrumbBarFragment bar=(BreadcrumbBarFragment)fm.findFragmentByTag("String_Node_Str");
    if (bar == null) {
      bar=new BreadcrumbBarFragment();
      fm.beginTransaction().add(bar,"String_Node_Str").commit();
    }
 else {
      bar.persistentCaseTileIsExpanded=false;
    }
  }
  mGestureDetector=new GestureDetector(this,this);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  FragmentManager fm=this.getSupportFragmentManager();
  stateHolder=(TaskConnectorFragment<R>)fm.findFragmentByTag("String_Node_Str");
  if (stateHolder == null) {
    stateHolder=new TaskConnectorFragment<>();
    fm.beginTransaction().add(stateHolder,"String_Node_Str").commit();
    AudioController.INSTANCE.releaseCurrentMediaEntity();
  }
  if (usesUIController()) {
    ((WithUIController)this).initUIController();
  }
  persistManagedUiState(fm);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && shouldShowBreadcrumbBar()) {
    getActionBar().setDisplayShowCustomEnabled(true);
    BreadcrumbBarFragment bar=(BreadcrumbBarFragment)fm.findFragmentByTag("String_Node_Str");
    if (bar == null) {
      bar=new BreadcrumbBarFragment();
      fm.beginTransaction().add(bar,"String_Node_Str").commit();
    }
  }
  mGestureDetector=new GestureDetector(this,this);
}
Program: 141989
Project: 141989
Buggy source:
@Override public void onClick(View v){
  if (!persistentCaseTileIsExpanded) {
    expandPersistentCaseTile(activity,holder,tileData);
  }
 else {
    collapsePersistentCaseTile(activity);
  }
}

Fixed version (ground truth):
@Override public void onClick(View v){
  boolean isCollapsed=INLINE_TILE_COLLAPSED.equals(holder.getTag());
  if (isCollapsed) {
    expandInlineTile(activity,holder,tileData,inlineDetail);
  }
 else {
    collapseTileIfExpanded(activity);
  }
}
Program: 141990
Project: 141990
Buggy source:
private View findAndLoadCaseTile(final Activity activity){
  final View holder=LayoutInflater.from(activity).inflate(R.layout.com_tile_holder,null);
  final Pair<View,TreeReference> tileData=this.loadTile(activity);
  if (tileData == null || tileData.first == null) {
    return null;
  }
  holder.findViewById(R.id.com_tile_holder_btn_open).setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      if (!persistentCaseTileIsExpanded) {
        expandPersistentCaseTile(activity,holder,tileData);
      }
 else {
        collapsePersistentCaseTile(activity);
      }
    }
  }
);
  return holder;
}

Fixed version (ground truth):
private View findAndLoadCaseTile(final Activity activity){
  final View holder=LayoutInflater.from(activity).inflate(R.layout.com_tile_holder,null);
  final Pair<View,TreeReference> tileData=this.loadTile(activity);
  if (tileData == null || tileData.first == null) {
    return null;
  }
  View tile=tileData.first;
  final String inlineDetail=(String)tile.getTag();
  ((ViewGroup)holder.findViewById(R.id.com_tile_holder_frame)).addView(tile,LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
  ImageButton infoButton=((ImageButton)holder.findViewById(R.id.com_tile_holder_btn_open));
  if (inlineDetail == null) {
    infoButton.setVisibility(View.GONE);
  }
  holder.setTag(INLINE_TILE_COLLAPSED);
  infoButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      boolean isCollapsed=INLINE_TILE_COLLAPSED.equals(holder.getTag());
      if (isCollapsed) {
        expandInlineTile(activity,holder,tileData,inlineDetail);
      }
 else {
        collapseTileIfExpanded(activity);
      }
    }
  }
);
  return holder;
}
Program: 141991
Project: 141991
Buggy source:
public static void wipeSandboxForUser(final String username){
  CommCareApplication.instance().getFileBackedUserStorage("String_Node_Str",FormInstance.class).removeAll();
  final Set<String> dbIdsToRemove=new HashSet<>();
  CommCareApplication.instance().getAppStorage(UserKeyRecord.class).removeAll(new EntityFilter<UserKeyRecord>(){
    @Override public boolean matches(    UserKeyRecord ukr){
      if (ukr.getUsername().equalsIgnoreCase(username.toLowerCase())) {
        dbIdsToRemove.add(ukr.getUuid());
        return true;
      }
      return false;
    }
  }
);
  for (  String id : dbIdsToRemove) {
    CommCareApplication.instance().getDatabasePath(DatabaseUserOpenHelper.getDbName(id)).delete();
  }
}

Fixed version (ground truth):
public static void wipeSandboxForUser(final String username){
  final Set<String> dbIdsToRemove=new HashSet<>();
  CommCareApplication.instance().getAppStorage(UserKeyRecord.class).removeAll(new EntityFilter<UserKeyRecord>(){
    @Override public boolean matches(    UserKeyRecord ukr){
      if (ukr.getUsername().equalsIgnoreCase(username.toLowerCase())) {
        dbIdsToRemove.add(ukr.getUuid());
        return true;
      }
      return false;
    }
  }
);
  wipeFileBackedFixtureStorage(dbIdsToRemove);
  for (  String id : dbIdsToRemove) {
    CommCareApplication.instance().getDatabasePath(DatabaseUserOpenHelper.getDbName(id)).delete();
  }
}
Program: 141992
Project: 141992
Buggy source:
@Override public IStorageUtilityIndexed<FormInstance> getUserFixtureStorage(){
  return app.getFileBackedUserStorage("String_Node_Str",FormInstance.class);
}

Fixed version (ground truth):
@Override public IStorageUtilityIndexed<FormInstance> getUserFixtureStorage(){
  return app.getFileBackedUserStorage(HybridFileBackedSqlStorage.FIXTURE_STORAGE_TABLE_NAME,FormInstance.class);
}
Program: 141993
Project: 141993
Buggy source:
/** 
 * Sql object storage layer that stores serialized objects on the filesystem.
 * @param tableName     name of database table
 * @param classType     type of object being stored in this database
 * @param directoryName Name of storage root subdir where entry files are placed
 * @param fsPathBuilder Resolves a db dir path to the correct app dir in external storage
 */
public HybridFileBackedSqlStorage(String tableName,Class<? extends T> classType,AndroidDbHelper dbHelper,String directoryName,AppFilePathBuilder fsPathBuilder){
  super(tableName,classType,dbHelper);
  final String subPath=GlobalConstants.FILE_CC_DB + directoryName + "String_Node_Str"+ tableName;
  dbDir=new File(fsPathBuilder.fsPath(subPath));
  setupDir();
}

Fixed version (ground truth):
/** 
 * Sql object storage layer that stores serialized objects on the filesystem.
 * @param tableName     name of database table
 * @param classType     type of object being stored in this database
 * @param directoryName Name of storage root subdir where entry files are placed
 * @param fsPathBuilder Resolves a db dir path to the correct app dir in external storage
 */
public HybridFileBackedSqlStorage(String tableName,Class<? extends T> classType,AndroidDbHelper dbHelper,String directoryName,AppFilePathBuilder fsPathBuilder){
  super(tableName,classType,dbHelper);
  dbDir=getStorageFile(directoryName,tableName,fsPathBuilder);
  setupDir();
}
Program: 141994
Project: 141994
Buggy source:
/** 
 * Ensure parsing doesn't stop at empty fixtures, but continues on, committing subsequent fixtures
 */
@Test public void testEmptyFixtureFollowedByNormalFixture(){
  HybridFileBackedSqlStorage<FormInstance> userFixtureStorage=CommCareApplication.instance().getFileBackedUserStorage("String_Node_Str",FormInstance.class);
  boolean didntFindEmptyFixture=false;
  try {
    userFixtureStorage.getRecordForValues(new String[]{FormInstance.META_ID},new String[]{"String_Node_Str"});
  }
 catch (  NoSuchElementException e) {
    didntFindEmptyFixture=true;
  }
  Assert.assertTrue(didntFindEmptyFixture);
  userFixtureStorage.getRecordForValues(new String[]{FormInstance.META_ID},new String[]{"String_Node_Str"});
}

Fixed version (ground truth):
/** 
 * Ensure parsing doesn't stop at empty fixtures, but continues on, committing subsequent fixtures
 */
@Test public void testEmptyFixtureFollowedByNormalFixture(){
  HybridFileBackedSqlStorage<FormInstance> userFixtureStorage=CommCareApplication.instance().getFileBackedUserStorage(HybridFileBackedSqlStorage.FIXTURE_STORAGE_TABLE_NAME,FormInstance.class);
  boolean didntFindEmptyFixture=false;
  try {
    userFixtureStorage.getRecordForValues(new String[]{FormInstance.META_ID},new String[]{"String_Node_Str"});
  }
 catch (  NoSuchElementException e) {
    didntFindEmptyFixture=true;
  }
  Assert.assertTrue(didntFindEmptyFixture);
  userFixtureStorage.getRecordForValues(new String[]{FormInstance.META_ID},new String[]{"String_Node_Str"});
}
Program: 141997
Project: 141997
Buggy source:
/** 
 * Write an object to the filesystem but fail before finializing the transaction. Test that the file is marked as orphan
 */
@Test public void atomicWriteTest(){
  HybridFileBackedSqlStorageMock.alwaysPutInFilesystem();
  HybridFileBackedSqlStorage<FormInstance> userFixtureStorage=CommCareApplication.instance().getFileBackedUserStorage("String_Node_Str",FormInstance.class);
  FormInstance form=userFixtureStorage.getRecordForValues(new String[]{FormInstance.META_ID},new String[]{"String_Node_Str"});
  form.setID(-1);
  FormInstanceWithFailures failingForm=new FormInstanceWithFailures(form.getRoot());
  FormInstanceWithFailures.setFailOnIdSet(true);
  File dbDir=userFixtureStorage.getDbDirForTesting();
  int fileCountBefore=dbDir.listFiles().length;
  boolean didWriteFail=false;
  try {
    userFixtureStorage.write(failingForm);
  }
 catch (  RuntimeException e) {
    didWriteFail=true;
  }
  Assert.assertTrue(didWriteFail);
  int fileCountAfter=dbDir.listFiles().length;
  Assert.assertTrue(fileCountAfter - fileCountBefore == 1);
  clearOrphanedFiles();
  int fileCountAfterClear=dbDir.listFiles().length;
  Assert.assertTrue(fileCountBefore - fileCountAfterClear == 0);
}

Fixed version (ground truth):
/** 
 * Write an object to the filesystem but fail before finializing the transaction. Test that the file is marked as orphan
 */
@Test public void atomicWriteTest(){
  HybridFileBackedSqlStorageMock.alwaysPutInFilesystem();
  HybridFileBackedSqlStorage<FormInstance> userFixtureStorage=CommCareApplication.instance().getFileBackedUserStorage(HybridFileBackedSqlStorage.FIXTURE_STORAGE_TABLE_NAME,FormInstance.class);
  FormInstance form=userFixtureStorage.getRecordForValues(new String[]{FormInstance.META_ID},new String[]{"String_Node_Str"});
  form.setID(-1);
  FormInstanceWithFailures failingForm=new FormInstanceWithFailures(form.getRoot());
  FormInstanceWithFailures.setFailOnIdSet(true);
  File dbDir=userFixtureStorage.getDbDirForTesting();
  int fileCountBefore=dbDir.listFiles().length;
  boolean didWriteFail=false;
  try {
    userFixtureStorage.write(failingForm);
  }
 catch (  RuntimeException e) {
    didWriteFail=true;
  }
  Assert.assertTrue(didWriteFail);
  int fileCountAfter=dbDir.listFiles().length;
  Assert.assertTrue(fileCountAfter - fileCountBefore == 1);
  clearOrphanedFiles();
  int fileCountAfterClear=dbDir.listFiles().length;
  Assert.assertTrue(fileCountBefore - fileCountAfterClear == 0);
}
Program: 141998
Project: 141998
Buggy source:
@Test public void testRecordLookup(){
  HybridFileBackedSqlStorage<FormInstance> userFixtureStorage=CommCareApplication.instance().getFileBackedUserStorage("String_Node_Str",FormInstance.class);
  Vector<FormInstance> forms=userFixtureStorage.getRecordsForValues(new String[]{FormInstance.META_ID},new String[]{"String_Node_Str"});
  Assert.assertTrue(forms.size() == 1);
  FormInstance form=userFixtureStorage.getRecordForValues(new String[]{FormInstance.META_ID},new String[]{"String_Node_Str"});
  Assert.assertEquals(forms.firstElement().getRoot(),form.getRoot());
  form=userFixtureStorage.getRecordForValue(FormInstance.META_ID,"String_Node_Str");
  Assert.assertEquals(forms.firstElement().getRoot(),form.getRoot());
  UnencryptedHybridFileBackedSqlStorage<FormInstance> appFixtureStorage=CommCareApplication.instance().getCurrentApp().getFileBackedStorage("String_Node_Str",FormInstance.class);
  forms=appFixtureStorage.getRecordsForValues(new String[]{FormInstance.META_ID},new String[]{"String_Node_Str"});
  Assert.assertTrue(forms.size() == 1);
  form=appFixtureStorage.getRecordForValues(new String[]{FormInstance.META_ID},new String[]{"String_Node_Str"});
  Assert.assertEquals(forms.firstElement().getRoot(),form.getRoot());
  form=appFixtureStorage.getRecordForValue(FormInstance.META_ID,"String_Node_Str");
  Assert.assertEquals(forms.firstElement().getRoot(),form.getRoot());
}

Fixed version (ground truth):
@Test public void testRecordLookup(){
  HybridFileBackedSqlStorage<FormInstance> userFixtureStorage=CommCareApplication.instance().getFileBackedUserStorage(HybridFileBackedSqlStorage.FIXTURE_STORAGE_TABLE_NAME,FormInstance.class);
  Vector<FormInstance> forms=userFixtureStorage.getRecordsForValues(new String[]{FormInstance.META_ID},new String[]{"String_Node_Str"});
  Assert.assertTrue(forms.size() == 1);
  FormInstance form=userFixtureStorage.getRecordForValues(new String[]{FormInstance.META_ID},new String[]{"String_Node_Str"});
  Assert.assertEquals(forms.firstElement().getRoot(),form.getRoot());
  form=userFixtureStorage.getRecordForValue(FormInstance.META_ID,"String_Node_Str");
  Assert.assertEquals(forms.firstElement().getRoot(),form.getRoot());
  UnencryptedHybridFileBackedSqlStorage<FormInstance> appFixtureStorage=CommCareApplication.instance().getCurrentApp().getFileBackedStorage("String_Node_Str",FormInstance.class);
  forms=appFixtureStorage.getRecordsForValues(new String[]{FormInstance.META_ID},new String[]{"String_Node_Str"});
  Assert.assertTrue(forms.size() == 1);
  form=appFixtureStorage.getRecordForValues(new String[]{FormInstance.META_ID},new String[]{"String_Node_Str"});
  Assert.assertEquals(forms.firstElement().getRoot(),form.getRoot());
  form=appFixtureStorage.getRecordForValue(FormInstance.META_ID,"String_Node_Str");
  Assert.assertEquals(forms.firstElement().getRoot(),form.getRoot());
}
Program: 141999
Project: 141999
Buggy source:
@Test public void testUpdate(){
  HybridFileBackedSqlStorage<FormInstance> userFixtureStorage=CommCareApplication.instance().getFileBackedUserStorage("String_Node_Str",FormInstance.class);
  FormInstance form=userFixtureStorage.getRecordForValues(new String[]{FormInstance.META_ID},new String[]{"String_Node_Str"});
  String newName="String_Node_Str";
  form.setName(newName);
  userFixtureStorage.update(form.getID(),form);
  form=userFixtureStorage.getRecordForValues(new String[]{FormInstance.META_ID},new String[]{"String_Node_Str"});
  Assert.assertEquals(newName,form.getName());
  UnencryptedHybridFileBackedSqlStorage<FormInstance> appFixtureStorage=CommCareApplication.instance().getCurrentApp().getFileBackedStorage("String_Node_Str",FormInstance.class);
  form=appFixtureStorage.getRecordForValues(new String[]{FormInstance.META_ID},new String[]{"String_Node_Str"});
  form.setName(newName);
  appFixtureStorage.update(form.getID(),form);
  form=appFixtureStorage.getRecordForValues(new String[]{FormInstance.META_ID},new String[]{"String_Node_Str"});
  Assert.assertEquals(newName,form.getName());
}

Fixed version (ground truth):
@Test public void testUpdate(){
  HybridFileBackedSqlStorage<FormInstance> userFixtureStorage=CommCareApplication.instance().getFileBackedUserStorage(HybridFileBackedSqlStorage.FIXTURE_STORAGE_TABLE_NAME,FormInstance.class);
  FormInstance form=userFixtureStorage.getRecordForValues(new String[]{FormInstance.META_ID},new String[]{"String_Node_Str"});
  String newName="String_Node_Str";
  form.setName(newName);
  userFixtureStorage.update(form.getID(),form);
  form=userFixtureStorage.getRecordForValues(new String[]{FormInstance.META_ID},new String[]{"String_Node_Str"});
  Assert.assertEquals(newName,form.getName());
  UnencryptedHybridFileBackedSqlStorage<FormInstance> appFixtureStorage=CommCareApplication.instance().getCurrentApp().getFileBackedStorage("String_Node_Str",FormInstance.class);
  form=appFixtureStorage.getRecordForValues(new String[]{FormInstance.META_ID},new String[]{"String_Node_Str"});
  form.setName(newName);
  appFixtureStorage.update(form.getID(),form);
  form=appFixtureStorage.getRecordForValues(new String[]{FormInstance.META_ID},new String[]{"String_Node_Str"});
  Assert.assertEquals(newName,form.getName());
}