nus-yam/ex-repair huggingface dataset:
Program: 157449
Project: 157449
Buggy source:
@Override public void restoreEntity(BackupDataInputStream data){
  final String key=data.getKey();
  if (!TextUtils.isEmpty(key)) {
    if (key.equalsIgnoreCase(getApplicationContext().getString(R.string.settings_key_default_split_state)))     return;
    if (key.equalsIgnoreCase("String_Node_Str"))     return;
    if (key.equalsIgnoreCase("String_Node_Str"))     return;
    if (key.equalsIgnoreCase(getApplicationContext().getString(R.string.settings_key_portrait_fullscreen)))     return;
    if (key.equalsIgnoreCase(getApplicationContext().getString(R.string.settings_key_landscape_fullscreen)))     return;
    if (key.equalsIgnoreCase(getApplicationContext().getString(R.string.settings_key_workaround_disable_rtl_fix)))     return;
  }
  super.restoreEntity(data);
}

Fixed version (ground truth):
@Override public void restoreEntity(BackupDataInputStream data){
  final String key=data.getKey();
  if (!TextUtils.isEmpty(key)) {
    if (key.equalsIgnoreCase(getApplicationContext().getString(R.string.settings_key_default_split_state)))     return;
    if (key.equalsIgnoreCase("String_Node_Str"))     return;
    if (key.equalsIgnoreCase("String_Node_Str"))     return;
    if (key.equalsIgnoreCase(getApplicationContext().getString(R.string.settings_key_portrait_fullscreen)))     return;
    if (key.equalsIgnoreCase(getApplicationContext().getString(R.string.settings_key_landscape_fullscreen)))     return;
    if (key.equalsIgnoreCase(getApplicationContext().getString(R.string.settings_key_workaround_disable_rtl_fix)))     return;
    if (key.equalsIgnoreCase(getApplicationContext().getString(R.string.settings_key_allow_suggestions_restart)))     return;
  }
  super.restoreEntity(data);
}
Program: 157450
Project: 157450
Buggy source:
@Override public boolean onTouchEvent(MotionEvent ev){
  try {
    mScaleGestureDetector.onTouchEvent(ev);
  }
 catch (  IllegalArgumentException e) {
  }
catch (  ArrayIndexOutOfBoundsException e) {
  }
  return super.onTouchEvent(ev);
}

Fixed version (ground truth):
@Override public boolean onTouchEvent(MotionEvent ev){
switch (MotionEventCompat.getActionMasked(ev)) {
case MotionEvent.ACTION_DOWN:
    if (ev.getPointerCount() == 1)     mSingleFingerEventPointerId=ev.getPointerId(0);
  break;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
if (ev.getPointerCount() == 1) mSingleFingerEventPointerId=NOT_A_POINTER_ID;
}
try {
mScaleGestureDetector.onTouchEvent(ev);
}
 catch (IllegalArgumentException e) {
}
catch (ArrayIndexOutOfBoundsException e) {
}
if (ev.getPointerCount() == 1 && ev.getPointerId(0) == mSingleFingerEventPointerId) return super.onTouchEvent(ev);
 else return false;
}
Program: 157451
Project: 157451
Buggy source:
@Override public void onViewCreated(View view,Bundle savedInstanceState){
  super.onViewCreated(view,savedInstanceState);
  Log.d(TAG,"String_Node_Str" + (savedInstanceState != null));
}

Fixed version (ground truth):
@Override public void onViewCreated(View view,Bundle savedInstanceState){
  super.onViewCreated(view,savedInstanceState);
  if (savedInstanceState == null) {
    FragmentManager fragmentManager=getChildFragmentManager();
    fragmentManager.beginTransaction().replace(R.id.change_log_fragment,new ChangeLogFragment.CardedChangeLogFragment()).replace(R.id.tip_fragment,new TipsFragment.RandomTipFragment()).commit();
  }
}
Program: 157452
Project: 157452
Buggy source:
@Override public void onViewCreated(View view,Bundle savedInstanceState){
  super.onViewCreated(view,savedInstanceState);
  mFullIndicator=view.findViewById(R.id.selected_page_indicator);
  mWizardPager=(ViewPager)view.findViewById(R.id.wizard_pages_pager);
  isInTabletUi=(mWizardPager == null);
  if (isInTabletUi) {
    FragmentManager fragmentManager=getChildFragmentManager();
    fragmentManager.beginTransaction().add(R.id.wizard_step_one,new WizardPageEnableKeyboardFragment()).add(R.id.wizard_step_two,new WizardPageSwitchToKeyboardFragment()).add(R.id.wizard_step_three,new WizardPageDoneAndMoreSettingsFragment()).commit();
  }
 else {
    mWizardPager.setAdapter(new WizardPagesAdapter(getChildFragmentManager()));
    mWizardPager.setOnPageChangeListener(onPageChangedListener);
  }
}

Fixed version (ground truth):
@Override public void onViewCreated(View view,Bundle savedInstanceState){
  super.onViewCreated(view,savedInstanceState);
  mFullIndicator=view.findViewById(R.id.selected_page_indicator);
  mWizardPager=(ViewPager)view.findViewById(R.id.wizard_pages_pager);
  isInTabletUi=(mWizardPager == null);
  if (isInTabletUi) {
    if (savedInstanceState == null) {
      FragmentManager fragmentManager=getChildFragmentManager();
      fragmentManager.beginTransaction().replace(R.id.wizard_step_one,new WizardPageEnableKeyboardFragment()).replace(R.id.wizard_step_two,new WizardPageSwitchToKeyboardFragment()).replace(R.id.wizard_step_three,new WizardPageDoneAndMoreSettingsFragment()).commit();
    }
  }
 else {
    mWizardPager.setAdapter(new WizardPagesAdapter(getChildFragmentManager()));
    mWizardPager.setOnPageChangeListener(onPageChangedListener);
  }
}
Program: 157453
Project: 157453
Buggy source:
private void scrollToPageRequiresSetup(){
  if (mWizardPager == null)   return;
  int positionToStartAt=0;
  if (SetupSupport.isThisKeyboardEnabled(getActivity())) {
    positionToStartAt=1;
    if (SetupSupport.isThisKeyboardSetAsDefaultIME(getActivity())) {
      positionToStartAt=2;
    }
  }
  mUiHandler.removeMessages(KEY_MESSAGE_SCROLL_TO_PAGE);
  mUiHandler.sendMessageDelayed(mUiHandler.obtainMessage(KEY_MESSAGE_SCROLL_TO_PAGE,positionToStartAt,0),getResources().getInteger(android.R.integer.config_longAnimTime));
}

