nus-yam/ex-repair huggingface dataset:
Program: 142259
Project: 142259
Buggy source:
private void populateAvailableAppsSpinner(){
  Spinner spinner=(Spinner)findViewById(R.id.app_selection_spinner);
  ArrayList<ApplicationRecord> readyApps=CommCareApplication._().getReadyAppRecords();
  ArrayList<String> appNames=new ArrayList<String>();
  for (  ApplicationRecord r : readyApps) {
    String name=r.getDisplayName();
    appNames.add(name);
    namesToRecords.put(name,r);
  }
  if (appNames.size() > 1) {
    ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,R.layout.spinner_text_view,appNames);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(this);
    SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(this);
    spinner.setSelection(prefs.getInt(KEY_LAST_POSITION,0));
    spinner.setVisibility(View.VISIBLE);
  }
 else   spinner.setVisibility(View.GONE);
}

Fixed version (ground truth):
private void populateAvailableAppsSpinner(){
  Spinner spinner=(Spinner)findViewById(R.id.app_selection_spinner);
  ArrayList<ApplicationRecord> readyApps=CommCareApplication._().getReadyAppRecords();
  ArrayList<String> appNames=new ArrayList<String>();
  for (  ApplicationRecord r : readyApps) {
    String name=r.getDisplayName();
    appNames.add(name);
    namesToRecords.put(name,r);
  }
  if (appNames.size() > 1) {
    ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,R.layout.spinner_text_view,appNames);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(this);
    SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(this);
    int lastPosition=prefs.getInt(KEY_LAST_POSITION,0);
    if (lastPosition >= appNames.size()) {
      lastPosition=0;
    }
    spinner.setSelection(lastPosition);
    spinner.setVisibility(View.VISIBLE);
  }
 else   spinner.setVisibility(View.GONE);
}
Program: 142260
Project: 142260
Buggy source:
private static int countDaysFromMinDay(int toYear,int toMonth,int toDay){
  if (toYear < MIN_YEAR || toYear > MAX_YEAR || toMonth < 1 || toMonth > 12 || toDay < 1 || toDay > NEPALI_YEAR_MONTHS.get(toYear)[toMonth]) {
    throw new RuntimeException("String_Node_Str");
  }
  int daysFromMinDay=0;
  for (int year=MIN_YEAR; year <= toYear; year++) {
    int[] monthsInYear=NEPALI_YEAR_MONTHS.get(year);
    for (int month=1; month <= 12; month++) {
      int daysInMonth=monthsInYear[month];
      for (int day=1; day <= daysInMonth; day++) {
        daysFromMinDay++;
        if (year == toYear && month == toMonth && day == toDay) {
          return daysFromMinDay;
        }
      }
    }
  }
  throw new RuntimeException("String_Node_Str");
}

Fixed version (ground truth):
private static int countDaysFromMinDay(int toYear,int toMonth,int toDay){
  if (toYear < MIN_YEAR || toYear > MAX_YEAR || toMonth < 1 || toMonth > 12 || toDay < 1 || toDay > NEPALI_YEAR_MONTHS.get(toYear)[toMonth]) {
    throw new RuntimeException("String_Node_Str");
  }
  int daysFromMinDay=-1;
  for (int year=MIN_YEAR; year <= toYear; year++) {
    int[] monthsInYear=NEPALI_YEAR_MONTHS.get(year);
    for (int month=1; month <= 12; month++) {
      int daysInMonth=monthsInYear[month];
      for (int day=1; day <= daysInMonth; day++) {
        daysFromMinDay++;
        if (year == toYear && month == toMonth && day == toDay) {
          return daysFromMinDay;
        }
      }
    }
  }
  throw new RuntimeException("String_Node_Str");
}
Program: 142261
Project: 142261
Buggy source:
@Override protected UniversalDate fromMillis(long millisFromJavaEpoch){
  long millisFromMinDay=millisFromJavaEpoch - MIN_MILLIS_FROM_JAVA_EPOCH;
  long daysFromMinDay=millisFromMinDay / AbstractUniversalDateWidget.MILLIS_IN_DAY;
  int days=0;
  for (int year=MIN_YEAR; year <= MAX_YEAR; year++) {
    int[] monthsInYear=NEPALI_YEAR_MONTHS.get(year);
    for (int month=1; month <= 12; month++) {
      int daysInMonth=monthsInYear[month];
      for (int day=1; day <= daysInMonth; day++) {
        days++;
        if (days == daysFromMinDay) {
          return new UniversalDate(year,month,day,millisFromJavaEpoch);
        }
      }
    }
  }
  throw new RuntimeException("String_Node_Str");
}

Fixed version (ground truth):
@Override protected UniversalDate fromMillis(long millisFromJavaEpoch){
  long millisFromMinDay=millisFromJavaEpoch - MIN_MILLIS_FROM_JAVA_EPOCH;
  long daysFromMinDay=millisFromMinDay / AbstractUniversalDateWidget.MILLIS_IN_DAY;
  int days=-1;
  for (int year=MIN_YEAR; year <= MAX_YEAR; year++) {
    int[] monthsInYear=NEPALI_YEAR_MONTHS.get(year);
    for (int month=1; month <= 12; month++) {
      int daysInMonth=monthsInYear[month];
      for (int day=1; day <= daysInMonth; day++) {
        days++;
        if (days == daysFromMinDay) {
          return new UniversalDate(year,month,day,millisFromJavaEpoch);
        }
      }
    }
  }
  throw new RuntimeException("String_Node_Str");
}
Program: 142262
Project: 142262
Buggy source:
private boolean upgradeTwoThree(SQLiteDatabase db,int oldVersion,int newVersion){
  db.beginTransaction();
  try {
    SqlStorage<Persistable> storage=new SqlStorage<Persistable>(ApplicationRecord.STORAGE_KEY,ApplicationRecordV1.class,new ConcreteDbHelper(c,db));
    for (int i=0; i < storage.getNumRecords(); i++) {
      ApplicationRecordV1 oldRecord=(ApplicationRecordV1)storage.read(0);
      ApplicationRecord newRecord=new ApplicationRecord(oldRecord.getApplicationId(),oldRecord.getStatus());
      newRecord.setID(oldRecord.getID());
      newRecord.setResourcesStatus(true);
      newRecord.setArchiveStatus(false);
      newRecord.setUniqueId(null);
      newRecord.setDisplayName(null);
      storage.write(newRecord);
    }
    return true;
  }
  finally {
    db.endTransaction();
  }
}

