nus-yam/ex-repair huggingface dataset:
Program: 146304
Project: 146304
Buggy source:
@Override public List<CommoditySnapshotValue> getActivitiesValues() throws Exception {
  List<CommoditySnapshotValue> commoditySnapshotValues=new ArrayList<>(1);
  commoditySnapshotValues.add(new CommoditySnapshotValue(getCommodity().getCommodityAction(STOCK_ON_HAND.getActivity()),getQuantity(),getDate()));
  return commoditySnapshotValues;
}

Fixed version (ground truth):
@Override public List<CommoditySnapshotValue> getActivitiesValues() throws Exception {
  List<CommoditySnapshotValue> commoditySnapshotValues=new ArrayList<>(1);
  commoditySnapshotValues.add(new CommoditySnapshotValue(getCommodity().getCommodityAction(STOCK_ON_HAND.getActivity()),getQuantity(),getCreated()));
  return commoditySnapshotValues;
}
Program: 146305
Project: 146305
Buggy source:
public void save(final List<Adjustment> adjustments){
  dbutil.withDao(Adjustment.class,new DbUtil.Operation<Adjustment,String>(){
    @Override public String operate(    Dao dao) throws SQLException {
      for (      Adjustment adjustment : adjustments) {
        dao.create(adjustment);
        StockItemSnapshot sis;
        if (adjustment.isPositive()) {
          sis=stockService.increaseStockLevelFor(adjustment.getCommodity(),adjustment.getQuantity(),adjustment.getCreated());
        }
 else {
          sis=stockService.reduceStockLevelFor(adjustment.getCommodity(),adjustment.getQuantity(),adjustment.getCreated());
        }
        commoditySnapshotService.add(sis,true);
        commoditySnapshotService.add(adjustment);
      }
      return null;
    }
  }
);
  categoryService.clearCache();
  alertsService.disableAllMonthlyStockCountAlerts();
  alertsService.updateLowStockAlerts();
}