Fixed version (ground truth):
private void scrollToPageRequiresSetup(){
  if (isInTabletUi)   return;
  int positionToStartAt=0;
  if (SetupSupport.isThisKeyboardEnabled(getActivity())) {
    positionToStartAt=1;
    if (SetupSupport.isThisKeyboardSetAsDefaultIME(getActivity())) {
      positionToStartAt=2;
    }
  }
  mUiHandler.removeMessages(KEY_MESSAGE_SCROLL_TO_PAGE);
  mUiHandler.sendMessageDelayed(mUiHandler.obtainMessage(KEY_MESSAGE_SCROLL_TO_PAGE,positionToStartAt,0),getResources().getInteger(android.R.integer.config_longAnimTime));
}
Program: 157454
Project: 157454
Buggy source:
@Override public void onViewCreated(View view,Bundle savedInstanceState){
  super.onViewCreated(view,savedInstanceState);
  mFullIndicator=view.findViewById(R.id.selected_page_indicator);
  mWizardPager=(ViewPager)view.findViewById(R.id.wizard_pages_pager);
  if (mWizardPager != null) {
    mWizardPager.setAdapter(new WizardPagesAdapter(getChildFragmentManager()));
    mWizardPager.setOnPageChangeListener(onPageChangedListener);
  }
}

Fixed version (ground truth):
@Override public void onViewCreated(View view,Bundle savedInstanceState){
  super.onViewCreated(view,savedInstanceState);
  mFullIndicator=view.findViewById(R.id.selected_page_indicator);
  mWizardPager=(ViewPager)view.findViewById(R.id.wizard_pages_pager);
  isInTabletUi=(mWizardPager == null);
  if (isInTabletUi) {
    FragmentManager fragmentManager=getChildFragmentManager();
    fragmentManager.beginTransaction().add(R.id.wizard_step_one,new WizardPageEnableKeyboardFragment()).add(R.id.wizard_step_two,new WizardPageSwitchToKeyboardFragment()).add(R.id.wizard_step_three,new WizardPageDoneAndMoreSettingsFragment()).commit();
  }
 else {
    mWizardPager.setAdapter(new WizardPagesAdapter(getChildFragmentManager()));
    mWizardPager.setOnPageChangeListener(onPageChangedListener);
  }
}
Program: 157455
Project: 157455
Buggy source:
private void refreshFragmentsUi(){
  if (mWizardPager != null) {
    mWizardPager.getAdapter().notifyDataSetChanged();
    scrollToPageRequiresSetup();
  }
 else {
    FragmentManager fragmentManager=getFragmentManager();
    refreshFragmentUi(fragmentManager,R.id.wizard_step_one);
    refreshFragmentUi(fragmentManager,R.id.wizard_step_two);
    refreshFragmentUi(fragmentManager,R.id.wizard_step_three);
  }
}

Fixed version (ground truth):
private void refreshFragmentsUi(){
  if (isInTabletUi) {
    FragmentManager fragmentManager=getChildFragmentManager();
    refreshFragmentUi(fragmentManager,R.id.wizard_step_one);
    refreshFragmentUi(fragmentManager,R.id.wizard_step_two);
    refreshFragmentUi(fragmentManager,R.id.wizard_step_three);
  }
 else {
    mWizardPager.getAdapter().notifyDataSetChanged();
    scrollToPageRequiresSetup();
  }
}
Program: 157456
Project: 157456
Buggy source:
private void postSetFullIndicatorPosition(int position,float positionOffset){
  mScrollHandler.removeMessages(KEY_MESSAGE_UPDATE_INDICATOR);
  mScrollHandler.sendMessage(mScrollHandler.obtainMessage(KEY_MESSAGE_UPDATE_INDICATOR,position,0,Float.valueOf(positionOffset)));
}

Fixed version (ground truth):
private void postSetFullIndicatorPosition(int position,float positionOffset){
  mUiHandler.removeMessages(KEY_MESSAGE_UPDATE_INDICATOR);
  mUiHandler.sendMessage(mUiHandler.obtainMessage(KEY_MESSAGE_UPDATE_INDICATOR,position,0,Float.valueOf(positionOffset)));
}
Program: 157457
Project: 157457
Buggy source:
@Override public void onChange(boolean selfChange){
  if (isResumed() && mWizardPager != null) {
    mWizardPager.getAdapter().notifyDataSetChanged();
    scrollToPageRequiresSetup();
  }
 else {
    mReloadPager=true;
  }
}