Fixed version (ground truth):
private boolean upgradeTwoThree(SQLiteDatabase db,int oldVersion,int newVersion){
  db.beginTransaction();
  try {
    SqlStorage<Persistable> storage=new SqlStorage<Persistable>(ApplicationRecord.STORAGE_KEY,ApplicationRecordV1.class,new ConcreteDbHelper(c,db));
    for (int i=0; i < storage.getNumRecords(); i++) {
      ApplicationRecordV1 oldRecord=(ApplicationRecordV1)storage.read(i);
      ApplicationRecord newRecord=new ApplicationRecord(oldRecord.getApplicationId(),oldRecord.getStatus());
      newRecord.setID(oldRecord.getID());
      newRecord.setResourcesStatus(true);
      newRecord.setArchiveStatus(false);
      newRecord.setUniqueId(null);
      newRecord.setDisplayName(null);
      storage.write(newRecord);
    }
    return true;
  }
  finally {
    db.endTransaction();
  }
}
Program: 142263
Project: 142263
Buggy source:
/** 
 * Get the current widget date in other chronology
 * @return
 */
private long getCurrentMillis(){
  int day=Integer.parseInt(txtDay.getText().toString());
  int month=monthArrayPointer + 1;
  int year=Integer.parseInt(txtYear.getText().toString());
  return toMillisFromJavaEpoch(year,month,day);
}

Fixed version (ground truth):
/** 
 * Get the current widget date in other chronology
 * @return
 */
private long getCurrentMillis(){
  int day=Integer.parseInt(txtDay.getText().toString());
  int month=monthArrayPointer + 1;
  int year=Integer.parseInt(txtYear.getText().toString());
  return toMillisFromJavaEpoch(year,month,day,millisOfDayOffset);
}
Program: 142264
Project: 142264
Buggy source:
protected abstract long toMillisFromJavaEpoch(int year,int month,int day);

Fixed version (ground truth):
protected abstract long toMillisFromJavaEpoch(int year,int month,int day,long millisOffset);
Program: 142265
Project: 142265
Buggy source:
@Override public void clearAnswer(){
  Date date=new Date();
  updateDateDisplay(date.getTime());
  updateGregorianDateHelperDisplay();
}

Fixed version (ground truth):
@Override public void clearAnswer(){
  Date date=new Date();
  millisOfDayOffset=date.getTime() % MILLIS_IN_DAY;
  updateDateDisplay(date.getTime());
  updateGregorianDateHelperDisplay();
}
Program: 142266
Project: 142266
Buggy source:
@Override protected long toMillisFromJavaEpoch(int year,int month,int day){
  DateTime dt=new DateTime(CHRON_ETH).withYear(year).withMonthOfYear(month).withDayOfMonth(day);
  return dt.getMillis();
}

Fixed version (ground truth):
@Override protected long toMillisFromJavaEpoch(int year,int month,int day,long millisOffset){
  DateTime dt=new DateTime(CHRON_ETH).withYear(year).withMonthOfYear(month).withDayOfMonth(day).withMillisOfDay((int)millisOffset);
  return dt.getMillis();
}
Program: 142267
Project: 142267
Buggy source:
@Override protected UniversalDate decrementYear(long millisFromJavaEpoch){
  UniversalDate origDate=fromMillis(millisFromJavaEpoch);
  int year=origDate.year;
  int month=origDate.month;
  int day=origDate.day;
  year--;
  if (year < MIN_YEAR) {
    year=MAX_YEAR;
  }
  if (day > NEPALI_YEAR_MONTHS.get(year)[month]) {
    day=NEPALI_YEAR_MONTHS.get(year)[month];
  }
  return new UniversalDate(year,month,day,toMillisFromJavaEpoch(year,month,day));
}

Fixed version (ground truth):
@Override protected UniversalDate decrementYear(long millisFromJavaEpoch){
  UniversalDate origDate=fromMillis(millisFromJavaEpoch);
  int year=origDate.year;
  int month=origDate.month;
  int day=origDate.day;
  year--;
  if (year < MIN_YEAR) {
    year=MAX_YEAR;
  }
  if (day > NEPALI_YEAR_MONTHS.get(year)[month]) {
    day=NEPALI_YEAR_MONTHS.get(year)[month];
  }
  return new UniversalDate(year,month,day,toMillisFromJavaEpoch(year,month,day,millisFromJavaEpoch % MILLIS_IN_DAY));
}
Program: 142268
Project: 142268
Buggy source:
@Override protected UniversalDate incrementMonth(long millisFromJavaEpoch){
  UniversalDate origDate=fromMillis(millisFromJavaEpoch);
  int year=origDate.year;
  int month=origDate.month;
  int day=origDate.day;
  month++;
  if (month > 12) {
    month=1;
    year++;
  }
  if (year > MAX_YEAR) {
    year=MIN_YEAR;
  }
  if (day > NEPALI_YEAR_MONTHS.get(year)[month]) {
    day=NEPALI_YEAR_MONTHS.get(year)[month];
  }
  return new UniversalDate(year,month,day,toMillisFromJavaEpoch(year,month,day));
}

Fixed version (ground truth):
@Override protected UniversalDate incrementMonth(long millisFromJavaEpoch){
  UniversalDate origDate=fromMillis(millisFromJavaEpoch);
  int year=origDate.year;
  int month=origDate.month;
  int day=origDate.day;
  month++;
  if (month > 12) {
    month=1;
    year++;
  }
  if (year > MAX_YEAR) {
    year=MIN_YEAR;
  }
  if (day > NEPALI_YEAR_MONTHS.get(year)[month]) {
    day=NEPALI_YEAR_MONTHS.get(year)[month];
  }
  return new UniversalDate(year,month,day,toMillisFromJavaEpoch(year,month,day,millisFromJavaEpoch % MILLIS_IN_DAY));
}
Program: 142269
Project: 142269
Buggy source:
@Override protected UniversalDate incrementYear(long millisFromJavaEpoch){
  UniversalDate origDate=fromMillis(millisFromJavaEpoch);
  int year=origDate.year;
  int month=origDate.month;
  int day=origDate.day;
  year++;
  if (year > MAX_YEAR) {
    year=MIN_YEAR;
  }
  if (day > NEPALI_YEAR_MONTHS.get(year)[month]) {
    day=NEPALI_YEAR_MONTHS.get(year)[month];
  }
  return new UniversalDate(year,month,day,toMillisFromJavaEpoch(year,month,day));
}