Fixed version (ground truth):
public void save(final List<Adjustment> adjustments){
  dbutil.withDao(Adjustment.class,new DbUtil.Operation<Adjustment,String>(){
    @Override public String operate(    Dao dao) throws SQLException {
      for (      Adjustment adjustment : adjustments) {
        dao.create(adjustment);
        commoditySnapshotService.add(adjustment);
        if (adjustment.isPositive()) {
          stockService.increaseStockLevelFor(adjustment.getCommodity(),adjustment.getQuantity(),adjustment.getCreated());
        }
 else {
          stockService.reduceStockLevelFor(adjustment.getCommodity(),adjustment.getQuantity(),adjustment.getCreated());
        }
      }
      return null;
    }
  }
);
  categoryService.clearCache();
  alertsService.disableAllMonthlyStockCountAlerts();
  alertsService.updateLowStockAlerts();
}
Program: 146306
Project: 146306
Buggy source:
public void add(final Snapshotable snapshotable,boolean isReplace){
  List<CommoditySnapshotValue> commoditySnapshotValues=null;
  try {
    commoditySnapshotValues=snapshotable.getActivitiesValues();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  GenericDao<CommoditySnapshot> snapshotDao=new GenericDao<>(CommoditySnapshot.class,context);
  for (  CommoditySnapshotValue value : commoditySnapshotValues) {
    List<CommoditySnapshot> commoditySnapshots=getSnapshotsForCommodityPeriod(value);
    if (commoditySnapshots.isEmpty()) {
      createNewSnapshot(value,snapshotDao);
    }
 else {
      updateSnapshot(value,snapshotDao,commoditySnapshots,isReplace);
    }
  }
}

Fixed version (ground truth):
public void add(final Snapshotable snapshotable){
  List<CommoditySnapshotValue> commoditySnapshotValues=null;
  try {
    commoditySnapshotValues=snapshotable.getActivitiesValues();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  GenericDao<CommoditySnapshot> snapshotDao=new GenericDao<>(CommoditySnapshot.class,context);
  for (  CommoditySnapshotValue value : commoditySnapshotValues) {
    List<CommoditySnapshot> commoditySnapshots=getSnapshotsForCommodityPeriod(value);
    if (commoditySnapshots.isEmpty()) {
      createNewSnapshot(value,snapshotDao);
    }
 else {
      updateSnapshot(value,snapshotDao,commoditySnapshots);
    }
  }
}
Program: 146307
Project: 146307
Buggy source:
private void updateSnapshot(CommoditySnapshotValue commoditySnapshotValue,GenericDao<CommoditySnapshot> snapshotDao,List<CommoditySnapshot> commoditySnapshots,boolean isReplace){
  CommoditySnapshot commoditySnapshot=commoditySnapshots.get(0);
  if (isReplace) {
    commoditySnapshot.setValue(commoditySnapshotValue.getValue());
  }
 else {
    commoditySnapshot.incrementValue(commoditySnapshotValue.getValue());
  }
  commoditySnapshot.setSynced(false);
  snapshotDao.update(commoditySnapshot);
}

Fixed version (ground truth):
private void updateSnapshot(CommoditySnapshotValue commoditySnapshotValue,GenericDao<CommoditySnapshot> snapshotDao,List<CommoditySnapshot> commoditySnapshots){
  CommoditySnapshot commoditySnapshot=commoditySnapshots.get(0);
  commoditySnapshot.incrementValue(commoditySnapshotValue.getValue());
  commoditySnapshot.setSynced(false);
  snapshotDao.update(commoditySnapshot);
}
Program: 146308
Project: 146308
Buggy source:
private void saveDispensingItems(final List<DispensingItem> dispensingItems){
  GenericDao<DispensingItem> dao=new GenericDao<>(DispensingItem.class,context);
  dao.bulkOperation(new DbUtil.Operation<DispensingItem,Object>(){
    @Override public Object operate(    Dao<DispensingItem,String> dao) throws SQLException {
      for (      DispensingItem dispensingItem : dispensingItems) {
        dao.create(dispensingItem);
      }
      return null;
    }
  }
);
  for (  DispensingItem dispensingItem : dispensingItems) {
    commoditySnapshotService.add(adjustStockLevel(dispensingItem),true);
    commoditySnapshotService.add(dispensingItem);
  }
  commodityService.addMostDispensedCommoditiesCache(dispensingItems.get(0).getCommodity());
}

Fixed version (ground truth):
private void saveDispensingItems(final List<DispensingItem> dispensingItems){
  GenericDao<DispensingItem> dao=new GenericDao<>(DispensingItem.class,context);
  dao.bulkOperation(new DbUtil.Operation<DispensingItem,Object>(){
    @Override public Object operate(    Dao<DispensingItem,String> dao) throws SQLException {
      for (      DispensingItem dispensingItem : dispensingItems) {
        dao.create(dispensingItem);
      }
      return null;
    }
  }
);
  for (  DispensingItem dispensingItem : dispensingItems) {
    adjustStockLevel(dispensingItem);
    commoditySnapshotService.add(dispensingItem);
  }
  commodityService.addMostDispensedCommoditiesCache(dispensingItems.get(0).getCommodity());
}
Program: 146309
Project: 146309
Buggy source:
private StockItemSnapshot adjustStockLevel(DispensingItem dispensing){
  return stockService.reduceStockLevelFor(dispensing.getCommodity(),dispensing.getQuantity(),dispensing.created());
}

Fixed version (ground truth):
private void adjustStockLevel(DispensingItem dispensing){
  stockService.reduceStockLevelFor(dispensing.getCommodity(),dispensing.getQuantity(),dispensing.created());
}
Program: 146310
Project: 146310
Buggy source:
private void saveLossItems(List<LossItem> lossItems){
  GenericDao<LossItem> lossItemDao=new GenericDao<>(LossItem.class,context);
  for (  LossItem lossItem : lossItems) {
    lossItemDao.create(lossItem);
    saveLossItemDetails(lossItem.getLossItemDetails());
    snapshotService.add(adjustStockLevel(lossItem),true);
    snapshotService.add(lossItem);
  }
}

Fixed version (ground truth):
private void saveLossItems(List<LossItem> lossItems){
  GenericDao<LossItem> lossItemDao=new GenericDao<>(LossItem.class,context);
  for (  LossItem lossItem : lossItems) {
    lossItemDao.create(lossItem);
    saveLossItemDetails(lossItem.getLossItemDetails());
    adjustStockLevel(lossItem);
    snapshotService.add(lossItem);
  }
}
Program: 146311
Project: 146311
Buggy source:
private StockItemSnapshot adjustStockLevel(LossItem lossItem){
  return stockService.reduceStockLevelFor(lossItem.getCommodity(),lossItem.getTotalLosses(),lossItem.created());
}

Fixed version (ground truth):
private void adjustStockLevel(LossItem lossItem){
  stockService.reduceStockLevelFor(lossItem.getCommodity(),lossItem.getTotalLosses(),lossItem.created());
}
Program: 146312
Project: 146312
Buggy source:
private void saveReceiveItems(List<ReceiveItem> receiveItems){
  GenericDao<ReceiveItem> receiveItemDao=new GenericDao<>(ReceiveItem.class,context);
  for (  ReceiveItem receiveItem : receiveItems) {
    receiveItemDao.create(receiveItem);
    commoditySnapshotService.add(stockService.increaseStockLevelFor(receiveItem.getCommodity(),receiveItem.getQuantityReceived(),receiveItem.created()),true);
    commoditySnapshotService.add(receiveItem);
  }
  alertsService.updateLowStockAlerts();
}

Fixed version (ground truth):
private void saveReceiveItems(List<ReceiveItem> receiveItems){
  GenericDao<ReceiveItem> receiveItemDao=new GenericDao<>(ReceiveItem.class,context);
  for (  ReceiveItem receiveItem : receiveItems) {
    receiveItemDao.create(receiveItem);
    stockService.increaseStockLevelFor(receiveItem.getCommodity(),receiveItem.getQuantityReceived(),receiveItem.created());
    commoditySnapshotService.add(receiveItem);
  }
  alertsService.updateLowStockAlerts();
}
Program: 146313
Project: 146313
Buggy source:
@Override public Void operate(Dao<StockItem,String> dao) throws SQLException {
  dao.update(stockItem);
  return null;
}

Fixed version (ground truth):
@Override public Void operate(Dao<StockItem,String> dao) throws SQLException {
  dao.update(stockItem);
  stockItemSnapshotService.createOrUpdate(commodity,stockItem.getQuantity(),date);
  return null;
}
Program: 146314
Project: 146314
Buggy source:
public StockItemSnapshot increaseStockLevelFor(Commodity commodity,int quantity,Date date){
  StockItem stockItem=commodity.increaseStockOnHandBy(quantity);
  StockItemSnapshot siss=saveStockLevel(commodity,stockItem,date);
  categoryService.clearCache();
  return siss;
}

Fixed version (ground truth):
public void increaseStockLevelFor(Commodity commodity,int quantity,Date date){
  StockItem stockItem=commodity.increaseStockOnHandBy(quantity);
  saveStockLevel(commodity,stockItem,date);
  categoryService.clearCache();
}
Program: 146315
Project: 146315
Buggy source:
public StockItemSnapshot reduceStockLevelFor(final Commodity commodity,int quantity,Date date){
  StockItem stockItem=commodity.reduceStockOnHandBy(quantity);
  StockItemSnapshot siss=saveStockLevel(commodity,stockItem,date);
  categoryService.clearCache();
  return siss;
}

Fixed version (ground truth):
public void reduceStockLevelFor(final Commodity commodity,int quantity,Date date){
  StockItem stockItem=commodity.reduceStockOnHandBy(quantity);
  saveStockLevel(commodity,stockItem,date);
  categoryService.clearCache();
}
Program: 146316
Project: 146316
Buggy source:
private StockItemSnapshot saveStockLevel(final Commodity commodity,final StockItem stockItem,final Date date){
  dbUtil.withDao(context,StockItem.class,new DbUtil.Operation<StockItem,Void>(){
    @Override public Void operate(    Dao<StockItem,String> dao) throws SQLException {
      dao.update(stockItem);
      return null;
    }
  }
);
  return stockItemSnapshotService.createOrUpdate(commodity,stockItem.getQuantity(),date);
}

Fixed version (ground truth):
private void saveStockLevel(final Commodity commodity,final StockItem stockItem,final Date date){
  dbUtil.withDao(context,StockItem.class,new DbUtil.Operation<StockItem,Void>(){
    @Override public Void operate(    Dao<StockItem,String> dao) throws SQLException {
      dao.update(stockItem);
      stockItemSnapshotService.createOrUpdate(commodity,stockItem.getQuantity(),date);
      return null;
    }
  }
);
}
Program: 146317
Project: 146317
Buggy source:
@Override public void onPerformSync(Account account,Bundle extras,String authority,ContentProviderClient provider,SyncResult syncResult){
  User user=userService.getRegisteredUser();
  if (user == null) {
    return;
  }
  i("String_Node_Str",account.name);
  commoditySnapshotService.syncWithServer(user);
  i("String_Node_Str",account.name);
  allocationService.syncAllocations(user);
  i("String_Node_Str",account.name);
  commodityActionService.syncCommodityActionValues(user);
  i("String_Node_Str",account.name);
  commodityActionService.syncIndicatorValues(user,commodityService.all());
  SharedPreferences.Editor edit=sharedPreferences.edit();
  edit.putString("String_Node_Str",dateTimeFormater.format(new Date()));
  edit.commit();
  EventBus.getDefault().post(new SyncedEvent());
}

Fixed version (ground truth):
@Override public void onPerformSync(Account account,Bundle extras,String authority,ContentProviderClient provider,SyncResult syncResult){
  User user=userService.getRegisteredUser();
  if (user == null) {
    return;
  }
  i("String_Node_Str",account.name);
  commoditySnapshotService.syncWithServer(user);
  i("String_Node_Str",account.name);
  commoditySnapshotService.syncSOHWithServer(user);
  i("String_Node_Str",account.name);
  allocationService.syncAllocations(user);
  i("String_Node_Str",account.name);
  commodityActionService.syncCommodityActionValues(user);
  i("String_Node_Str",account.name);
  commodityActionService.syncIndicatorValues(user,commodityService.all());
  SharedPreferences.Editor edit=sharedPreferences.edit();
  edit.putString("String_Node_Str",dateTimeFormater.format(new Date()));
  edit.commit();
  EventBus.getDefault().post(new SyncedEvent());
}
Program: 146318
Project: 146318
Buggy source:
@Test public void shouldReturnReturnedToLGAUtilizationItemWithCorrectUtilizationValue() throws Exception {
  commodityService.initialise(new User("String_Node_Str","String_Node_Str"));
  categoryService.clearCache();
  Commodity commodity=categoryService.all().get(0).getCommodities().get(0);
  Calendar calendar=Calendar.getInstance();
  Date today=calendar.getTime();
  assertNotNull(commodity);
  adjust(commodity,2,false,AdjustmentReason.RETURNED_TO_LGA,adjustmentService);
  adjust(commodity,3,false,AdjustmentReason.RETURNED_TO_LGA,adjustmentService);
  List<UtilizationItem> utilizationItems=commodityService.getMonthlyUtilizationItems(commodity,today);
  int expectedValue=5;
  int utilizationValueIndex=DateUtil.dayNumber(today) - 1;
  assertThat(utilizationItems.get(5).getUtilizationValues().get(utilizationValueIndex).getValue(),is(expectedValue));
}

Fixed version (ground truth):
@Test public void shouldReturnReturnedToLGAUtilizationItemWithCorrectUtilizationValue() throws Exception {
  commodityService.initialise(new User("String_Node_Str","String_Node_Str"));
  categoryService.clearCache();
  Commodity commodity=categoryService.all().get(6).getCommodities().get(0);
  Calendar calendar=Calendar.getInstance();
  Date today=calendar.getTime();
  assertNotNull(commodity);
  adjust(commodity,2,false,AdjustmentReason.RETURNED_TO_LGA,adjustmentService);
  adjust(commodity,3,false,AdjustmentReason.RETURNED_TO_LGA,adjustmentService);
  List<UtilizationItem> utilizationItems=commodityService.getMonthlyUtilizationItems(commodity,today);
  int expectedValue=5;
  int utilizationValueIndex=DateUtil.dayNumber(today) - 1;
  assertThat(utilizationItems.get(5).getUtilizationValues().get(utilizationValueIndex).getValue(),is(expectedValue));
}
Program: 146319
Project: 146319
Buggy source:
@Test public void shouldUpdateSnapShotWhenLossItemIsSaved() throws Exception {
  Commodity commodity=commodityService.all().get(0);
  assertThat(snapshotGenericDao.queryForAll().size(),is(0));
  int stockOnHand=commodity.getStockOnHand();
  int expectedStockOnHand=stockOnHand - 1;
  Loss loss=new Loss();
  loss.addLossItem(new LossItem(commodity,1));
  lossService.saveLoss(loss);
  commodity=commodityService.all().get(0);
  assertThat(commodity.getStockOnHand(),is(expectedStockOnHand));
}

Fixed version (ground truth):
@Test public void shouldUpdateSnapShotWhenLossItemIsSaved() throws Exception {
  Commodity commodity=commodityService.all().get(0);
  assertThat(snapshotGenericDao.queryForAll().size(),is(0));
  int stockOnHand=commodity.getStockOnHand();
  int expectedStockOnHand=stockOnHand - 1;
  Loss loss=new Loss();
  loss.addLossItem(new LossItem(commodity,1));
  lossService.saveLoss(loss);
  commodity=commodityService.all().get(0);
  assertThat(commodity.getStockOnHand(),is(expectedStockOnHand));
  assertThat(snapshotGenericDao.queryForAll().size(),is(2));
}
Program: 146320
Project: 146320
Buggy source:
public boolean quantityIsUnexpected(){
  return (quantityEntered > (1.1 * getExpectedOrderQuantity()));
}

Fixed version (ground truth):
public boolean quantityIsUnexpected(){
  return (getExpectedOrderQuantity() != 0) && (quantityEntered > (1.1 * getExpectedOrderQuantity()));
}
Program: 146322
Project: 146322
Buggy source:
@Override protected AdapterView.OnItemClickListener getAutoCompleteTextViewCommoditiesAdapterListener(){
  return new AdapterView.OnItemClickListener(){
    @Override public void onItemClick(    AdapterView<?> parent,    View view,    int position,    long id){
      Commodity commodity=searchCommodityAdapter.getItem(position);
      onEvent(new CommodityToggledEvent(new OrderCommodityViewModel(commodity)));
      autoCompleteTextViewCommodities.setText("String_Node_Str");
    }
  }
;
}

Fixed version (ground truth):
@Override protected AdapterView.OnItemClickListener getAutoCompleteTextViewCommoditiesAdapterListener(){
  return new AdapterView.OnItemClickListener(){
    @Override public void onItemClick(    AdapterView<?> parent,    View view,    int position,    long id){
      Commodity commodity=searchCommodityAdapter.getItem(position);
      onEvent(new CommodityToggledEvent(setupOrderCommodityViewModel(commodity)));
      autoCompleteTextViewCommodities.setText("String_Node_Str");
    }
  }
;
}
Program: 146323
Project: 146323
Buggy source:
@Override public void onItemClick(AdapterView<?> parent,View view,int position,long id){
  Commodity commodity=searchCommodityAdapter.getItem(position);
  onEvent(new CommodityToggledEvent(new OrderCommodityViewModel(commodity)));
  autoCompleteTextViewCommodities.setText("String_Node_Str");
}

Fixed version (ground truth):
@Override public void onItemClick(AdapterView<?> parent,View view,int position,long id){
  Commodity commodity=searchCommodityAdapter.getItem(position);
  onEvent(new CommodityToggledEvent(setupOrderCommodityViewModel(commodity)));
  autoCompleteTextViewCommodities.setText("String_Node_Str");
}
Program: 146324
Project: 146324
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (getArguments() != null) {
    category=(Category)getArguments().getSerializable(CATEGORY);
    selectedCommodities=(ArrayList<? extends BaseCommodityViewModel>)getArguments().getSerializable(SELECTED_COMMODITIES);
    commodityDisplayStrategy=(CommodityDisplayStrategy)getArguments().getSerializable(COMMODITY_DISPLAY_STRATEGY);
    viewModelsConverter=(CommoditiesToViewModelsConverter)getArguments().getSerializable(COMMODITIES_TO_VIEW_MODELS_CONVERTER);
    activityName=(String)getArguments().getSerializable(ACTIVITY_NAME);
  }
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (getArguments() != null) {
    category=(Category)getArguments().getSerializable(CATEGORY);
    selectedCommodities=(ArrayList<? extends BaseCommodityViewModel>)getArguments().getSerializable(SELECTED_COMMODITIES);
    activityName=(String)getArguments().getSerializable(ACTIVITY_NAME);
  }
}
Program: 146325
Project: 146325
Buggy source:
public static ItemSelectFragment newInstance(CommoditySelectableActivity parent,Category category,ArrayList<?> selectedCommodities,CommodityDisplayStrategy commodityDisplayStrategy,CommoditiesToViewModelsConverter generator,String activityName){
  Bundle arguments=new Bundle();
  arguments.putSerializable(CATEGORY,category);
  arguments.putSerializable(SELECTED_COMMODITIES,selectedCommodities);
  arguments.putSerializable(COMMODITY_DISPLAY_STRATEGY,commodityDisplayStrategy);
  arguments.putSerializable(COMMODITIES_TO_VIEW_MODELS_CONVERTER,generator);
  arguments.putSerializable(ACTIVITY_NAME,activityName);
  ItemSelectFragment fragment=new ItemSelectFragment();
  fragment.setArguments(arguments);
  fragment.parentActivity=parent;
  return fragment;
}

Fixed version (ground truth):
public static ItemSelectFragment newInstance(CommoditySelectableActivity parent,Category category,ArrayList<?> selectedCommodities,CommodityDisplayStrategy commodityDisplayStrategy,CommoditiesToViewModelsConverter generator,String activityName){
  Bundle arguments=new Bundle();
  arguments.putSerializable(CATEGORY,category);
  arguments.putSerializable(SELECTED_COMMODITIES,selectedCommodities);
  arguments.putSerializable(ACTIVITY_NAME,activityName);
  ItemSelectFragment fragment=new ItemSelectFragment();
  fragment.setArguments(arguments);
  fragment.parentActivity=parent;
  fragment.commodityDisplayStrategy=commodityDisplayStrategy;
  fragment.viewModelsConverter=generator;
  return fragment;
}
Program: 146326
Project: 146326
Buggy source:
@Override protected void onPostExecute(Boolean succeeded){
  if (dialog.isShowing() && dialog.getOwnerActivity() != null && !dialog.getOwnerActivity().isFinishing()) {
    dialog.dismiss();
  }
  if (succeeded) {
    startActivity(new Intent(getApplicationContext(),HomeActivity.class));
    finish();
  }
  String toastMessage=succeeded ? registrationSuccessfulMessage : failureCause.getMessage();
  Toast.makeText(getApplicationContext(),toastMessage,LENGTH_SHORT).show();
  Log.e("String_Node_Str",toastMessage + "String_Node_Str");
}

Fixed version (ground truth):
@Override protected void onPostExecute(Boolean succeeded){
  if (dialog.isShowing()) {
    dialog.dismiss();
  }
  if (succeeded) {
    startActivity(new Intent(getApplicationContext(),HomeActivity.class));
    finish();
  }
  String toastMessage=succeeded ? registrationSuccessfulMessage : failureCause.getMessage();
  Toast.makeText(getApplicationContext(),toastMessage,LENGTH_SHORT).show();
  Log.e("String_Node_Str",toastMessage + "String_Node_Str");
}
Program: 146327
Project: 146327
Buggy source:
private int average(List<CommodityActionValue> commodityActionValues,int maxNumberOfValues){
  int value=0;
  for (  CommodityActionValue commodityActionValue : commodityActionValues) {
    value+=Integer.parseInt(commodityActionValue.getValue());
  }
  return value / maxNumberOfValues;
}

Fixed version (ground truth):
private int average(List<CommodityActionValue> commodityActionValues,int maxNumberOfValues){
  float value=0;
  for (  CommodityActionValue commodityActionValue : commodityActionValues) {
    value+=Float.parseFloat(commodityActionValue.getValue());
  }
  return (int)value / maxNumberOfValues;
}
Program: 146328
Project: 146328
Buggy source:
@Override public View getView(int position,View convertView,ViewGroup parent){
  LayoutInflater inflater=(LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  View view=inflater.inflate(resource,parent,false);
  Map<Integer,String> integerStringMap=new HashMap<>();
  FacilityConsumptionReportRH2Item item=getItem(position);
  integerStringMap.put(R.id.textViewCommodityName,item.getCommodityName());
  integerStringMap.put(R.id.textViewOpeningBalance,String.valueOf(item.getOpeningStock()));
  integerStringMap.put(R.id.textViewQuantityReceived,String.valueOf(item.getCommoditiesReceived()));
  integerStringMap.put(R.id.textViewQuantityAdjusted,String.valueOf(item.getCommoditiesAdjusted()));
  integerStringMap.put(R.id.textViewQuantityDispensed,String.valueOf(item.getCommoditiesDispensedToFacilities()));
  integerStringMap.put(R.id.textViewTotalDispensed,String.valueOf(item.totalDispensed()));
  integerStringMap.put(R.id.textViewQuantityLost,String.valueOf(item.getCommoditiesLost()));
  integerStringMap.put(R.id.textViewClosingStock,String.valueOf(item.getClosingStock()));
  for (  Integer key : integerStringMap.keySet()) {
    TextView textView=(TextView)view.findViewById(key);
    textView.setText(integerStringMap.get(key));
  }
  if (isGrey) {
    view.setBackgroundColor(getContext().getResources().getColor(R.color.m_grey));
  }
  isGrey=!isGrey;
  return view;
}

Fixed version (ground truth):
@Override public View getView(int position,View convertView,ViewGroup parent){
  LayoutInflater inflater=(LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  View view=inflater.inflate(resource,parent,false);
  Map<Integer,String> integerStringMap=new HashMap<>();
  FacilityConsumptionReportRH2Item item=getItem(position);
  integerStringMap.put(R.id.textViewCommodityName,item.getCommodityName());
  integerStringMap.put(R.id.textViewOpeningBalance,String.valueOf(item.getOpeningStock()));
  integerStringMap.put(R.id.textViewQuantityReceived,String.valueOf(item.getCommoditiesReceived()));
  integerStringMap.put(R.id.textViewQuantityAdjusted,String.valueOf(item.getCommoditiesAdjusted()));
  integerStringMap.put(R.id.textViewQuantityDispensed,String.valueOf(item.getCommoditiesDispensedToClients()));
  integerStringMap.put(R.id.textViewTotalDispensed,String.valueOf(item.totalDispensed()));
  integerStringMap.put(R.id.textViewQuantityLost,String.valueOf(item.getCommoditiesLost()));
  integerStringMap.put(R.id.textViewClosingStock,String.valueOf(item.getClosingStock()));
  for (  Integer key : integerStringMap.keySet()) {
    TextView textView=(TextView)view.findViewById(key);
    textView.setText(integerStringMap.get(key));
  }
  if (isGrey) {
    view.setBackgroundColor(getContext().getResources().getColor(R.color.m_grey));
  }
  isGrey=!isGrey;
  return view;
}
Program: 146330
Project: 146330
Buggy source:
public static <T>Dao<T,String> initialiseDao(SQLiteOpenHelper openHelper,Class<T> domainClass) throws SQLException {
  ConnectionSource connectionSource=new AndroidConnectionSource(openHelper);
  return createDao(connectionSource,domainClass);
}

Fixed version (ground truth):
public static <T>Dao<T,String> initialiseDao(SQLiteOpenHelper openHelper,Class<T> domainClass) throws SQLException {
  ConnectionSource connectionSource;
  if (openHelper instanceof LmisSqliteOpenHelper) {
    LmisSqliteOpenHelper helper=(LmisSqliteOpenHelper)openHelper;
    connectionSource=helper.getConnectionSource();
  }
 else {
    connectionSource=new AndroidConnectionSource(openHelper);
  }
  return createDao(connectionSource,domainClass);
}
Program: 146332
Project: 146332
Buggy source:
@Override protected void onPostExecute(Boolean succeeded){
  if (dialog.isShowing()) {
    dialog.dismiss();
  }
  if (succeeded) {
    startActivity(new Intent(getApplicationContext(),HomeActivity.class));
    finish();
  }
  String toastMessage=succeeded ? registrationSuccessfulMessage : failureCause.getMessage();
  Toast.makeText(getApplicationContext(),toastMessage,LENGTH_SHORT).show();
  Log.e("String_Node_Str",toastMessage + "String_Node_Str");
}

Fixed version (ground truth):
@Override protected void onPostExecute(Boolean succeeded){
  if (dialog.isShowing() && dialog.getOwnerActivity() != null && !dialog.getOwnerActivity().isFinishing()) {
    dialog.dismiss();
  }
  if (succeeded) {
    startActivity(new Intent(getApplicationContext(),HomeActivity.class));
    finish();
  }
  String toastMessage=succeeded ? registrationSuccessfulMessage : failureCause.getMessage();
  Toast.makeText(getApplicationContext(),toastMessage,LENGTH_SHORT).show();
  Log.e("String_Node_Str",toastMessage + "String_Node_Str");
}
Program: 146333
Project: 146333
Buggy source:
private Allocation toAllocation(Collection<CommodityActionValue> commodityActionValues){
  Collection<CommodityActionValue> filteredForAllocationId=filter(commodityActionValues,new Predicate<CommodityActionValue>(){
    @Override public boolean apply(    CommodityActionValue commodityActionValue){
      return DataElementType.ALLOCATION_ID.getActivity().equals(commodityActionValue.getCommodityAction().getName());
    }
  }
);
  CommodityActionValue allocationIdValue=newArrayList(filteredForAllocationId).get(0);
  Allocation allocation=new Allocation(allocationIdValue.getValue(),allocationIdValue.getPeriod());
  ArrayList<CommodityActionValue> allocationActionValues=newArrayList(commodityActionValues);
  allocationActionValues.remove(allocationIdValue);
  List<AllocationItem> allocationItems=transform(allocationActionValues,new Function<CommodityActionValue,AllocationItem>(){
    @Override public AllocationItem apply(    CommodityActionValue input){
      AllocationItem allocationItem=new AllocationItem();
      try {
        allocationItem.setQuantity(parseInt(input.getValue()));
      }
 catch (      NumberFormatException e) {
        throw new LmisException("String_Node_Str" + input.getCommodityAction().getActivityType() + "String_Node_Str"+ input.getValue(),e);
      }
      allocationItem.setCommodity(input.getCommodityAction().getCommodity());
      return allocationItem;
    }
  }
);
  allocation.addTransientItems(allocationItems);
  return allocation;
}

Fixed version (ground truth):
private Allocation toAllocation(Collection<CommodityActionValue> commodityActionValues){
  Collection<CommodityActionValue> filteredForAllocationId=filter(commodityActionValues,new Predicate<CommodityActionValue>(){
    @Override public boolean apply(    CommodityActionValue commodityActionValue){
      return DataElementType.ALLOCATION_ID.getActivity().equals(commodityActionValue.getCommodityAction().getName());
    }
  }
);
  if (filteredForAllocationId == null || filteredForAllocationId.size() == 0) {
    return null;
  }
  CommodityActionValue allocationIdValue=newArrayList(filteredForAllocationId).get(0);
  Allocation allocation=new Allocation(allocationIdValue.getValue(),allocationIdValue.getPeriod());
  ArrayList<CommodityActionValue> allocationActionValues=newArrayList(commodityActionValues);
  allocationActionValues.remove(allocationIdValue);
  List<AllocationItem> allocationItems=transform(allocationActionValues,new Function<CommodityActionValue,AllocationItem>(){
    @Override public AllocationItem apply(    CommodityActionValue input){
      AllocationItem allocationItem=new AllocationItem();
      try {
        allocationItem.setQuantity(parseInt(input.getValue()));
      }
 catch (      NumberFormatException e) {
        throw new LmisException("String_Node_Str" + input.getCommodityAction().getActivityType() + "String_Node_Str"+ input.getValue(),e);
      }
      allocationItem.setCommodity(input.getCommodityAction().getCommodity());
      return allocationItem;
    }
  }
);
  allocation.addTransientItems(allocationItems);
  return allocation;
}
Program: 146335
Project: 146335
Buggy source:
protected void setupEndMonthSpinner(){
  if (getStartingYear().compareTo(getEndingYear()) < 0) {
    return;
  }
  int selectedIndex=spinnerStartingMonth.getSelectedItemPosition();
  ArrayAdapter<String> endMonthAdapter=new ArrayAdapter<>(getApplicationContext(),R.layout.spinner_item_black,getMonths(selectedIndex,endingYearIsCurrent() ? DateUtil.monthNumber() + 1 : 12));
  spinnerEndingMonth.setAdapter(endMonthAdapter);
}

Fixed version (ground truth):
protected void setupEndMonthSpinner(){
  if (getStartingYear().compareTo(getEndingYear()) < 0) {
    return;
  }
  int selectedIndex=spinnerStartingMonth.getSelectedItemPosition();
  ArrayAdapter<String> endMonthAdapter=new ArrayAdapter<>(getApplicationContext(),R.layout.spinner_item_large,getMonths(selectedIndex,endingYearIsCurrent() ? DateUtil.monthNumber() + 1 : 12));
  spinnerEndingMonth.setAdapter(endMonthAdapter);
}
Program: 146336
Project: 146336
Buggy source:
protected void setupStartingMonthSpinner(){
  if (startingYearIsCurrent()) {
    ArrayAdapter<String> startMonthAdapter=new ArrayAdapter<>(getApplicationContext(),R.layout.spinner_item_black,getMonths(0,DateUtil.monthNumber() + 1));
    spinnerStartingMonth.setAdapter(startMonthAdapter);
  }
 else {
    ArrayAdapter<String> startMonthAdapter=new ArrayAdapter<>(getApplicationContext(),R.layout.spinner_item_black,getMonths());
    spinnerStartingMonth.setAdapter(startMonthAdapter);
  }
}

Fixed version (ground truth):
protected void setupStartingMonthSpinner(){
  if (startingYearIsCurrent()) {
    ArrayAdapter<String> startMonthAdapter=new ArrayAdapter<>(getApplicationContext(),R.layout.spinner_item_large,getMonths(0,DateUtil.monthNumber() + 1));
    spinnerStartingMonth.setAdapter(startMonthAdapter);
  }
 else {
    ArrayAdapter<String> startMonthAdapter=new ArrayAdapter<>(getApplicationContext(),R.layout.spinner_item_large,getMonths());
    spinnerStartingMonth.setAdapter(startMonthAdapter);
  }
}
Program: 146337
Project: 146337
Buggy source:
private void setupSpinners(){
  ArrayAdapter<String> yearsAdapter=new ArrayAdapter<>(getApplicationContext(),R.layout.spinner_item_black,getLastNYears(NUMBER_OF_YEARS));
  spinnerStartingYear.setAdapter(yearsAdapter);
  spinnerStartingYear.setSelection(0);
  setupEndYearSpinner();
  ArrayAdapter<String> startMonthAdapter=new ArrayAdapter<>(getApplicationContext(),R.layout.spinner_item_black,getMonths());
  spinnerStartingMonth.setAdapter(startMonthAdapter);
  spinnerStartingMonth.setSelection(0);
  setupEndMonthSpinner();
  setupListeners();
  getStrategy().applyVisibilityStrategy(spinnerStartingMonth,spinnerEndingMonth,spinnerStartingYear,spinnerEndingYear,textViewEndingMonth,textViewEndingYear);
}

Fixed version (ground truth):
private void setupSpinners(){
  ArrayAdapter<String> yearsAdapter=new ArrayAdapter<>(getApplicationContext(),R.layout.spinner_item_large,getLastNYears(NUMBER_OF_YEARS));
  spinnerStartingYear.setAdapter(yearsAdapter);
  spinnerStartingYear.setSelection(0);
  setupEndYearSpinner();
  ArrayAdapter<String> startMonthAdapter=new ArrayAdapter<>(getApplicationContext(),R.layout.spinner_item_large,getMonths());
  spinnerStartingMonth.setAdapter(startMonthAdapter);
  spinnerStartingMonth.setSelection(0);
  setupEndMonthSpinner();
  setupListeners();
  getStrategy().applyVisibilityStrategy(spinnerStartingMonth,spinnerEndingMonth,spinnerStartingYear,spinnerEndingYear,textViewEndingMonth,textViewEndingYear);
}
Program: 146338
Project: 146338
Buggy source:
protected void setupEndYearSpinner(){
  int selectedIndex=spinnerStartingYear.getSelectedItemPosition();
  ArrayAdapter<String> endYearAdapter=new ArrayAdapter<>(getApplicationContext(),R.layout.spinner_item_black,getLastNYears(NUMBER_OF_YEARS).subList(0,selectedIndex + 1));
  spinnerEndingYear.setAdapter(endYearAdapter);
}

Fixed version (ground truth):
protected void setupEndYearSpinner(){
  int selectedIndex=spinnerStartingYear.getSelectedItemPosition();
  ArrayAdapter<String> endYearAdapter=new ArrayAdapter<>(getApplicationContext(),R.layout.spinner_item_large,getLastNYears(NUMBER_OF_YEARS).subList(0,selectedIndex + 1));
  spinnerEndingYear.setAdapter(endYearAdapter);
}
Program: 146339
Project: 146339
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setupActionBar();
  category=(Category)getIntent().getSerializableExtra(ReportsActivity.CATEGORY_BUNDLE_KEY);
  reportType=(ReportType)getIntent().getSerializableExtra(ReportsActivity.REPORT_TYPE_BUNDLE_KEY);
  setContentView(R.layout.activity_monthly_vaccine_utilization_report);
  textViewReportName.setText(reportType.getName());
  ArrayAdapter<String> yearsAdapter=new ArrayAdapter<>(getApplicationContext(),R.layout.spinner_item_black,getLastNYears(NUMBER_OF_YEARS));
  spinnerYear.setAdapter(yearsAdapter);
  setupMonthSpinner();
  setupListeners();
  buttonLoadReport.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View view){
      textViewReloadReport.setVisibility(View.GONE);
      scrollViewReportItems.setVisibility(View.VISIBLE);
      setItems();
    }
  }
);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setupActionBar();
  category=(Category)getIntent().getSerializableExtra(ReportsActivity.CATEGORY_BUNDLE_KEY);
  reportType=(ReportType)getIntent().getSerializableExtra(ReportsActivity.REPORT_TYPE_BUNDLE_KEY);
  setContentView(R.layout.activity_monthly_vaccine_utilization_report);
  textViewReportName.setText(reportType.getName());
  ArrayAdapter<String> yearsAdapter=new ArrayAdapter<>(getApplicationContext(),R.layout.spinner_item_large,getLastNYears(NUMBER_OF_YEARS));
  spinnerYear.setAdapter(yearsAdapter);
  setupMonthSpinner();
  setupListeners();
  buttonLoadReport.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View view){
      textViewReloadReport.setVisibility(View.GONE);
      scrollViewReportItems.setVisibility(View.VISIBLE);
      setItems();
    }
  }
);
}
Program: 146340
Project: 146340
Buggy source:
private void setupMonthSpinner(){
  ArrayAdapter<String> startMonthAdapter=new ArrayAdapter<>(getApplicationContext(),R.layout.spinner_item_black,getMonths(0,yearIsCurrent() ? DateUtil.monthNumber() + 1 : 12));
  spinnerMonth.setAdapter(startMonthAdapter);
  if (yearIsCurrent()) {
    Calendar calendar=Calendar.getInstance();
    spinnerMonth.setSelection(calendar.get(Calendar.MONTH));
  }
}