Fixed version (ground truth):
@Override public void onChange(boolean selfChange){
  mUiHandler.removeMessages(KEY_MESSAGE_UPDATE_FRAGMENTS);
  mUiHandler.sendMessageDelayed(mUiHandler.obtainMessage(KEY_MESSAGE_UPDATE_FRAGMENTS),50);
}
Program: 157458
Project: 157458
Buggy source:
@Override public void handleMessage(Message msg){
  super.handleMessage(msg);
switch (msg.what) {
case KEY_MESSAGE_SCROLL_TO_PAGE:
    int pageToScrollTo=msg.arg1;
  mWizardPager.setCurrentItem(pageToScrollTo,true);
setFullIndicatorTo(pageToScrollTo,0.0f);
break;
case KEY_MESSAGE_UPDATE_INDICATOR:
int position=msg.arg1;
float offset=((Float)msg.obj).floatValue();
setFullIndicatorTo(position,offset);
break;
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
  super.handleMessage(msg);
switch (msg.what) {
case KEY_MESSAGE_SCROLL_TO_PAGE:
    int pageToScrollTo=msg.arg1;
  mWizardPager.setCurrentItem(pageToScrollTo,true);
setFullIndicatorTo(pageToScrollTo,0.0f);
break;
case KEY_MESSAGE_UPDATE_INDICATOR:
int position=msg.arg1;
float offset=((Float)msg.obj).floatValue();
setFullIndicatorTo(position,offset);
break;
case KEY_MESSAGE_UPDATE_FRAGMENTS:
if (isResumed()) {
refreshFragmentsUi();
}
 else {
mReloadPager=true;
}
break;
}
}
Program: 157459
Project: 157459
Buggy source:
private void scrollToPageRequiresSetup(){
  if (mWizardPager == null)   return;
  int positionToStartAt=0;
  if (SetupSupport.isThisKeyboardEnabled(getActivity())) {
    positionToStartAt=1;
    if (SetupSupport.isThisKeyboardSetAsDefaultIME(getActivity())) {
      positionToStartAt=2;
    }
  }
  mScrollHandler.removeMessages(KEY_MESSAGE_SCROLL_TO_PAGE);
  mScrollHandler.sendMessageDelayed(mScrollHandler.obtainMessage(KEY_MESSAGE_SCROLL_TO_PAGE,positionToStartAt,0),getResources().getInteger(android.R.integer.config_longAnimTime));
}

Fixed version (ground truth):
private void scrollToPageRequiresSetup(){
  if (mWizardPager == null)   return;
  int positionToStartAt=0;
  if (SetupSupport.isThisKeyboardEnabled(getActivity())) {
    positionToStartAt=1;
    if (SetupSupport.isThisKeyboardSetAsDefaultIME(getActivity())) {
      positionToStartAt=2;
    }
  }
  mUiHandler.removeMessages(KEY_MESSAGE_SCROLL_TO_PAGE);
  mUiHandler.sendMessageDelayed(mUiHandler.obtainMessage(KEY_MESSAGE_SCROLL_TO_PAGE,positionToStartAt,0),getResources().getInteger(android.R.integer.config_longAnimTime));
}
Program: 157460
Project: 157460
Buggy source:
@Override public void onStart(){
  super.onStart();
  if (mReloadPager && mWizardPager != null) {
    mWizardPager.getAdapter().notifyDataSetChanged();
  }
  scrollToPageRequiresSetup();
  mReloadPager=false;
}

Fixed version (ground truth):
@Override public void onStart(){
  super.onStart();
  if (mReloadPager) {
    refreshFragmentsUi();
  }
  mReloadPager=false;
}
Program: 157461
Project: 157461
Buggy source:
@Override public void onStop(){
  super.onStop();
  mScrollHandler.removeMessages(KEY_MESSAGE_SCROLL_TO_PAGE);
}

Fixed version (ground truth):
@Override public void onStop(){
  super.onStop();
  mUiHandler.removeMessages(KEY_MESSAGE_SCROLL_TO_PAGE);
}
Program: 157462
Project: 157462
Buggy source:
@Override public void onStart(){
  super.onStart();
  final View preStepNotCompeleted=getView().findViewById(R.id.previous_step_not_complete);
  final View thisStepCompeleted=getView().findViewById(R.id.this_step_complete);
  final View thisStepSetup=getView().findViewById(R.id.this_step_needs_setup);
  preStepNotCompeleted.setVisibility(View.GONE);
  thisStepCompeleted.setVisibility(View.GONE);
  thisStepSetup.setVisibility(View.GONE);
  if (!isStepPreConditionDone()) {
    preStepNotCompeleted.setVisibility(View.VISIBLE);
  }
 else   if (isStepCompleted()) {
    thisStepCompeleted.setVisibility(View.VISIBLE);
  }
 else {
    thisStepSetup.setVisibility(View.VISIBLE);
  }
}

Fixed version (ground truth):
@Override public void onStart(){
  super.onStart();
  refreshFragmentUi();
}
Program: 157463
Project: 157463
Buggy source:
public void onSendCrashReport(View v){
  String[] recipients=new String[]{BuildConfig.CRASH_REPORT_EMAIL_ADDRESS};
  Intent callingIntent=getIntent();
  Intent sendMail=new Intent();
  sendMail.setAction(Intent.ACTION_SEND);
  sendMail.setType("String_Node_Str");
  sendMail.putExtra(Intent.EXTRA_EMAIL,recipients);
  sendMail.putExtra(Intent.EXTRA_SUBJECT,getText(R.string.ime_crashed_title));
  sendMail.putExtra(Intent.EXTRA_TEXT,callingIntent.getStringExtra(CRASH_REPORT_TEXT));
  try {
    Intent sender=Intent.createChooser(sendMail,getString(R.string.ime_crashed_intent_selector_title));
    sender.putExtra(Intent.EXTRA_EMAIL,sendMail.getStringExtra(Intent.EXTRA_EMAIL));
    sender.putExtra(Intent.EXTRA_SUBJECT,sendMail.getStringExtra(Intent.EXTRA_SUBJECT));
    sender.putExtra(Intent.EXTRA_TEXT,callingIntent.getStringExtra(CRASH_REPORT_TEXT));
    Log.i(TAG,"String_Node_Str" + sender);
    startActivity(sender);
  }
 catch (  android.content.ActivityNotFoundException ex) {
    Toast.makeText(getApplicationContext(),"String_Node_Str",Toast.LENGTH_LONG).show();
  }
  finish();
}

Fixed version (ground truth):
public void onSendCrashReport(View v){
  String[] recipients=new String[]{BuildConfig.CRASH_REPORT_EMAIL_ADDRESS};
  Intent callingIntent=getIntent();
  Intent sendMail=new Intent();
  sendMail.setAction(Intent.ACTION_SEND);
  sendMail.setType("String_Node_Str");
  sendMail.putExtra(Intent.EXTRA_EMAIL,recipients);
  sendMail.putExtra(Intent.EXTRA_SUBJECT,getText(R.string.ime_crashed_title));
  sendMail.putExtra(Intent.EXTRA_TEXT,callingIntent.getStringExtra(CRASH_REPORT_TEXT));
  try {
    Intent sender=Intent.createChooser(sendMail,getString(R.string.ime_crashed_intent_selector_title));
    sender.putExtra(Intent.EXTRA_EMAIL,sendMail.getStringArrayExtra(Intent.EXTRA_EMAIL));
    sender.putExtra(Intent.EXTRA_SUBJECT,sendMail.getStringExtra(Intent.EXTRA_SUBJECT));
    sender.putExtra(Intent.EXTRA_TEXT,callingIntent.getStringExtra(CRASH_REPORT_TEXT));
    Log.i(TAG,"String_Node_Str" + sender);
    startActivity(sender);
  }
 catch (  android.content.ActivityNotFoundException ex) {
    Toast.makeText(getApplicationContext(),"String_Node_Str",Toast.LENGTH_LONG).show();
  }
  finish();
}
Program: 157464
Project: 157464
Buggy source:
@Override public void onDestroy(){
  super.onDestroy();
  mAppContext.getContentResolver().unregisterContentObserver(mSecureSettingsChanged);
  mAppContext=null;
}

Fixed version (ground truth):
@Override public void onDestroy(){
  super.onDestroy();
  if (mAppContext != null)   mAppContext.getContentResolver().unregisterContentObserver(mSecureSettingsChanged);
  mAppContext=null;
}
Program: 157465
Project: 157465
Buggy source:
public void fillWordsList(){
  Log.d(TAG,"String_Node_Str" + mSelectedLocale);
  new UserWordsEditorAsyncTask(this){
    private UserDictionary mNewDictionary;
    private List<String> mWordsList;
    @Override protected void onPreExecute(){
      super.onPreExecute();
      mNewDictionary=new UserDictionary(getActivity().getApplicationContext(),mSelectedLocale);
      if (mNewDictionary != mCurrentDictionary && mCurrentDictionary != null && mCursor != null) {
        mCurrentDictionary.close();
      }
    }
    @Override protected Void doAsyncTask(    Void[] params) throws Exception {
      mCurrentDictionary=mNewDictionary;
      mCurrentDictionary.loadDictionary();
      mCursor=mCurrentDictionary.getWordsCursor();
      Cursor cursor=mCursor.getCursor();
      mWordsList=new ArrayList<>(mCursor.getCursor().getCount());
      cursor.moveToFirst();
      while (!cursor.isAfterLast()) {
        mWordsList.add(mCursor.getCurrentWord());
        cursor.moveToNext();
      }
      return null;
    }
    protected void applyResults(    Void result,    Exception backgroundException){
      UserWordsListAdapter adapter=new UserWordsListAdapter(UserDictionaryEditorFragment.this.getActivity(),mWordsList,UserDictionaryEditorFragment.this);
      mWordsListView.setAdapter(adapter);
    }
  }
.execute();
}

Fixed version (ground truth):
public void fillWordsList(){
  Log.d(TAG,"String_Node_Str" + mSelectedLocale);
  new UserWordsEditorAsyncTask(this){
    private UserDictionary mNewDictionary;
    private List<String> mWordsList;
    @Override protected void onPreExecute(){
      super.onPreExecute();
      mNewDictionary=new UserDictionary(getActivity().getApplicationContext(),mSelectedLocale);
      if (mNewDictionary != mCurrentDictionary && mCurrentDictionary != null && mCursor != null) {
        mCurrentDictionary.close();
      }
    }
    @Override protected Void doAsyncTask(    Void[] params) throws Exception {
      mCurrentDictionary=mNewDictionary;
      mCurrentDictionary.loadDictionary();
      mCursor=mCurrentDictionary.getWordsCursor();
      Cursor cursor=mCursor.getCursor();
      mWordsList=new ArrayList<>(mCursor.getCursor().getCount());
      cursor.moveToFirst();
      while (!cursor.isAfterLast()) {
        mWordsList.add(mCursor.getCurrentWord());
        cursor.moveToNext();
      }
      return null;
    }
    protected void applyResults(    Void result,    Exception backgroundException){
      UserWordsListAdapter adapter=new UserWordsListAdapter(UserDictionaryEditorFragment.this.getActivity(),mWordsList,UserDictionaryEditorFragment.this);
      if (mWordsListView instanceof ListView) {
        ((ListView)mWordsListView).setAdapter(adapter);
      }
 else       if (mWordsListView instanceof GridView) {
        ((GridView)mWordsListView).setAdapter(adapter);
      }
 else {
        throw new ClassCastException("String_Node_Str" + mWordsListView.getClass());
      }
    }
  }
.execute();
}
Program: 157466
Project: 157466
Buggy source:
@Override protected void onRestoreInstanceState(Parcelable state){
  if (state == null || !(state instanceof AddOnsListSavedState)) {
    super.onRestoreInstanceState(state);
  }
 else {
    AddOnsListSavedState myState=(AddOnsListSavedState)state;
    String selectedAddOnId=myState.selectedAddOnId;
    String[] addOnIds=myState.addOnIds;
    AddOn[] addOns=new AddOn[addOnIds.length];
    for (int i=0; i < addOns.length; i++)     addOns[i]=AddOnsFactory.locateAddOn(addOnIds[i],getContext().getApplicationContext());
    setAddOnsList(addOns);
    setSelectedAddOn(AddOnsFactory.locateAddOn(selectedAddOnId,getContext().getApplicationContext()));
    super.onRestoreInstanceState(myState.getSuperState());
  }
}

Fixed version (ground truth):
@Override protected void onRestoreInstanceState(Parcelable state){
  if (state == null || !(state instanceof AddOnsListSavedState)) {
    super.onRestoreInstanceState(state);
  }
 else {
    AddOnsListSavedState myState=(AddOnsListSavedState)state;
    String selectedAddOnId=myState.selectedAddOnId;
    String[] addOnIds=myState.addOnIds;
    AddOn[] addOns=new AddOn[addOnIds.length];
    for (int i=0; i < addOns.length; i++)     addOns[i]=AddOnsFactory.locateAddOn(addOnIds[i],getContext().getApplicationContext());
    setAddOnsList(addOns);
    setSelectedAddOn(selectedAddOnId == null ? null : AddOnsFactory.locateAddOn(selectedAddOnId,getContext().getApplicationContext()));
    super.onRestoreInstanceState(myState.getSuperState());
  }
}
Program: 157467
Project: 157467
Buggy source:
@Override protected Parcelable onSaveInstanceState(){
  Parcelable superP=super.onSaveInstanceState();
  AddOnsListSavedState myState=new AddOnsListSavedState(superP);
  myState.selectedAddOnId=mSelectedAddOn.getId();
  String[] addOns=new String[mAddOns.length];
  for (int i=0; i < addOns.length; i++)   addOns[i]=mAddOns[i].getId();
  myState.addOnIds=addOns;
  return myState;
}

Fixed version (ground truth):
@Override protected Parcelable onSaveInstanceState(){
  Parcelable superP=super.onSaveInstanceState();
  AddOnsListSavedState myState=new AddOnsListSavedState(superP);
  myState.selectedAddOnId=mSelectedAddOn == null ? null : mSelectedAddOn.getId();
  String[] addOns=new String[mAddOns.length];
  for (int i=0; i < addOns.length; i++)   addOns[i]=mAddOns[i].getId();
  myState.addOnIds=addOns;
  return myState;
}
Program: 157469
Project: 157469
Buggy source:
public boolean isAtTwoFingersState(){
  return SystemClock.elapsedRealtime() - mLastTimeHadTwoFingers > TWO_FINGERS_LINGER_TIME;
}

Fixed version (ground truth):
public boolean isAtTwoFingersState(){
  return SystemClock.elapsedRealtime() - mLastTimeHadTwoFingers < TWO_FINGERS_LINGER_TIME;
}
Program: 157472
Project: 157472
Buggy source:
public boolean onSeparate(float factor){
  if (factor > 1.35) {
    mKeyboardView.mKeyboardActionListener.onSeparate();
    return true;
  }
  return false;
}

Fixed version (ground truth):
public boolean onSeparate(float factor){
  if (factor > 1.35) {
    mKeyboardView.disableTouchesTillFingersAreUp();
    mKeyboardView.mKeyboardActionListener.onSeparate();
    return true;
  }
  return false;
}
Program: 157475
Project: 157475
Buggy source:
public boolean onPinch(float factor){
  if (factor < 0.65) {
    mKeyboardView.mKeyboardActionListener.onPinch();
    return true;
  }
  return false;
}

Fixed version (ground truth):
public boolean onPinch(float factor){
  if (factor < 0.65) {
    mKeyboardView.disableTouchesTillFingersAreUp();
    mKeyboardView.mKeyboardActionListener.onPinch();
    return true;
  }
  return false;
}
Program: 157478
Project: 157478
Buggy source:
@Override public CharSequence getSummary(){
  return String.format(super.getSummary().toString(),getEntry());
}

Fixed version (ground truth):
@Override public CharSequence getSummary(){
  final CharSequence baseSummary=super.getSummary();
  if (TextUtils.isEmpty(baseSummary))   return baseSummary;
 else   return String.format(baseSummary.toString(),getEntry());
}
Program: 157481
Project: 157481
Buggy source:
/** 
 * Sets an optional contacts dictionary resource to be loaded.
 */
public void setContactsDictionary(Context context,boolean enabled){
  if (!enabled && mContactsDictionary != null) {
    Log.i(TAG,"String_Node_Str");
    mContactsDictionary.close();
    mContactsDictionary=null;
  }
 else   if (enabled && mContactsDictionary == null) {
    mContactsDictionary=mDictionaryFactory.createContactsDictionary(context);
    DictionaryASyncLoader loader=new DictionaryASyncLoader(null);
    loader.execute(mContactsDictionary);
    loader.waitTillLoadingStarted();
  }
}

Fixed version (ground truth):
/** 
 * Sets an optional contacts dictionary resource to be loaded.
 */
public void setContactsDictionary(Context context,boolean enabled){
  if (!enabled && mContactsDictionary != null) {
    Log.i(TAG,"String_Node_Str");
    mContactsDictionary.close();
    mContactsDictionary=null;
  }
 else   if (enabled && mContactsDictionary == null) {
    mContactsDictionary=mDictionaryFactory.createContactsDictionary(context);
    if (mContactsDictionary != null) {
      DictionaryASyncLoader loader=new DictionaryASyncLoader(null);
      loader.execute(mContactsDictionary);
      loader.waitTillLoadingStarted();
    }
  }
}
Program: 157482
Project: 157482
Buggy source:
public void showPreview(int keyIndex,PointerTracker tracker){
  int oldKeyIndex=mOldPreviewKeyIndex;
  mOldPreviewKeyIndex=keyIndex;
  final boolean isLanguageSwitchEnabled=false;
  final boolean hidePreviewOrShowSpaceKeyPreview=(tracker == null);
  if (oldKeyIndex != keyIndex && (mShowPreview || (hidePreviewOrShowSpaceKeyPreview && isLanguageSwitchEnabled))) {
    if (keyIndex == NOT_A_KEY) {
      mHandler.cancelPopupPreview();
      mHandler.dismissPreview(mDelayAfterPreview);
    }
 else     if (tracker != null) {
      if (tracker.getKey(keyIndex).showPreview)       mHandler.popupPreview(mDelayBeforePreview,keyIndex,tracker);
    }
  }
}

Fixed version (ground truth):
public void showPreview(int keyIndex,PointerTracker tracker){
  int oldKeyIndex=mOldPreviewKeyIndex;
  mOldPreviewKeyIndex=keyIndex;
  final boolean isLanguageSwitchEnabled=false;
  final boolean hidePreviewOrShowSpaceKeyPreview=(tracker == null);
  if (oldKeyIndex != keyIndex && (mShowPreview || (hidePreviewOrShowSpaceKeyPreview && isLanguageSwitchEnabled))) {
    final Key key=hidePreviewOrShowSpaceKeyPreview ? null : tracker.getKey(keyIndex);
    if (keyIndex == NOT_A_KEY || key == null || !key.showPreview) {
      mHandler.cancelPopupPreview();
      mHandler.dismissPreview(mDelayAfterPreview);
    }
 else     if (tracker != null) {
      mHandler.popupPreview(mDelayBeforePreview,keyIndex,tracker);
    }
  }
}
Program: 157483
Project: 157483
Buggy source:
/** 
 * Enables or disables the key feedback popup. This is a popup that shows a magnified version of the depressed key. By default the preview is enabled.
 * @param previewEnabled whether or not to enable the key feedback popup
 * @see #isPreviewEnabled()
 */
protected void setPreviewEnabled(boolean previewEnabled){
  mShowPreview=mPreviewText != null && previewEnabled;
}

Fixed version (ground truth):
/** 
 * Enables or disables the key feedback popup. This is a popup that shows a magnified version of the depressed key. By default the preview is enabled.
 * @param previewEnabled whether or not to enable the key feedback popup
 */
protected void setPreviewEnabled(boolean previewEnabled){
  mShowPreview=mPreviewText != null && previewEnabled;
}
Program: 157484
Project: 157484
Buggy source:
/** 
 * This method will help in the rare case the access to the dictionary is done before loading started (hence the storage is not ready)
 */
public void waitTillLoadingStarted(){
synchronized (mLoadingStartedMonitor) {
    if (mLoadingStarted == false) {
      try {
        mLoadingStartedMonitor.wait();
        waitTillLoadingStarted();
      }
 catch (      InterruptedException e) {
        e.printStackTrace();
        return;
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * This method will help in the rare case the access to the dictionary is done before loading started (hence the storage is not ready)
 */
public void waitTillLoadingStarted(){
  Thread.yield();
synchronized (mLoadingStartedMonitor) {
    if (mLoadingStarted == false) {
      try {
        mLoadingStartedMonitor.wait();
        waitTillLoadingStarted();
      }
 catch (      InterruptedException e) {
        e.printStackTrace();
        return;
      }
    }
  }
}
Program: 157485
Project: 157485
Buggy source:
/** 
 * Sets an optional contacts dictionary resource to be loaded.
 */
public void setContactsDictionary(Context context,boolean enabled){
  if (!enabled && mContactsDictionary != null) {
    Log.i(TAG,"String_Node_Str");
    mContactsDictionary.close();
    mContactsDictionary=null;
  }
 else   if (enabled && mContactsDictionary == null) {
    mContactsDictionary=mDictionaryFactory.createContactsDictionary(context);
  }
}

Fixed version (ground truth):
/** 
 * Sets an optional contacts dictionary resource to be loaded.
 */
public void setContactsDictionary(Context context,boolean enabled){
  if (!enabled && mContactsDictionary != null) {
    Log.i(TAG,"String_Node_Str");
    mContactsDictionary.close();
    mContactsDictionary=null;
  }
 else   if (enabled && mContactsDictionary == null) {
    mContactsDictionary=mDictionaryFactory.createContactsDictionary(context);
    DictionaryASyncLoader loader=new DictionaryASyncLoader(null);
    loader.execute(mContactsDictionary);
    loader.waitTillLoadingStarted();
  }
}
Program: 157487
Project: 157487
Buggy source:
public void popTextOutOfKey(CharSequence text){
  if (TextUtils.isEmpty(text)) {
    Log.w(TAG,"String_Node_Str");
    return;
  }
  if (!AnyApplication.getConfig().workaround_alwaysUseDrawText())   return;
  mPopOutText=text;
  mPopOutTime=SystemClock.elapsedRealtime();
  mPopOutStartPoint.x=mFirstTouchPont.x;
  mPopOutStartPoint.y=mFirstTouchPont.y;
  postInvalidate();
}

Fixed version (ground truth):
public void popTextOutOfKey(CharSequence text){
  if (TextUtils.isEmpty(text)) {
    Log.w(TAG,"String_Node_Str");
    return;
  }
  if (!AnyApplication.getConfig().workaround_alwaysUseDrawText())   return;
  mPopOutText=text.toString();
  mPopOutTime=SystemClock.elapsedRealtime();
  mPopOutStartPoint.x=mFirstTouchPont.x;
  mPopOutStartPoint.y=mFirstTouchPont.y;
  postInvalidate();
}
Program: 157488
Project: 157488
Buggy source:
/** 
 * Adds a word to the dictionary and makes it persistent.
 * @param word      the word to add. If the word is capitalized, then thedictionary will recognize it as a capitalized word when searched.
 * @param frequency the frequency of occurrence of the word. A frequency of 255 isconsidered the highest.
 */
public boolean addWord(String word,int frequency){
synchronized (mResourceMonitor) {
    if (isClosed())     return false;
    if (word.length() >= MAX_WORD_LENGTH)     return false;
    Log.e(TAG,"String_Node_Str" + word + "String_Node_Str"+ getClass().getSimpleName()+ "String_Node_Str"+ frequency);
    addWordRec(mRoots,word,0,frequency);
    AddWordToStorage(word,frequency);
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Adds a word to the dictionary and makes it persistent.
 * @param word      the word to add. If the word is capitalized, then thedictionary will recognize it as a capitalized word when searched.
 * @param frequency the frequency of occurrence of the word. A frequency of 255 isconsidered the highest.
 */
public boolean addWord(String word,int frequency){
synchronized (mResourceMonitor) {
    if (isClosed())     return false;
    if (word.length() >= MAX_WORD_LENGTH)     return false;
    Log.i(TAG,"String_Node_Str" + word + "String_Node_Str"+ getClass().getSimpleName()+ "String_Node_Str"+ frequency);
    deleteWord(word);
    addWordRec(mRoots,word,0,frequency);
    AddWordToStorage(word,frequency);
  }
  return true;
}
Program: 157489
Project: 157489
Buggy source:
private boolean deleteWordRec(final NodeArray children,final CharSequence word,final int offset,final int length){
  final int count=children.length;
  final char currentChar=word.charAt(offset);
  for (int j=0; j < count; j++) {
    final Node node=children.data[j];
    if (node.code == currentChar) {
      if (offset == length - 1) {
        if (node.terminal) {
          children.deleteNode(j);
          return true;
        }
 else {
          return false;
        }
      }
 else {
        final boolean aChildNodeWasDeleted=deleteWordRec(node.children,word,offset + 1,length);
        if (aChildNodeWasDeleted) {
          if (node.children.length == 0) {
            children.deleteNode(j);
            return true;
          }
 else {
            return false;
          }
        }
      }
    }
  }
  return false;
}

Fixed version (ground truth):
private boolean deleteWordRec(final NodeArray children,final CharSequence word,final int offset,final int length){
  final int count=children.length;
  final char currentChar=word.charAt(offset);
  for (int j=0; j < count; j++) {
    final Node node=children.data[j];
    if (node.code == currentChar) {
      if (offset == length - 1) {
        if (node.terminal) {
          children.deleteNode(j);
          return true;
        }
 else {
          return false;
        }
      }
 else       if (node.terminal && (node.children == null || node.children.length == 0)) {
        return false;
      }
 else {
        final boolean aChildNodeWasDeleted=deleteWordRec(node.children,word,offset + 1,length);
        if (aChildNodeWasDeleted) {
          if (node.children.length == 0) {
            children.deleteNode(j);
            return true;
          }
 else {
            return false;
          }
        }
      }
    }
  }
  return false;
}
Program: 157490
Project: 157490
Buggy source:
/** 
 * <p> Creates a blank keyboard from the given resource file and populates it with the specified characters in left-to-right, top-to-bottom fashion, using the specified number of columns. </p> <p> If the specified number of columns is -1, then the keyboard will fit as many keys as possible in each row. </p>
 * @param context             the application or service context
 * @param layoutTemplateResId the layout template file, containing no keys.
 * @param characters          the list of characters to display on the keyboard. Onekey will be created for each character.
 * @param columns             the number of columns of keys to display. If this numberis greater than the number of keys that can fit in a row, it will be ignored. If this number is -1, the keyboard will fit as many keys as possible in each row.
 */
public List<Key> getKeys(){
  return mKeys;
}

Fixed version (ground truth):
public List<Key> getKeys(){
  return mKeys;
}
Program: 157491
Project: 157491
Buggy source:
private void setupMiniKeyboardContainer(Context packageContext,CharSequence popupCharacters,int popupKeyboardId,boolean isSticky){
  final AnyPopupKeyboard keyboard;
  if (popupCharacters != null) {
    keyboard=new AnyPopupKeyboard(getContext().getApplicationContext(),popupCharacters,mMiniKeyboard.getThemedKeyboardDimens());
  }
 else {
    keyboard=new AnyPopupKeyboard(getContext().getApplicationContext(),packageContext,popupKeyboardId,mMiniKeyboard.getThemedKeyboardDimens());
  }
  keyboard.setIsOneKeyEventPopup(!isSticky);
  if (isSticky)   mMiniKeyboard.setKeyboard(keyboard,mVerticalCorrection);
 else   mMiniKeyboard.setKeyboard(keyboard);
  mMiniKeyboard.measure(MeasureSpec.makeMeasureSpec(getWidth(),MeasureSpec.AT_MOST),MeasureSpec.makeMeasureSpec(getHeight(),MeasureSpec.AT_MOST));
}

Fixed version (ground truth):
private void setupMiniKeyboardContainer(CharSequence popupCharacters,int popupKeyboardId,boolean isSticky){
  final AnyPopupKeyboard keyboard;
  if (popupCharacters != null) {
    keyboard=new AnyPopupKeyboard(getContext().getApplicationContext(),popupCharacters,mMiniKeyboard.getThemedKeyboardDimens());
  }
 else {
    keyboard=new AnyPopupKeyboard(getContext().getApplicationContext(),mKeyboard.getKeyboardContext(),popupKeyboardId,mMiniKeyboard.getThemedKeyboardDimens());
  }
  keyboard.setIsOneKeyEventPopup(!isSticky);
  if (isSticky)   mMiniKeyboard.setKeyboard(keyboard,mVerticalCorrection);
 else   mMiniKeyboard.setKeyboard(keyboard);
  mMiniKeyboard.measure(MeasureSpec.makeMeasureSpec(getWidth(),MeasureSpec.AT_MOST),MeasureSpec.makeMeasureSpec(getHeight(),MeasureSpec.AT_MOST));
}
Program: 157494
Project: 157494
Buggy source:
private void setGesturePreviewText(KeyboardSwitcher switcher,MotionEvent me){
  if (mPreviewText == null)   return;
  final int slide=getSlideDistance(me);
  final int slideDisatance=slide & 0x00FF;
  if (slideDisatance >= 20) {
    final boolean isGesture=slideDisatance > SLIDE_RATIO_FOR_GESTURE;
    final int alpha=isGesture ? 255 : slideDisatance / 2;
    mPreviewText.setTextSize(TypedValue.COMPLEX_UNIT_PX,mGesturePreviewTextSize);
    int color=Color.argb(alpha,mGesturePreviewTextColorRed,mGesturePreviewTextColorGreen,mGesturePreviewTextColorBlue);
    mPreviewText.setTextColor(color);
    final int swipeKeyTarget;
    final Configuration cfg=AnyApplication.getConfig();
switch (slide & 0xFF00) {
case DIRECTION_UP:
      swipeKeyTarget=cfg.getGestureSwipeUpFromSpacebarKeyCode();
    break;
case DIRECTION_DOWN:
  swipeKeyTarget=cfg.getGestureSwipeDownKeyCode();
break;
case DIRECTION_LEFT:
swipeKeyTarget=cfg.getGestureSwipeLeftKeyCode();
break;
case DIRECTION_RIGHT:
swipeKeyTarget=cfg.getGestureSwipeRightKeyCode();
break;
default :
swipeKeyTarget=KeyCodes.SPACE;
break;
}
String tooltip;
switch (swipeKeyTarget) {
case KeyCodes.MODE_ALPHABET:
tooltip=switcher.peekNextAlphabetKeyboard();
break;
case KeyCodes.MODE_SYMOBLS:
tooltip=switcher.peekNextSymbolsKeyboard();
break;
default :
tooltip="String_Node_Str";
break;
}
mPreviewText.setText(tooltip);
}
 else {
mPreviewText.setText("String_Node_Str");
}
}

Fixed version (ground truth):
private void setGesturePreviewText(KeyboardSwitcher switcher,MotionEvent me){
  if (mPreviewText == null)   return;
  final int slide=getSlideDistance(me);
  final int slideDisatance=slide & 0x00FF;
  if (slideDisatance >= 20) {
    final boolean isGesture=slideDisatance > SLIDE_RATIO_FOR_GESTURE;
    final int alpha=isGesture ? 255 : slideDisatance / 2;
    mPreviewText.setTextSize(TypedValue.COMPLEX_UNIT_PX,mGesturePreviewTextSize);
    int color=Color.argb(alpha,mGesturePreviewTextColorRed,mGesturePreviewTextColorGreen,mGesturePreviewTextColorBlue);
    mPreviewText.setTextColor(color);
    final int swipeKeyTarget;
    final Configuration cfg=AnyApplication.getConfig();
switch (slide & 0xFF00) {
case DIRECTION_UP:
      swipeKeyTarget=cfg.getGestureSwipeUpFromSpacebarKeyCode();
    break;
case DIRECTION_DOWN:
  swipeKeyTarget=cfg.getGestureSwipeDownKeyCode();
break;
case DIRECTION_LEFT:
swipeKeyTarget=cfg.getGestureSwipeLeftKeyCode();
break;
case DIRECTION_RIGHT:
swipeKeyTarget=cfg.getGestureSwipeRightKeyCode();
break;
default :
swipeKeyTarget=KeyCodes.SPACE;
break;
}
String tooltip;
switch (swipeKeyTarget) {
case KeyCodes.MODE_ALPHABET:
tooltip=switcher != null ? switcher.peekNextAlphabetKeyboard() : "String_Node_Str";
break;
case KeyCodes.MODE_SYMOBLS:
tooltip=switcher != null ? switcher.peekNextSymbolsKeyboard() : "String_Node_Str";
break;
default :
tooltip="String_Node_Str";
break;
}
mPreviewText.setText(tooltip);
}
 else {
mPreviewText.setText("String_Node_Str");
}
}
Program: 157495
Project: 157495
Buggy source:
DictionaryContentObserver(DictionaryContentObserverDiagram diagram){
  super(null);
  mDictionary=new WeakReference<BTreeDictionary>(diagram.getOwningDictionary());
}

Fixed version (ground truth):
public DictionaryContentObserver(DictionaryContentObserverDiagram diagram){
  super(null);
  mDictionary=new WeakReference<BTreeDictionary>(diagram.getOwningDictionary());
}
Program: 157496
Project: 157496
Buggy source:
@Override protected boolean isEventRequiresViewReset(Intent eventIntent,Context context){
  KeyboardTheme selectedTheme=getCurrentKeyboardTheme(context.getApplicationContext());
  if ((selectedTheme != null) && (selectedTheme.getPackageContext().getPackageName().equals(eventIntent.getData().getSchemeSpecificPart()))) {
    Log.d(TAG,"String_Node_Str");
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override protected boolean isEventRequiresViewReset(Intent eventIntent,Context context){
  KeyboardTheme selectedTheme=getCurrentKeyboardTheme(context.getApplicationContext());
  if ((selectedTheme != null) && (selectedTheme.getPackageName().equals(eventIntent.getData().getSchemeSpecificPart()))) {
    Log.d(TAG,"String_Node_Str");
    return true;
  }
  return false;
}
Program: 157498
Project: 157498
Buggy source:
@Override public final WordsCursor getWordsCursor(){
  try {
    if (mStorage == null)     mStorage=createStorage(mLocale);
    return mStorage.getWordsCursor();
  }
 catch (  SQLiteException e) {
    e.printStackTrace();
    final String dbFile=mStorage.getDatabaseName();
    try {
      mStorage.close();
    }
 catch (    SQLiteException swallow) {
    }
    Log.w(TAG,"String_Node_Str" + e.getMessage() + "String_Node_Str"+ dbFile+ "String_Node_Str");
    mContext.deleteDatabase(dbFile);
    mStorage=null;
    mStorage=createStorage(mLocale);
    return mStorage.getWordsCursor();
  }
}

Fixed version (ground truth):
@Override public final WordsCursor getWordsCursor(){
  try {
    if (mStorage == null)     mStorage=createStorage(mLocale);
    return mStorage.getWordsCursor();
  }
 catch (  SQLiteException e) {
    e.printStackTrace();
    final String dbFile=mStorage.getDbFilename();
    try {
      mStorage.close();
    }
 catch (    SQLiteException swallow) {
    }
    Log.w(TAG,"String_Node_Str" + e.getMessage() + "String_Node_Str"+ dbFile+ "String_Node_Str");
    mContext.deleteDatabase(dbFile);
    mStorage=null;
    mStorage=createStorage(mLocale);
    return mStorage.getWordsCursor();
  }
}
Program: 157499
Project: 157499
Buggy source:
public WordsSQLiteConnection(Context context,String DbFilename,String currentLocale){
  super(context,DbFilename,null,7);
  mContext=context;
  mCurrentLocale=currentLocale;
}

Fixed version (ground truth):
public WordsSQLiteConnection(Context context,String DbFilename,String currentLocale){
  super(context,DbFilename,null,7);
  mContext=context;
  mCurrentLocale=currentLocale;
  mDbName=DbFilename;
}
Program: 157501
Project: 157501
Buggy source:
public ConfigurationImpl(Context context){
  mContext=context;
  String version="String_Node_Str";
  int releaseNumber=0;
  try {
    PackageInfo info=mContext.getPackageManager().getPackageInfo(mContext.getPackageName(),0);
    version=info.versionName;
    releaseNumber=info.versionCode;
  }
 catch (  NameNotFoundException e) {
    Log.e(TAG,"String_Node_Str");
  }
  Log.i(TAG,"String_Node_Str" + version);
  Log.i(TAG,"String_Node_Str" + releaseNumber);
  Log.i(TAG,"String_Node_Str" + AnyApplication.DEBUG);
  SharedPreferences sp=PreferenceManager.getDefaultSharedPreferences(mContext);
  updateStatistics(sp,mContext);
  customizeSettingValues(mContext.getApplicationContext(),sp);
  upgradeSettingsValues(sp);
  onSharedPreferenceChanged(sp,"String_Node_Str");
}

Fixed version (ground truth):
public ConfigurationImpl(Context context){
  mContext=context;
  String version="String_Node_Str";
  int releaseNumber=0;
  try {
    PackageInfo info=mContext.getPackageManager().getPackageInfo(mContext.getPackageName(),0);
    version=info.versionName;
    releaseNumber=info.versionCode;
  }
 catch (  NameNotFoundException e) {
    Log.e(TAG,"String_Node_Str");
  }
  Log.i(TAG,"String_Node_Str" + version);
  Log.i(TAG,"String_Node_Str" + releaseNumber);
  Log.i(TAG,"String_Node_Str" + AnyApplication.DEBUG);
  SharedPreferences sp=PreferenceManager.getDefaultSharedPreferences(mContext);
  updateStatistics(sp,mContext);
  customizeSettingValues(mContext.getApplicationContext(),sp);
  upgradeSettingsValues(sp);
  initializeComputedValues(sp);
  onSharedPreferenceChanged(sp,"String_Node_Str");
}
Program: 157503
Project: 157503
Buggy source:
public void deleteNode(int nodeIndexToDelete){
  length--;
  final int oldChildrenCount=data.length;
  Node[] newChildren=new Node[oldChildrenCount - 1];
  int newArrayIndex=0;
  for (int oldArrayIndex=0; oldArrayIndex < oldChildrenCount; oldArrayIndex++) {
    if (oldArrayIndex != nodeIndexToDelete)     newChildren[newArrayIndex]=data[oldArrayIndex];
 else     newArrayIndex++;
  }
  data=newChildren;
}

Fixed version (ground truth):
public void deleteNode(int nodeIndexToDelete){
  length--;
  final int oldChildrenCount=data.length;
  Node[] newChildren=new Node[oldChildrenCount - 1];
  int newArrayIndex=0;
  for (int oldArrayIndex=0; oldArrayIndex < oldChildrenCount; oldArrayIndex++) {
    if (oldArrayIndex != nodeIndexToDelete) {
      newChildren[newArrayIndex]=data[oldArrayIndex];
      newArrayIndex++;
    }
  }
  data=newChildren;
}
Program: 157504
Project: 157504
Buggy source:
private int deleteWordRec(final NodeArray children,final CharSequence word,final int offset,final int length){
  final int count=children.length;
  final char currentChar=word.charAt(offset);
  for (int j=0; j < count; j++) {
    final Node node=children.data[j];
    if (node.code == currentChar) {
      if (offset == length - 1) {
        if (node.terminal) {
          node.terminal=false;
          return j;
        }
      }
 else {
        if (node.children != null) {
          final int deletedIndex=deleteWordRec(node.children,word,offset + 1,length);
          if (deletedIndex >= 0) {
            Node deletedNode=node.children.data[deletedIndex];
            if (deletedNode.children.length == 0 && !deletedNode.terminal) {
              node.children.deleteNode(deletedIndex);
              return j;
            }
 else {
              return -1;
            }
          }
        }
      }
    }
  }
  return -1;
}

Fixed version (ground truth):
private boolean deleteWordRec(final NodeArray children,final CharSequence word,final int offset,final int length){
  final int count=children.length;
  final char currentChar=word.charAt(offset);
  for (int j=0; j < count; j++) {
    final Node node=children.data[j];
    if (node.code == currentChar) {
      if (offset == length - 1) {
        if (node.terminal) {
          children.deleteNode(j);
          return true;
        }
 else {
          return false;
        }
      }
 else {
        final boolean aChildNodeWasDeleted=deleteWordRec(node.children,word,offset + 1,length);
        if (aChildNodeWasDeleted) {
          if (node.children.length == 0) {
            children.deleteNode(j);
            return true;
          }
 else {
            return false;
          }
        }
      }
    }
  }
  return false;
}
Program: 157505
Project: 157505
Buggy source:
private void handleShift(boolean reset){
  mHandler.removeMessages(MSG_UPDATE_SHIFT_STATE);
  if (mKeyboardSwitcher.isAlphabetMode()) {
    final boolean caps;
    if (reset) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str");
      mInputView.setShifted(false);
      caps=false;
    }
 else {
      if (!mInputView.isShifted()) {
        mShiftStartTime=SystemClock.elapsedRealtime();
        if (DEBUG)         Log.d(TAG,"String_Node_Str");
        mInputView.setShifted(true);
        caps=false;
      }
 else {
        if (mInputView.isShiftLocked()) {
          if (DEBUG)           Log.d(TAG,"String_Node_Str");
          mInputView.setShifted(false);
          caps=false;
        }
 else {
          if ((SystemClock.elapsedRealtime() - mShiftStartTime) < mConfig.getMultiTapTimeout()) {
            if (DEBUG)             Log.d(TAG,"String_Node_Str");
            mInputView.setShifted(true);
            caps=true;
          }
 else {
            if (DEBUG)             Log.d(TAG,"String_Node_Str");
            mInputView.setShifted(false);
            caps=false;
          }
        }
      }
    }
    mCapsLock=caps;
    mInputView.setShiftLocked(mCapsLock);
  }
}

Fixed version (ground truth):
private void handleShift(boolean reset){
  mHandler.removeMessages(MSG_UPDATE_SHIFT_STATE);
  if (mInputView != null && mKeyboardSwitcher.isAlphabetMode()) {
    final boolean caps;
    if (reset) {
      mInputView.setShifted(false);
      caps=false;
    }
 else {
      if (!mInputView.isShifted()) {
        mShiftStartTime=SystemClock.elapsedRealtime();
        mInputView.setShifted(true);
        caps=false;
      }
 else {
        if (mInputView.isShiftLocked()) {
          mInputView.setShifted(false);
          caps=false;
        }
 else {
          if ((SystemClock.elapsedRealtime() - mShiftStartTime) < mConfig.getMultiTapTimeout()) {
            Log.d(TAG,"String_Node_Str");
            mInputView.setShifted(true);
            caps=true;
          }
 else {
            Log.d(TAG,"String_Node_Str");
            mInputView.setShifted(false);
            caps=false;
          }
        }
      }
    }
    mCapsLock=caps;
    mInputView.setShiftLocked(mCapsLock);
  }
}