Fixed version (ground truth):
@Override protected UniversalDate incrementYear(long millisFromJavaEpoch){
  UniversalDate origDate=fromMillis(millisFromJavaEpoch);
  int year=origDate.year;
  int month=origDate.month;
  int day=origDate.day;
  year++;
  if (year > MAX_YEAR) {
    year=MIN_YEAR;
  }
  if (day > NEPALI_YEAR_MONTHS.get(year)[month]) {
    day=NEPALI_YEAR_MONTHS.get(year)[month];
  }
  return new UniversalDate(year,month,day,toMillisFromJavaEpoch(year,month,day,millisFromJavaEpoch % MILLIS_IN_DAY));
}
Program: 142270
Project: 142270
Buggy source:
@Override protected UniversalDate fromMillis(long millisFromJavaEpoch){
  long millisFromMinDay=millisFromJavaEpoch - MIN_MILLIS_FROM_JAVA_EPOCH;
  long daysFromMinDay=millisFromMinDay / AbstractUniversalDateWidget.MILLIS_IN_DAY;
  int days=-1;
  for (int year=MIN_YEAR; year <= MAX_YEAR; year++) {
    int[] monthsInYear=NEPALI_YEAR_MONTHS.get(year);
    for (int month=1; month <= 12; month++) {
      int daysInMonth=monthsInYear[month];
      for (int day=1; day <= daysInMonth; day++) {
        days++;
        if (days == daysFromMinDay) {
          return new UniversalDate(year,month,day,millisFromJavaEpoch);
        }
      }
    }
  }
  throw new RuntimeException("String_Node_Str");
}

Fixed version (ground truth):
@Override protected UniversalDate fromMillis(long millisFromJavaEpoch){
  long millisFromMinDay=millisFromJavaEpoch - MIN_MILLIS_FROM_JAVA_EPOCH;
  long daysFromMinDay=millisFromMinDay / MILLIS_IN_DAY;
  int days=-1;
  for (int year=MIN_YEAR; year <= MAX_YEAR; year++) {
    int[] monthsInYear=NEPALI_YEAR_MONTHS.get(year);
    for (int month=1; month <= 12; month++) {
      int daysInMonth=monthsInYear[month];
      for (int day=1; day <= daysInMonth; day++) {
        days++;
        if (days == daysFromMinDay) {
          return new UniversalDate(year,month,day,millisFromJavaEpoch);
        }
      }
    }
  }
  throw new RuntimeException("String_Node_Str");
}
Program: 142271
Project: 142271
Buggy source:
@Override protected UniversalDate decrementMonth(long millisFromJavaEpoch){
  UniversalDate origDate=fromMillis(millisFromJavaEpoch);
  int year=origDate.year;
  int month=origDate.month;
  int day=origDate.day;
  month--;
  if (month < 1) {
    month=12;
    year--;
  }
  if (year < MIN_YEAR) {
    year=MAX_YEAR;
  }
  if (day > NEPALI_YEAR_MONTHS.get(year)[month]) {
    day=NEPALI_YEAR_MONTHS.get(year)[month];
  }
  return new UniversalDate(year,month,day,toMillisFromJavaEpoch(year,month,day));
}

Fixed version (ground truth):
@Override protected UniversalDate decrementMonth(long millisFromJavaEpoch){
  UniversalDate origDate=fromMillis(millisFromJavaEpoch);
  int year=origDate.year;
  int month=origDate.month;
  int day=origDate.day;
  month--;
  if (month < 1) {
    month=12;
    year--;
  }
  if (year < MIN_YEAR) {
    year=MAX_YEAR;
  }
  if (day > NEPALI_YEAR_MONTHS.get(year)[month]) {
    day=NEPALI_YEAR_MONTHS.get(year)[month];
  }
  return new UniversalDate(year,month,day,toMillisFromJavaEpoch(year,month,day,millisFromJavaEpoch % MILLIS_IN_DAY));
}
Program: 142272
Project: 142272
Buggy source:
@Override protected long toMillisFromJavaEpoch(int year,int month,int day){
  int daysFromMinDay=countDaysFromMinDay(year,month,day);
  long millisFromMinDay=daysFromMinDay * AbstractUniversalDateWidget.MILLIS_IN_DAY;
  return millisFromMinDay + MIN_MILLIS_FROM_JAVA_EPOCH;
}

Fixed version (ground truth):
@Override protected long toMillisFromJavaEpoch(int year,int month,int day,long millisOffset){
  int daysFromMinDay=countDaysFromMinDay(year,month,day);
  long millisFromMinDay=daysFromMinDay * MILLIS_IN_DAY;
  return millisFromMinDay + MIN_MILLIS_FROM_JAVA_EPOCH + millisOffset;
}
Program: 142273
Project: 142273
Buggy source:
private boolean upgradeFiveSix(SQLiteDatabase db,int oldVersion,int newVersion){
  db.beginTransaction();
  try {
    db.execSQL("String_Node_Str");
    DbUtil.createNumbersTable(db);
    db.execSQL(EntityStorageCache.getTableDefinition());
    EntityStorageCache.createIndexes(db);
    db.execSQL(CaseIndexTable.getTableDefinition());
    CaseIndexTable.createIndexes(db);
    CaseIndexTable cit=new CaseIndexTable();
    for (    ACase c : CommCareApplication._().getUserStorage(ACase.STORAGE_KEY,ACasePreV6Model.class)) {
      cit.indexCase(c);
    }
    db.setTransactionSuccessful();
    return true;
  }
  finally {
    db.endTransaction();
  }
}

Fixed version (ground truth):
private boolean upgradeFiveSix(SQLiteDatabase db,int oldVersion,int newVersion){
  db.beginTransaction();
  try {
    db.execSQL("String_Node_Str");
    DbUtil.createNumbersTable(db);
    db.execSQL(EntityStorageCache.getTableDefinition());
    EntityStorageCache.createIndexes(db);
    db.execSQL(CaseIndexTable.getTableDefinition());
    CaseIndexTable.createIndexes(db);
    CaseIndexTable cit=new CaseIndexTable();
    SqlStorage<ACase> caseStorage=new SqlStorage<ACase>(ACase.STORAGE_KEY,ACasePreV6Model.class,new ConcreteDbHelper(c,db));
    for (    ACase c : caseStorage) {
      cit.indexCase(c);
    }
    db.setTransactionSuccessful();
    return true;
  }
  finally {
    db.endTransaction();
  }
}
Program: 142274
Project: 142274
Buggy source:
private boolean upgradeSixSeven(SQLiteDatabase db,int oldVersion,int newVersion){
  db.beginTransaction();
  try {
    updateModels(CommCareApplication._().getUserStorage(ACase.STORAGE_KEY,ACasePreV6Model.class));
    db.setTransactionSuccessful();
    return true;
  }
  finally {
    db.endTransaction();
  }
}