Fixed version (ground truth):
private void setupMonthSpinner(){
  ArrayAdapter<String> startMonthAdapter=new ArrayAdapter<>(getApplicationContext(),R.layout.spinner_item_large,getMonths(0,yearIsCurrent() ? DateUtil.monthNumber() + 1 : 12));
  spinnerMonth.setAdapter(startMonthAdapter);
  if (yearIsCurrent()) {
    Calendar calendar=Calendar.getInstance();
    spinnerMonth.setSelection(calendar.get(Calendar.MONTH));
  }
}
Program: 146341
Project: 146341
Buggy source:
public void saveReceive(Receive receive){
  try {
    GenericDao<Receive> receiveDao=new GenericDao<>(Receive.class,context);
    receiveDao.create(receive);
    saveReceiveItems(receive.getReceiveItems());
    if (receive.getAllocation() != null) {
      Allocation allocation=receive.getAllocation();
      allocation.setReceived(true);
      if (!allocation.isDummy()) {
        allocationService.update(allocation);
        alertsService.deleteAllocationAlert(allocation);
      }
 else {
        allocationService.createAllocation(allocation);
        EventBus.getDefault().post(new AllocationCreateEvent(receive.getAllocation()));
      }
    }
  }
 catch (  Exception e) {
    Log.e("String_Node_Str",e.getMessage());
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public void saveReceive(final Receive receive) throws Exception {
  TransactionManager.callInTransaction(LmisSqliteOpenHelper.getInstance(context).getConnectionSource(),new Callable<Object>(){
    @Override public Object call() throws Exception {
      GenericDao<Receive> receiveDao=new GenericDao<>(Receive.class,context);
      receiveDao.create(receive);
      saveReceiveItems(receive.getReceiveItems());
      if (receive.getAllocation() != null) {
        Allocation allocation=receive.getAllocation();
        allocation.setReceived(true);
        if (!allocation.isDummy()) {
          allocationService.update(allocation);
          alertsService.deleteAllocationAlert(allocation);
        }
 else {
          allocationService.createAllocation(allocation);
          EventBus.getDefault().post(new AllocationCreateEvent(receive.getAllocation()));
        }
      }
      return null;
    }
  }
);
}
Program: 146342
Project: 146342
Buggy source:
@Override public User operate(Dao<User,String> dao) throws SQLException {
  List<User> users=dao.queryForAll();
  return users.get(0);
}

Fixed version (ground truth):
@Override public User operate(Dao<User,String> dao) throws SQLException {
  List<User> users=dao.queryForAll();
  if (users != null && users.size() > 0) {
    return users.get(0);
  }
  return null;
}
Program: 146343
Project: 146343
Buggy source:
public User getRegisteredUser() throws IndexOutOfBoundsException {
  return dbUtil.withDao(context,User.class,new Operation<User,User>(){
    @Override public User operate(    Dao<User,String> dao) throws SQLException {
      List<User> users=dao.queryForAll();
      return users.get(0);
    }
  }
);
}

Fixed version (ground truth):
public User getRegisteredUser() throws IndexOutOfBoundsException {
  return dbUtil.withDao(context,User.class,new Operation<User,User>(){
    @Override public User operate(    Dao<User,String> dao) throws SQLException {
      List<User> users=dao.queryForAll();
      if (users != null && users.size() > 0) {
        return users.get(0);
      }
      return null;
    }
  }
);
}
Program: 146344
Project: 146344
Buggy source:
@Override public void onPerformSync(Account account,Bundle extras,String authority,ContentProviderClient provider,SyncResult syncResult){
  User user=userService.getRegisteredUser();
  i("String_Node_Str",account.name);
  commoditySnapshotService.syncWithServer(user);
  i("String_Node_Str",account.name);
  allocationService.syncAllocations(user);
  i("String_Node_Str",account.name);
  commodityActionService.syncCommodityActionValues(user);
  i("String_Node_Str",account.name);
  commodityActionService.syncIndicatorValues(user,commodityService.all());
}

Fixed version (ground truth):
@Override public void onPerformSync(Account account,Bundle extras,String authority,ContentProviderClient provider,SyncResult syncResult){
  User user=userService.getRegisteredUser();
  if (user == null) {
    return;
  }
  i("String_Node_Str",account.name);
  commoditySnapshotService.syncWithServer(user);
  i("String_Node_Str",account.name);
  allocationService.syncAllocations(user);
  i("String_Node_Str",account.name);
  commodityActionService.syncCommodityActionValues(user);
  i("String_Node_Str",account.name);
  commodityActionService.syncIndicatorValues(user,commodityService.all());
}
Program: 146345
Project: 146345
Buggy source:
public RelativeLayout getView(Context applicationContext,int biggestValue,int height){
  int barWidth=Math.round(applicationContext.getResources().getDimension(R.dimen.bar_width));
  int barLegendHeight=70;
  int barHeight=height - barLegendHeight - 50;
  heightForMinThreshold=getHeightForMinThreshold(barHeight,biggestValue);
  heightForMaxThreshold=getHeightForMaxThreshold(barHeight,biggestValue);
  RelativeLayout relativeLayout=getRelativeLayout(applicationContext);
  relativeLayout.addView(getSOHTextView(applicationContext,barWidth));
  relativeLayout.addView(getTextViewForCommodityName(applicationContext,barWidth,barLegendHeight));
  relativeLayout.addView(getColorViewHolder(applicationContext,biggestValue,barWidth,barHeight));
  if (heightForMaxThreshold > heightForMinThreshold) {
    ImageView imageViewSpaceBorderLeft=getImageViewForSpace(applicationContext,barWidth);
    relativeLayout.addView(imageViewSpaceBorderLeft);
    relativeLayout.addView(getMaxTextView(applicationContext,barWidth));
  }
  return relativeLayout;
}

Fixed version (ground truth):
public RelativeLayout getView(Context applicationContext,int biggestValue,int height){
  int barWidth=Math.round(applicationContext.getResources().getDimension(R.dimen.bar_width));
  int barLegendHeight=70;
  int barHeight=height - barLegendHeight - 50;
  heightForMinThreshold=getHeightForMinThreshold(barHeight,biggestValue);
  heightForMaxThreshold=getHeightForMaxThreshold(barHeight,biggestValue);
  RelativeLayout relativeLayout=getRelativeLayout(applicationContext);
  relativeLayout.addView(getSOHTextView(applicationContext,barWidth));
  relativeLayout.addView(getTextViewForCommodityName(applicationContext,barWidth,barLegendHeight));
  relativeLayout.addView(getColorViewHolder(applicationContext,biggestValue,barWidth,barHeight));
  if (heightForMaxThreshold > heightForMinThreshold) {
    ImageView imageViewSpaceBorderLeft=getImageViewForSpace(applicationContext,barWidth);
    relativeLayout.addView(imageViewSpaceBorderLeft);
    relativeLayout.addView(getMaxTextView(applicationContext,barWidth));
    if (actualStockOnHand < minimumThreshold) {
      relativeLayout.addView(getMinimumOrdersTextView(applicationContext,barWidth,minimumThreshold - actualStockOnHand));
    }
  }
  return relativeLayout;
}
Program: 146346
Project: 146346
Buggy source:
@Override public View getView(int position,View convertView,ViewGroup parent){
  LayoutInflater inflater=(LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  View view=inflater.inflate(resource,parent,false);
  Map<Integer,String> integerStringMap=new HashMap<>();
  FacilityConsumptionReportRH2Item item=getItem(position);
  integerStringMap.put(R.id.textViewCommodityName,item.getCommodityName());
  integerStringMap.put(R.id.textViewOpeningBalance,String.valueOf(item.getOpeningStock()));
  integerStringMap.put(R.id.textViewQuantityReceived,String.valueOf(item.getCommoditiesReceived()));
  integerStringMap.put(R.id.textViewQuantityAdjusted,String.valueOf(item.getCommoditiesAdjusted()));
  integerStringMap.put(R.id.textViewQuantityDispensedToFacilities,String.valueOf(item.getCommoditiesDispensedToFacilities()));
  integerStringMap.put(R.id.textViewTotalDispensed,String.valueOf(item.totalDispensed()));
  integerStringMap.put(R.id.textViewQuantityLost,String.valueOf(item.getCommoditiesLost()));
  integerStringMap.put(R.id.textViewClosingStock,String.valueOf(item.getClosingStock()));
  for (  Integer key : integerStringMap.keySet()) {
    TextView textView=(TextView)view.findViewById(key);
    textView.setText(integerStringMap.get(key));
  }
  if (isGrey) {
    view.setBackgroundColor(getContext().getResources().getColor(R.color.m_grey));
  }
  isGrey=!isGrey;
  return view;
}

Fixed version (ground truth):
@Override public View getView(int position,View convertView,ViewGroup parent){
  LayoutInflater inflater=(LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  View view=inflater.inflate(resource,parent,false);
  Map<Integer,String> integerStringMap=new HashMap<>();
  FacilityConsumptionReportRH2Item item=getItem(position);
  integerStringMap.put(R.id.textViewCommodityName,item.getCommodityName());
  integerStringMap.put(R.id.textViewOpeningBalance,String.valueOf(item.getOpeningStock()));
  integerStringMap.put(R.id.textViewQuantityReceived,String.valueOf(item.getCommoditiesReceived()));
  integerStringMap.put(R.id.textViewQuantityAdjusted,String.valueOf(item.getCommoditiesAdjusted()));
  integerStringMap.put(R.id.textViewQuantityDispensed,String.valueOf(item.getCommoditiesDispensedToFacilities()));
  integerStringMap.put(R.id.textViewTotalDispensed,String.valueOf(item.totalDispensed()));
  integerStringMap.put(R.id.textViewQuantityLost,String.valueOf(item.getCommoditiesLost()));
  integerStringMap.put(R.id.textViewClosingStock,String.valueOf(item.getClosingStock()));
  for (  Integer key : integerStringMap.keySet()) {
    TextView textView=(TextView)view.findViewById(key);
    textView.setText(integerStringMap.get(key));
  }
  if (isGrey) {
    view.setBackgroundColor(getContext().getResources().getColor(R.color.m_grey));
  }
  isGrey=!isGrey;
  return view;
}
Program: 146347
Project: 146347
Buggy source:
public static LmisSqliteOpenHelper getInstance(Context context){
  if (_helperInstance == null)   _helperInstance=new LmisSqliteOpenHelper(context);
  return _helperInstance;
}

Fixed version (ground truth):
public static LmisSqliteOpenHelper getInstance(Context context){
  if (_helperInstance == null)   syncInit(context);
  return _helperInstance;
}
Program: 146348
Project: 146348
Buggy source:
public List<Category> all(){
  if (allCategories == null) {
    allCategories=dbUtil.withDao(context,Category.class,new DbUtil.Operation<Category,List<Category>>(){
      @Override public List<Category> operate(      Dao<Category,String> dao) throws SQLException {
        return dao.queryForAll();
      }
    }
);
  }
  return allCategories;
}

Fixed version (ground truth):
public List<Category> all(){
  if (allCategories == null || allCategories.size() == 0) {
    allCategories=dbUtil.withDao(context,Category.class,new DbUtil.Operation<Category,List<Category>>(){
      @Override public List<Category> operate(      Dao<Category,String> dao) throws SQLException {
        return dao.queryForAll();
      }
    }
);
  }
  return allCategories;
}
Program: 146349
Project: 146349
Buggy source:
public List<DataSet> all(){
  if (allDataSets == null) {
    allDataSets=dbUtil.withDao(DataSet.class,new DbUtil.Operation<DataSet,List<DataSet>>(){
      @Override public List<DataSet> operate(      Dao<DataSet,String> dao) throws SQLException {
        return dao.queryForAll();
      }
    }
);
  }
  return allDataSets;
}

Fixed version (ground truth):
public List<DataSet> all(){
  if (allDataSets == null || allDataSets.size() == 0) {
    allDataSets=dbUtil.withDao(DataSet.class,new DbUtil.Operation<DataSet,List<DataSet>>(){
      @Override public List<DataSet> operate(      Dao<DataSet,String> dao) throws SQLException {
        return dao.queryForAll();
      }
    }
);
  }
  return allDataSets;
}