Fixed version (ground truth):
private boolean upgradeSixSeven(SQLiteDatabase db,int oldVersion,int newVersion){
  long start=System.currentTimeMillis();
  db.beginTransaction();
  try {
    SqlStorage<ACase> caseStorage=new SqlStorage<ACase>(ACase.STORAGE_KEY,ACasePreV6Model.class,new ConcreteDbHelper(c,db));
    updateModels(caseStorage);
    db.setTransactionSuccessful();
    return true;
  }
  finally {
    db.endTransaction();
    System.out.println("String_Node_Str" + (System.currentTimeMillis() - start) + "String_Node_Str");
  }
}
Program: 142276
Project: 142276
Buggy source:
private boolean yOutOfBounds(float y,FillOutsideLine.Type type,Canvas canvas){
  if (type == FillOutsideLine.Type.BOUNDS_ALL) {
    return false;
  }
  if (type == FillOutsideLine.Type.BOUNDS_BELOW) {
    return false;
  }
  if (type == FillOutsideLine.Type.BOUNDS_ABOVE) {
    return false;
  }
  if (type == FillOutsideLine.Type.ABOVE) {
    return y > canvas.getHeight();
  }
  if (type == FillOutsideLine.Type.BELOW) {
    return y < 0;
  }
  throw new RuntimeException("String_Node_Str");
}

Fixed version (ground truth):
private boolean yOutOfBounds(float y,FillOutsideLine.Type type,Canvas canvas){
  if (type == FillOutsideLine.Type.BOUNDS_ALL) {
    return false;
  }
  if (type == FillOutsideLine.Type.BOUNDS_BELOW) {
    return false;
  }
  if (type == FillOutsideLine.Type.BOUNDS_ABOVE) {
    return false;
  }
  if (type == FillOutsideLine.Type.ABOVE) {
    return y > canvas.getHeight() || y < 0;
  }
  if (type == FillOutsideLine.Type.BELOW) {
    return y < 0;
  }
  throw new RuntimeException("String_Node_Str");
}
Program: 142277
Project: 142277
Buggy source:
public static boolean isActionBarEnabled(){
  SharedPreferences properties=CommCareApplication._().getCurrentApp().getAppPreferences();
  return properties.getString(ACTION_BAR_ENABLED,CommCarePreferences.NO).equals(CommCarePreferences.YES);
}

Fixed version (ground truth):
public static boolean isActionBarEnabled(){
  return doesPropertyMatch(ACTION_BAR_ENABLED,CommCarePreferences.NO,CommCarePreferences.YES);
}
Program: 142278
Project: 142278
Buggy source:
public static boolean isNewNavEnabled(){
  SharedPreferences properties=CommCareApplication._().getCurrentApp().getAppPreferences();
  return properties.getString(NAV_UI_ENABLED,CommCarePreferences.NO).equals(CommCarePreferences.YES);
}

Fixed version (ground truth):
public static boolean isNewNavEnabled(){
  return doesPropertyMatch(NAV_UI_ENABLED,CommCarePreferences.NO,CommCarePreferences.YES);
}
Program: 142279
Project: 142279
Buggy source:
public static boolean isSuperuserEnabled(){
  SharedPreferences properties=CommCareApplication._().getCurrentApp().getAppPreferences();
  return properties.getString(SUPERUSER_ENABLED,BuildConfig.DEBUG ? CommCarePreferences.YES : CommCarePreferences.NO).equals(CommCarePreferences.YES);
}

Fixed version (ground truth):
public static boolean isSuperuserEnabled(){
  return doesPropertyMatch(SUPERUSER_ENABLED,BuildConfig.DEBUG ? CommCarePreferences.YES : CommCarePreferences.NO,CommCarePreferences.YES);
}
Program: 142280
Project: 142280
Buggy source:
public EntityListAdapter(Activity activity,Detail detail,List<TreeReference> references,List<Entity<TreeReference>> full,int[] sort,TextToSpeech tts,AudioController controller,NodeEntityFactory factory) throws SessionUnavailableException {
  this.detail=detail;
  this.full=full;
  current=new ArrayList<Entity<TreeReference>>();
  this.references=references;
  this.context=activity;
  this.observers=new ArrayList<DataSetObserver>();
  mNodeFactory=factory;
  if (!(factory instanceof AsyncNodeEntityFactory)) {
    if (sort.length != 0) {
      sort(sort);
    }
    filterValues("String_Node_Str");
  }
 else {
    current=new ArrayList<Entity<TreeReference>>(full);
  }
  this.tts=tts;
  this.controller=controller;
  if (android.os.Build.VERSION.SDK_INT >= 14) {
    mImageLoader=new CachingAsyncImageLoader(context,SCALE_FACTOR);
  }
 else {
    mImageLoader=null;
  }
  if (detail.getCustomAction() != null) {
  }
  usesGridView=detail.usesGridView();
  this.mFuzzySearchEnabled=CommCarePreferences.isFuzzySearchEnabled();
  actionEnabled=detail.getCustomAction() != null;
}

Fixed version (ground truth):
public EntityListAdapter(Activity activity,Detail detail,List<TreeReference> references,List<Entity<TreeReference>> full,int[] sort,TextToSpeech tts,AudioController controller,NodeEntityFactory factory) throws SessionUnavailableException {
  this.detail=detail;
  this.full=full;
  current=new ArrayList<Entity<TreeReference>>();
  this.references=references;
  this.context=activity;
  this.observers=new ArrayList<DataSetObserver>();
  mNodeFactory=factory;
  if (!(factory instanceof AsyncNodeEntityFactory)) {
    if (sort.length != 0) {
      sort(sort);
    }
    filterValues("String_Node_Str");
  }
 else {
    current=new ArrayList<Entity<TreeReference>>(full);
    actionPosition=current.size();
  }
  this.tts=tts;
  this.controller=controller;
  if (android.os.Build.VERSION.SDK_INT >= 14) {
    mImageLoader=new CachingAsyncImageLoader(context,SCALE_FACTOR);
  }
 else {
    mImageLoader=null;
  }
  if (detail.getCustomAction() != null) {
  }
  usesGridView=detail.usesGridView();
  this.mFuzzySearchEnabled=CommCarePreferences.isFuzzySearchEnabled();
  actionEnabled=detail.getCustomAction() != null;
}
Program: 142281
Project: 142281
Buggy source:
@Override public void onResume(){
  super.onResume();
  if (tile != null) {
    ViewGroup vg=(ViewGroup)this.getActivity().findViewById(R.id.universal_frame_tile);
    if (vg != null) {
      vg.addView(tile,LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);
      mInternalDetailView=null;
    }
  }
  if (this.getActivity() instanceof CommCareActivity) {
    String title=((CommCareActivity)this.getActivity()).getActivityTitle();
    if (title != null) {
      if (!breadCrumbsEnabled) {
        ActionBar actionBar=this.getActivity().getActionBar();
        actionBar.setSubtitle(title);
      }
 else {
        if (localIdPart != -1) {
          TextView text=(TextView)this.getActivity().getActionBar().getCustomView().findViewById(localIdPart);
          if (text != null) {
            text.setText(title);
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override public void onResume(){
  super.onResume();
  if (tile != null) {
    ViewGroup vg=(ViewGroup)this.getActivity().findViewById(R.id.universal_frame_tile);
    if (vg != null) {
      if (((ViewGroup)tile.getParent()) != null) {
        ((ViewGroup)tile.getParent()).removeView(tile);
      }
      vg.addView(tile,LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);
      mInternalDetailView=null;
    }
  }
  if (this.getActivity() instanceof CommCareActivity) {
    String title=((CommCareActivity)this.getActivity()).getActivityTitle();
    if (title != null) {
      if (!breadCrumbsEnabled) {
        ActionBar actionBar=this.getActivity().getActionBar();
        actionBar.setSubtitle(title);
      }
 else {
        if (localIdPart != -1) {
          TextView text=(TextView)this.getActivity().getActionBar().getCustomView().findViewById(localIdPart);
          if (text != null) {
            text.setText(title);
          }
        }
      }
    }
  }
}
Program: 142284
Project: 142284
Buggy source:
public void setupImageLayout(View layout,final String source){
  ImageView iv=(ImageView)layout;
  Bitmap b;
  if (!source.equals("String_Node_Str")) {
    try {
      b=BitmapFactory.decodeStream(ReferenceManager._().DeriveReference(source).getStream());
      if (b == null) {
        iv.setImageDrawable(getResources().getDrawable(R.drawable.ic_menu_archive));
      }
 else {
        iv.setImageBitmap(b);
      }
    }
 catch (    IOException ex) {
      ex.printStackTrace();
      iv.setImageDrawable(getResources().getDrawable(R.drawable.ic_menu_archive));
    }
catch (    InvalidReferenceException ex) {
      ex.printStackTrace();
      iv.setImageDrawable(getResources().getDrawable(R.drawable.ic_menu_archive));
    }
  }
 else {
    iv.setImageDrawable(getResources().getDrawable(R.drawable.ic_menu_archive));
  }
}

Fixed version (ground truth):
public void setupImageLayout(View layout,final String source){
  ImageView iv=(ImageView)layout;
  Bitmap b;
  if (!source.equals("String_Node_Str")) {
    try {
      b=BitmapFactory.decodeStream(ReferenceManager._().DeriveReference(source).getStream());
      if (b == null) {
        iv.setImageDrawable(getResources().getDrawable(R.drawable.ic_menu_archive));
      }
 else {
        iv.setImageBitmap(b);
      }
    }
 catch (    IOException ex) {
      ex.printStackTrace();
      iv.setImageDrawable(getResources().getDrawable(R.drawable.ic_menu_archive));
    }
catch (    InvalidReferenceException ex) {
      ex.printStackTrace();
      iv.setImageDrawable(getResources().getDrawable(R.drawable.ic_menu_archive));
    }
  }
 else {
    iv.setImageDrawable(getResources().getDrawable(R.drawable.white));
  }
}
Program: 142285
Project: 142285
Buggy source:
@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case MENU_PREFERENCES:
    createPreferencesMenu();
  return true;
case MENU_UPDATE:
if (isAirplaneModeOn()) {
  CommCareApplication._().reportNotificationMessage(NotificationMessageFactory.message(StockMessages.Sync_AirplaneMode));
  return true;
}
Intent i=new Intent(getApplicationContext(),CommCareSetupActivity.class);
SharedPreferences prefs=CommCareApplication._().getCurrentApp().getAppPreferences();
String ref=prefs.getString("String_Node_Str",null);
i.putExtra(CommCareSetupActivity.KEY_PROFILE_REF,ref);
i.putExtra(CommCareSetupActivity.KEY_UPGRADE_MODE,true);
startActivityForResult(i,UPGRADE_APP);
return true;
case MENU_CALL_LOG:
createCallLogActivity();
return true;
case MENU_REPORT_PROBLEM:
startReportActivity();
return true;
case MENU_VALIDATE_MEDIA:
startValidationActivity();
return true;
case MENU_DUMP_FORMS:
startFormDumpActivity();
return true;
case MENU_WIFI_DIRECT:
startWifiDirectActivity();
return true;
case MENU_CONNECTION_DIAGNOSTIC:
startMenuConnectionActivity();
return true;
case MENU_SAVED_FORMS:
goToFormArchive(false);
return true;
case MENU_SAVED_FORMS:
goToFormArchive(false);
return true;
}
return super.onOptionsItemSelected(item);
}

Fixed version (ground truth):
@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case MENU_PREFERENCES:
    createPreferencesMenu();
  return true;
case MENU_UPDATE:
if (isAirplaneModeOn()) {
  CommCareApplication._().reportNotificationMessage(NotificationMessageFactory.message(StockMessages.Sync_AirplaneMode));
  return true;
}
Intent i=new Intent(getApplicationContext(),CommCareSetupActivity.class);
SharedPreferences prefs=CommCareApplication._().getCurrentApp().getAppPreferences();
String ref=prefs.getString("String_Node_Str",null);
i.putExtra(CommCareSetupActivity.KEY_PROFILE_REF,ref);
i.putExtra(CommCareSetupActivity.KEY_UPGRADE_MODE,true);
startActivityForResult(i,UPGRADE_APP);
return true;
case MENU_CALL_LOG:
createCallLogActivity();
return true;
case MENU_REPORT_PROBLEM:
startReportActivity();
return true;
case MENU_VALIDATE_MEDIA:
startValidationActivity();
return true;
case MENU_DUMP_FORMS:
startFormDumpActivity();
return true;
case MENU_WIFI_DIRECT:
startWifiDirectActivity();
return true;
case MENU_CONNECTION_DIAGNOSTIC:
startMenuConnectionActivity();
return true;
case MENU_SAVED_FORMS:
goToFormArchive(false);
return true;
}
return super.onOptionsItemSelected(item);
}
Program: 142287
Project: 142287
Buggy source:
private void startFormEntry(AndroidSessionWrapper state) throws SessionUnavailableException {
  try {
    if (state.getFormRecordId() == -1) {
      if (CommCarePreferences.isIncompleteFormsEnabled()) {
        SessionStateDescriptor existing=state.searchForDuplicates();
        if (existing != null && existing.getSessionDescriptor().contains(SessionFrame.STATE_DATUM_VAL)) {
          createAskUseOldDialog(state,existing);
          return;
        }
      }
      state.commitStub();
    }
 else {
      Logger.log("String_Node_Str","String_Node_Str");
    }
    FormRecord record=state.getFormRecord();
    formEntry(platform.getFormContentUri(record.getFormNamespace()),record,CommCareActivity.getTitle(this,null));
  }
 catch (  StorageFullException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
private void startFormEntry(AndroidSessionWrapper state) throws SessionUnavailableException {
  try {
    if (state.getFormRecordId() == -1) {
      if (CommCarePreferences.isIncompleteFormsEnabled()) {
        SessionStateDescriptor existing=state.searchForDuplicates();
        if (existing != null && existing.getSessionDescriptor().contains(SessionFrame.STATE_DATUM_VAL)) {
          createAskUseOldDialog(state,existing);
          return;
        }
      }
      state.commitStub();
    }
 else {
      Logger.log("String_Node_Str","String_Node_Str");
    }
    FormRecord record=state.getFormRecord();
    if (platform == null) {
      platform=CommCareApplication._().getCurrentApp() == null ? null : CommCareApplication._().getCurrentApp().getCommCarePlatform();
    }
    formEntry(platform.getFormContentUri(record.getFormNamespace()),record,CommCareActivity.getTitle(this,null));
  }
 catch (  StorageFullException e) {
    throw new RuntimeException(e);
  }
}
Program: 142288
Project: 142288
Buggy source:
public void onResume(){
  super.onResume();
  if (this.isFinishing() || startOther) {
    return;
  }
  if (!resuming && !mNoDetailMode && this.getIntent().hasExtra(EXTRA_ENTITY_KEY)) {
    TreeReference entity=getEntityFromID(this.getIntent().getStringExtra(EXTRA_ENTITY_KEY));
    if (entity != null) {
      if (inAwesomeMode) {
        displayReferenceAwesome(entity,adapter.getPosition(entity));
        updateSelectedItem(entity,true);
      }
 else {
        this.getIntent().removeExtra(EXTRA_ENTITY_KEY);
        Intent i=getDetailIntent(entity);
        if (adapter != null) {
          i.putExtra("String_Node_Str",adapter.getPosition(entity));
        }
        startActivityForResult(i,CONFIRM_SELECT);
        return;
      }
    }
  }
  refreshView();
}

Fixed version (ground truth):
public void onResume(){
  super.onResume();
  if (this.isFinishing() || startOther) {
    return;
  }
  if (!resuming && !mNoDetailMode && this.getIntent().hasExtra(EXTRA_ENTITY_KEY)) {
    TreeReference entity=getEntityFromID(this.getIntent().getStringExtra(EXTRA_ENTITY_KEY));
    if (entity != null) {
      if (inAwesomeMode) {
        if (adapter != null) {
          displayReferenceAwesome(entity,adapter.getPosition(entity));
          updateSelectedItem(entity,true);
        }
      }
 else {
        this.getIntent().removeExtra(EXTRA_ENTITY_KEY);
        Intent i=getDetailIntent(entity);
        if (adapter != null) {
          i.putExtra("String_Node_Str",adapter.getPosition(entity));
        }
        startActivityForResult(i,CONFIRM_SELECT);
        return;
      }
    }
  }
  refreshView();
}
Program: 142290
Project: 142290
Buggy source:
protected PasswordAuthentication getPasswordAuthentication(){
  return passwordAuthentication;
}

Fixed version (ground truth):
@Override protected PasswordAuthentication getPasswordAuthentication(){
  return passwordAuthentication;
}
Program: 142291
Project: 142291
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");
  }
  setContentView(R.layout.mainnew);
  configUi();
}

Fixed version (ground truth):
/** 
 * Called when the activity is first created. 
 */
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (!isTaskRoot()) {
    Intent intent=getIntent();
    String action=intent.getAction();
    if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && action != null && action.equals(Intent.ACTION_MAIN)) {
      finish();
      return;
    }
  }
  if (savedInstanceState != null) {
    wasExternal=savedInstanceState.getBoolean("String_Node_Str");
  }
  setContentView(R.layout.mainnew);
  configUi();
}
Program: 142292
Project: 142292
Buggy source:
public T newObject(byte[] data){
  try {
    T e=(T)ctype.newInstance();
    e.readExternal(new DataInputStream(new ByteArrayInputStream(data)),helper.getPrototypeFactory());
    return e;
  }
 catch (  IllegalAccessException e1) {
    e1.printStackTrace();
  }
catch (  InstantiationException e1) {
    e1.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
catch (  DeserializationException e) {
    e.printStackTrace();
  }
  return null;
}

Fixed version (ground truth):
public T newObject(byte[] data){
  try {
    T e=(T)ctype.newInstance();
    e.readExternal(new DataInputStream(new ByteArrayInputStream(data)),helper.getPrototypeFactory());
    return e;
  }
 catch (  IllegalAccessException e) {
    RuntimeException re=new RuntimeException("String_Node_Str" + ctype.getName());
    re.initCause(e);
    Logger.log(AndroidLogger.TYPE_ERROR_STORAGE,ExceptionReportTask.getStackTrace(re,true));
    throw re;
  }
catch (  InstantiationException e) {
    RuntimeException re=new RuntimeException("String_Node_Str" + ctype.getName());
    re.initCause(e);
    Logger.log(AndroidLogger.TYPE_ERROR_STORAGE,ExceptionReportTask.getStackTrace(re,true));
    throw re;
  }
catch (  IOException e) {
    RuntimeException re=new RuntimeException("String_Node_Str" + ctype.getName());
    re.initCause(e);
    Logger.log(AndroidLogger.TYPE_ERROR_STORAGE,ExceptionReportTask.getStackTrace(re,true));
    throw re;
  }
catch (  DeserializationException e) {
    RuntimeException re=new RuntimeException("String_Node_Str" + ctype.getName());
    re.initCause(e);
    Logger.log(AndroidLogger.TYPE_ERROR_STORAGE,ExceptionReportTask.getStackTrace(re,true));
    throw re;
  }
}
Program: 142293
Project: 142293
Buggy source:
public static String getStackTrace(Throwable e){
  ByteArrayOutputStream bos=new ByteArrayOutputStream();
  e.printStackTrace(new PrintStream(bos));
  return new String(bos.toByteArray());
}

Fixed version (ground truth):
public static String getStackTrace(Throwable e,boolean fullContext){
  ByteArrayOutputStream bos=new ByteArrayOutputStream();
  e.printStackTrace(new PrintStream(bos));
  String retString=new String(bos.toByteArray());
  if (fullContext && e.getCause() != null) {
    retString+="String_Node_Str" + getStackTrace(e.getCause(),false);
  }
  return retString;
}
Program: 142294
Project: 142294
Buggy source:
public void resetRecords() throws SessionUnavailableException {
  if (loader.getStatus() == Status.RUNNING) {
    loader.cancel(false);
    loader=loader.spawn();
  }
 else   if (loader.getStatus() == Status.FINISHED) {
    loader=loader.spawn();
  }
  SqlStorage<FormRecord> storage=CommCareApplication._().getUserStorage(FormRecord.class);
  if (filter == null) {
    filter=FormRecordFilter.SubmittedAndPending;
  }
  records=new Vector<FormRecord>();
  for (  String status : filter.getStatus()) {
    records.addAll(storage.getRecordsForValues(new String[]{FormRecord.META_STATUS},new Object[]{status}));
  }
  Collections.sort(records,new Comparator<FormRecord>(){
    public int compare(    FormRecord one,    FormRecord two){
      long ot=one.lastModified().getTime();
      long tt=two.lastModified().getTime();
      return ot > tt ? -1 : ot == tt ? 0 : 1;
    }
  }
);
  searchCache=new Hashtable<Integer,String[]>();
  current=new ArrayList<FormRecord>();
  this.filterValues(currentQuery);
  loader.init(searchCache);
  loader.execute(records.toArray(new FormRecord[0]));
}

Fixed version (ground truth):
public void resetRecords() throws SessionUnavailableException {
  if (loader.getStatus() == Status.RUNNING) {
    loader.cancel(false);
    loader=loader.spawn();
  }
 else   if (loader.getStatus() == Status.FINISHED) {
    loader=loader.spawn();
  }
  SqlStorage<FormRecord> storage=CommCareApplication._().getUserStorage(FormRecord.class);
  if (filter == null) {
    filter=FormRecordFilter.SubmittedAndPending;
  }
  records=new Vector<FormRecord>();
  for (  String status : filter.getStatus()) {
    records.addAll(storage.getRecordsForValues(new String[]{FormRecord.META_STATUS},new Object[]{status}));
  }
  Collections.sort(records,new Comparator<FormRecord>(){
    public int compare(    FormRecord one,    FormRecord two){
      long ot=one.lastModified().getTime();
      long tt=two.lastModified().getTime();
      return ot > tt ? -1 : ot == tt ? 0 : 1;
    }
  }
);
  searchCache=new Hashtable<Integer,String[]>();
  current=new ArrayList<FormRecord>();
  this.filterValues(currentQuery);
  loader.init(searchCache,names);
  loader.execute(records.toArray(new FormRecord[0]));
}
Program: 142295
Project: 142295
Buggy source:
public void init(Hashtable<Integer,String[]> searchCache){
  this.searchCache=searchCache;
  if (descriptorCache == null) {
    descriptorCache=new Hashtable<String,String>();
  }
  priorityQueue=new LinkedList<FormRecord>();
  loaded=new HashSet<Integer>();
}

Fixed version (ground truth):
public void init(Hashtable<Integer,String[]> searchCache,Hashtable<String,Text> formNames){
  this.searchCache=searchCache;
  if (descriptorCache == null) {
    descriptorCache=new Hashtable<String,String>();
  }
  priorityQueue=new LinkedList<FormRecord>();
  loaded=new HashSet<Integer>();
  this.formNames=formNames;
}
Program: 142298
Project: 142298
Buggy source:
@Override public void onItemSelected(AdapterView<?> arg0,View arg1,int index,long id){
  adapter.setFormFilter(FormRecordFilter.values()[index]);
  adapter.resetRecords();
  adapter.notifyDataSetChanged();
  invalidateOptionsMenu();
}

Fixed version (ground truth):
@Override public void onItemSelected(AdapterView<?> arg0,View arg1,int index,long id){
  adapter.setFormFilter(FormRecordFilter.values()[index]);
  adapter.resetRecords();
  adapter.notifyDataSetChanged();
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
    invalidateOptionsMenu();
  }
}
Program: 142300
Project: 142300
Buggy source:
public void setParams(Entity e,boolean currentlySelected){
  for (int i=0; i < e.getNumFields(); ++i) {
    if (views[i] == null) {
      continue;
    }
    if (e.getField(i) == null) {
      continue;
    }
    if ("String_Node_Str".equals(forms[i])) {
      ImageView iv=(ImageView)views[i];
      Bitmap b;
      try {
        if (!e.getField(i).equals("String_Node_Str")) {
          b=BitmapFactory.decodeStream(ReferenceManager._().DeriveReference(e.getField(i)).getStream());
          iv.setImageBitmap(b);
        }
      }
 catch (      IOException ex) {
        ex.printStackTrace();
        iv.setImageBitmap(null);
      }
catch (      InvalidReferenceException ex) {
        ex.printStackTrace();
        iv.setImageBitmap(null);
      }
    }
 else {
      setupLayout(views[i],e.getField(i));
    }
  }
  if (currentlySelected) {
    this.setBackgroundResource(R.drawable.grey_bordered_box);
  }
 else {
    this.setBackgroundDrawable(null);
  }
}

Fixed version (ground truth):
public void setParams(Entity e,boolean currentlySelected){
  for (int i=0; i < e.getNumFields(); ++i) {
    if (views[i] == null) {
      continue;
    }
    if (e.getField(i) == null) {
      continue;
    }
    if ("String_Node_Str".equals(forms[i])) {
      ImageView iv=(ImageView)views[i];
      Bitmap b;
      try {
        if (!e.getField(i).equals("String_Node_Str")) {
          b=BitmapFactory.decodeStream(ReferenceManager._().DeriveReference(e.getField(i)).getStream());
          iv.setImageBitmap(b);
        }
 else {
          iv.setImageBitmap(null);
        }
      }
 catch (      IOException ex) {
        ex.printStackTrace();
        iv.setImageBitmap(null);
      }
catch (      InvalidReferenceException ex) {
        ex.printStackTrace();
        iv.setImageBitmap(null);
      }
    }
 else {
      setupLayout(views[i],e.getField(i));
    }
  }
  if (currentlySelected) {
    this.setBackgroundResource(R.drawable.grey_bordered_box);
  }
 else {
    this.setBackgroundDrawable(null);
  }
}
Program: 142301
Project: 142301
Buggy source:
public SqlStorageIterator<T> iterate(){
  Cursor c=helper.getHandle().query(table,new String[]{DbUtil.ID_COL},null,null,null,null,DbUtil.ID_COL);
  return new SqlStorageIterator<T>(c,this);
}

Fixed version (ground truth):
public SqlStorageIterator<T> iterate(){
  Cursor c=helper.getHandle().query(table,new String[]{DbUtil.ID_COL,DbUtil.DATA_COL},null,null,null,null,DbUtil.ID_COL);
  return new SqlStorageIterator<T>(c,this);
}
Program: 142302
Project: 142302
Buggy source:
/** 
 * Clear all local state and return this session to completely fresh
 */
public void reset(){
  this.session.clearAllState();
  formRecordId=-1;
  instanceUri=null;
  instanceStatus=null;
  sessionStateRecordId=-1;
}

Fixed version (ground truth):
/** 
 * Clear all local state and return this session to completely fresh
 */
public void reset(){
  this.session.clearAllState();
  cleanVolatiles();
}
Program: 142303
Project: 142303
Buggy source:
/** 
 * Finish and seal the current session. Run any stack operations mandated by the current entry and pop a new frame from the stack, if one exists.
 */
public boolean terminateSession(){
  Vector<StackOperation> ops=session.getCurrentEntry().getPostEntrySessionOperations();
  if (ops.size() > 0) {
    EvaluationContext ec=getEC();
    for (    StackOperation op : ops) {
      session.executeStackOperation(op,ec);
    }
  }
  if (session.finishAndPop()) {
    formRecordId=-1;
    instanceUri=null;
    instanceStatus=null;
    sessionStateRecordId=-1;
    return true;
  }
 else {
    reset();
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Finish and seal the current session. Run any stack operations mandated by the current entry and pop a new frame from the stack, if one exists.
 */
public boolean terminateSession(){
  Vector<StackOperation> ops=session.getCurrentEntry().getPostEntrySessionOperations();
  if (ops.size() > 0) {
    EvaluationContext ec=getEC();
    for (    StackOperation op : ops) {
      session.executeStackOperation(op,ec);
    }
  }
  if (session.finishAndPop()) {
    cleanVolatiles();
    return true;
  }
 else {
    reset();
    return false;
  }
}
Program: 142304
Project: 142304
Buggy source:
private String readInput(InputStream stream,CommCareTransactionParserFactory factory) throws InvalidStructureException, IOException, XmlPullParserException, UnfullfilledRequirementsException, SessionUnavailableException {
  DataModelPullParser parser;
  factory.initCaseParser();
  Hashtable<String,String> formNamespaces=new Hashtable<String,String>();
  for (  String xmlns : CommCareApplication._().getCommCarePlatform().getInstalledForms()) {
    Cursor cur=c.getContentResolver().query(CommCareApplication._().getCommCarePlatform().getFormContentUri(xmlns),new String[]{FormsColumns.FORM_FILE_PATH},null,null,null);
    if (cur.moveToFirst()) {
      String path=cur.getString(cur.getColumnIndex(FormsColumns.FORM_FILE_PATH));
      formNamespaces.put(xmlns,path);
    }
 else {
      throw new RuntimeException("String_Node_Str" + CommCareApplication._().getCommCarePlatform().getFormContentUri(xmlns));
    }
    cur.close();
  }
  factory.initFormInstanceParser(formNamespaces);
  SQLiteDatabase db=CommCareApplication._().getUserDbHandle();
  try {
    db.beginTransaction();
    parser=new DataModelPullParser(stream,factory);
    parser.parse();
    db.setTransactionSuccessful();
  }
  finally {
    db.endTransaction();
  }
  return factory.getSyncToken();
}

Fixed version (ground truth):
private String readInput(InputStream stream,CommCareTransactionParserFactory factory) throws InvalidStructureException, IOException, XmlPullParserException, UnfullfilledRequirementsException, SessionUnavailableException {
  DataModelPullParser parser;
  factory.initCaseParser();
  factory.initStockParser();
  Hashtable<String,String> formNamespaces=new Hashtable<String,String>();
  for (  String xmlns : CommCareApplication._().getCommCarePlatform().getInstalledForms()) {
    Cursor cur=c.getContentResolver().query(CommCareApplication._().getCommCarePlatform().getFormContentUri(xmlns),new String[]{FormsColumns.FORM_FILE_PATH},null,null,null);
    if (cur.moveToFirst()) {
      String path=cur.getString(cur.getColumnIndex(FormsColumns.FORM_FILE_PATH));
      formNamespaces.put(xmlns,path);
    }
 else {
      throw new RuntimeException("String_Node_Str" + CommCareApplication._().getCommCarePlatform().getFormContentUri(xmlns));
    }
    cur.close();
  }
  factory.initFormInstanceParser(formNamespaces);
  SQLiteDatabase db=CommCareApplication._().getUserDbHandle();
  try {
    db.beginTransaction();
    parser=new DataModelPullParser(stream,factory);
    parser.parse();
    db.setTransactionSuccessful();
  }
  finally {
    db.endTransaction();
  }
  return factory.getSyncToken();
}
Program: 142305
Project: 142305
Buggy source:
private FormRecord process(FormRecord record) throws InvalidStructureException, IOException, XmlPullParserException, UnfullfilledRequirementsException, StorageFullException {
  String form=record.getPath(c);
  DataModelPullParser parser;
  final File f=new File(form);
  final Cipher decrypter=FormUploadUtil.getDecryptCipher((new SecretKeySpec(record.getAesKey(),"String_Node_Str")));
  InputStream is=new CipherInputStream(new FileInputStream(f),decrypter);
  parser=new DataModelPullParser(is,new TransactionParserFactory(){
    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;
    }
  }
,true,true);
  parser.parse();
  is.close();
  return updateRecordStatus(record,FormRecord.STATUS_UNSENT);
}

Fixed version (ground truth):
/** 
 * This is the entry point for processing a form. New transaction types should all be declared here. 
 * @param record
 * @return
 * @throws InvalidStructureException
 * @throws IOException
 * @throws XmlPullParserException
 * @throws UnfullfilledRequirementsException
 * @throws StorageFullException
 */
private FormRecord process(FormRecord record) throws InvalidStructureException, IOException, XmlPullParserException, UnfullfilledRequirementsException, StorageFullException {
  String form=record.getPath(c);
  DataModelPullParser parser;
  final File f=new File(form);
  final Cipher decrypter=FormUploadUtil.getDecryptCipher((new SecretKeySpec(record.getAesKey(),"String_Node_Str")));
  InputStream is=new CipherInputStream(new FileInputStream(f),decrypter);
  parser=new DataModelPullParser(is,new TransactionParserFactory(){
    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;
    }
  }
,true,true);
  parser.parse();
  is.close();
  return updateRecordStatus(record,FormRecord.STATUS_UNSENT);
}