nus-yam/ex-repair huggingface dataset:
Program: 87604
Project: 87604
Buggy source:
/** 
 * When the cursor is moved by the user, we need to update its position. If it falls inside the currently composing word, we don't reset the composition, and only update the cursor position.
 * @param expectedMoveAmount How many java chars to move the cursor. Negative values movethe cursor backward, positive values move the cursor forward.
 * @return true if the cursor is still inside the composing word, false otherwise.
 */
public boolean moveCursorByAndReturnIfInsideComposingWord(final int expectedMoveAmount){
  int actualMoveAmountWithinWord=0;
  int cursorPos=mCursorPositionWithinWord;
  if (expectedMoveAmount >= 0) {
    while (actualMoveAmountWithinWord < expectedMoveAmount && cursorPos < mCodePointSize) {
      actualMoveAmountWithinWord+=Character.charCount(mPrimaryKeyCodes[cursorPos]);
      ++cursorPos;
    }
  }
 else {
    while (actualMoveAmountWithinWord > expectedMoveAmount && cursorPos > 0) {
      --cursorPos;
      actualMoveAmountWithinWord-=Character.charCount(mPrimaryKeyCodes[cursorPos]);
    }
  }
  if (actualMoveAmountWithinWord != expectedMoveAmount)   return false;
  mCursorPositionWithinWord=cursorPos;
  return true;
}

Fixed version (ground truth):
/** 
 * When the cursor is moved by the user, we need to update its position. If it falls inside the currently composing word, we don't reset the composition, and only update the cursor position.
 * @param expectedMoveAmount How many java chars to move the cursor. Negative values movethe cursor backward, positive values move the cursor forward.
 * @return true if the cursor is still inside the composing word, false otherwise.
 */
public boolean moveCursorByAndReturnIfInsideComposingWord(final int expectedMoveAmount){
  int actualMoveAmountWithinWord=0;
  int cursorPos=mCursorPositionWithinWord;
  final int[] codePoints;
  if (mCodePointSize >= MAX_WORD_LENGTH) {
    codePoints=StringUtils.toCodePointArray(mTypedWord.toString());
  }
 else {
    codePoints=mPrimaryKeyCodes;
  }
  if (expectedMoveAmount >= 0) {
    while (actualMoveAmountWithinWord < expectedMoveAmount && cursorPos < mCodePointSize) {
      actualMoveAmountWithinWord+=Character.charCount(codePoints[cursorPos]);
      ++cursorPos;
    }
  }
 else {
    while (actualMoveAmountWithinWord > expectedMoveAmount && cursorPos > 0) {
      --cursorPos;
      actualMoveAmountWithinWord-=Character.charCount(codePoints[cursorPos]);
    }
  }
  if (actualMoveAmountWithinWord != expectedMoveAmount)   return false;
  mCursorPositionWithinWord=cursorPos;
  return true;
}
Program: 87605
Project: 87605
Buggy source:
/** 
 * When the cursor is moved by the user, we need to update its position. If it falls inside the currently composing word, we don't reset the composition, and only update the cursor position.
 * @param expectedMoveAmount How many java chars to move the cursor. Negative values movethe cursor backward, positive values move the cursor forward.
 * @return true if the cursor is still inside the composing word, false otherwise.
 */
public boolean moveCursorByAndReturnIfInsideComposingWord(final int expectedMoveAmount){
  int actualMoveAmountWithinWord=0;
  int cursorPos=mCursorPositionWithinWord;
  if (expectedMoveAmount >= 0) {
    while (actualMoveAmountWithinWord < expectedMoveAmount && cursorPos < mCodePointSize) {
      actualMoveAmountWithinWord+=Character.charCount(mPrimaryKeyCodes[cursorPos]);
      ++cursorPos;
    }
  }
 else {
    while (actualMoveAmountWithinWord > expectedMoveAmount && cursorPos > 0) {
      --cursorPos;
      actualMoveAmountWithinWord-=Character.charCount(mPrimaryKeyCodes[cursorPos]);
    }
  }
  if (actualMoveAmountWithinWord != expectedMoveAmount)   return false;
  mCursorPositionWithinWord=cursorPos;
  return true;
}

Fixed version (ground truth):
/** 
 * When the cursor is moved by the user, we need to update its position. If it falls inside the currently composing word, we don't reset the composition, and only update the cursor position.
 * @param expectedMoveAmount How many java chars to move the cursor. Negative values movethe cursor backward, positive values move the cursor forward.
 * @return true if the cursor is still inside the composing word, false otherwise.
 */
public boolean moveCursorByAndReturnIfInsideComposingWord(final int expectedMoveAmount){
  int actualMoveAmountWithinWord=0;
  int cursorPos=mCursorPositionWithinWord;
  final int[] codePoints;
  if (mCodePointSize >= MAX_WORD_LENGTH) {
    codePoints=StringUtils.toCodePointArray(mTypedWord.toString());
  }
 else {
    codePoints=mPrimaryKeyCodes;
  }
  if (expectedMoveAmount >= 0) {
    while (actualMoveAmountWithinWord < expectedMoveAmount && cursorPos < mCodePointSize) {
      actualMoveAmountWithinWord+=Character.charCount(codePoints[cursorPos]);
      ++cursorPos;
    }
  }
 else {
    while (actualMoveAmountWithinWord > expectedMoveAmount && cursorPos > 0) {
      --cursorPos;
      actualMoveAmountWithinWord-=Character.charCount(codePoints[cursorPos]);
    }
  }
  if (actualMoveAmountWithinWord != expectedMoveAmount)   return false;
  mCursorPositionWithinWord=cursorPos;
  return true;
}
Program: 87606
Project: 87606
Buggy source:
public void reset(){
  mStatus=NOT_INITIALIZED;
  mAnimateToStatus=NOT_INITIALIZED;
}

Fixed version (ground truth):
public void reset(final DictionaryListInterfaceState interfaceState){
  mStatus=NOT_INITIALIZED;
  mAnimateToStatus=NOT_INITIALIZED;
  mInterfaceState=interfaceState;
}
Program: 87607
Project: 87607
Buggy source:
private ViewPropertyAnimator animateButton(final View button,final int direction){
  final float outerX=getWidth();
  final float innerX=button.getX() - button.getTranslationX();
  if (ANIMATION_IN == direction) {
    button.setClickable(true);
    return button.animate().translationX(0);
  }
 else {
    button.setClickable(false);
    return button.animate().translationX(outerX - innerX);
  }
}

Fixed version (ground truth):
private ViewPropertyAnimator animateButton(final View button,final int direction){
  final float outerX=getWidth();
  final float innerX=button.getX() - button.getTranslationX();
  mInterfaceState.removeFromCache((View)getParent());
  if (ANIMATION_IN == direction) {
    button.setClickable(true);
    return button.animate().translationX(0);
  }
 else {
    button.setClickable(false);
    return button.animate().translationX(outerX - innerX);
  }
}
Program: 87608
Project: 87608
Buggy source:
@Override protected void onBindView(final View view){
  super.onBindView(view);
  ((ViewGroup)view).setLayoutTransition(null);
  final DictionaryDownloadProgressBar progressBar=(DictionaryDownloadProgressBar)view.findViewById(R.id.dictionary_line_progress_bar);
  final TextView status=(TextView)view.findViewById(android.R.id.summary);
  progressBar.setIds(mClientId,mWordlistId);
  progressBar.setMax(mFilesize);
  final boolean showProgressBar=(MetadataDbHelper.STATUS_DOWNLOADING == mStatus);
  status.setVisibility(showProgressBar ? View.INVISIBLE : View.VISIBLE);
  progressBar.setVisibility(showProgressBar ? View.VISIBLE : View.INVISIBLE);
  final ButtonSwitcher buttonSwitcher=(ButtonSwitcher)view.findViewById(R.id.wordlist_button_switcher);
  buttonSwitcher.reset();
  if (mInterfaceState.isOpen(mWordlistId)) {
    final int previousStatus=mInterfaceState.getStatus(mWordlistId);
    buttonSwitcher.setStatusAndUpdateVisuals(getButtonSwitcherStatus(previousStatus));
    if (previousStatus != mStatus) {
      buttonSwitcher.setStatusAndUpdateVisuals(getButtonSwitcherStatus(mStatus));
      mInterfaceState.setOpen(mWordlistId,mStatus);
    }
  }
 else {
    buttonSwitcher.setStatusAndUpdateVisuals(ButtonSwitcher.STATUS_NO_BUTTON);
  }
  buttonSwitcher.setInternalOnClickListener(mActionButtonClickHandler);
  view.setOnClickListener(mPreferenceClickHandler);
}

Fixed version (ground truth):
@Override protected void onBindView(final View view){
  super.onBindView(view);
  ((ViewGroup)view).setLayoutTransition(null);
  final DictionaryDownloadProgressBar progressBar=(DictionaryDownloadProgressBar)view.findViewById(R.id.dictionary_line_progress_bar);
  final TextView status=(TextView)view.findViewById(android.R.id.summary);
  progressBar.setIds(mClientId,mWordlistId);
  progressBar.setMax(mFilesize);
  final boolean showProgressBar=(MetadataDbHelper.STATUS_DOWNLOADING == mStatus);
  status.setVisibility(showProgressBar ? View.INVISIBLE : View.VISIBLE);
  progressBar.setVisibility(showProgressBar ? View.VISIBLE : View.INVISIBLE);
  final ButtonSwitcher buttonSwitcher=(ButtonSwitcher)view.findViewById(R.id.wordlist_button_switcher);
  buttonSwitcher.reset(mInterfaceState);
  if (mInterfaceState.isOpen(mWordlistId)) {
    final int previousStatus=mInterfaceState.getStatus(mWordlistId);
    buttonSwitcher.setStatusAndUpdateVisuals(getButtonSwitcherStatus(previousStatus));
    if (previousStatus != mStatus) {
      buttonSwitcher.setStatusAndUpdateVisuals(getButtonSwitcherStatus(mStatus));
      mInterfaceState.setOpen(mWordlistId,mStatus);
    }
  }
 else {
    buttonSwitcher.setStatusAndUpdateVisuals(ButtonSwitcher.STATUS_NO_BUTTON);
  }
  buttonSwitcher.setInternalOnClickListener(mActionButtonClickHandler);
  view.setOnClickListener(mPreferenceClickHandler);
}
Program: 87609
Project: 87609
Buggy source:
public void reset(){
  mStatus=NOT_INITIALIZED;
  mAnimateToStatus=NOT_INITIALIZED;
}

Fixed version (ground truth):
public void reset(final DictionaryListInterfaceState interfaceState){
  mStatus=NOT_INITIALIZED;
  mAnimateToStatus=NOT_INITIALIZED;
  mInterfaceState=interfaceState;
}
Program: 87610
Project: 87610
Buggy source:
private ViewPropertyAnimator animateButton(final View button,final int direction){
  final float outerX=getWidth();
  final float innerX=button.getX() - button.getTranslationX();
  if (ANIMATION_IN == direction) {
    button.setClickable(true);
    return button.animate().translationX(0);
  }
 else {
    button.setClickable(false);
    return button.animate().translationX(outerX - innerX);
  }
}

Fixed version (ground truth):
private ViewPropertyAnimator animateButton(final View button,final int direction){
  final float outerX=getWidth();
  final float innerX=button.getX() - button.getTranslationX();
  mInterfaceState.removeFromCache((View)getParent());
  if (ANIMATION_IN == direction) {
    button.setClickable(true);
    return button.animate().translationX(0);
  }
 else {
    button.setClickable(false);
    return button.animate().translationX(outerX - innerX);
  }
}
Program: 87611
Project: 87611
Buggy source:
@Override protected void onBindView(final View view){
  super.onBindView(view);
  ((ViewGroup)view).setLayoutTransition(null);
  final DictionaryDownloadProgressBar progressBar=(DictionaryDownloadProgressBar)view.findViewById(R.id.dictionary_line_progress_bar);
  final TextView status=(TextView)view.findViewById(android.R.id.summary);
  progressBar.setIds(mClientId,mWordlistId);
  progressBar.setMax(mFilesize);
  final boolean showProgressBar=(MetadataDbHelper.STATUS_DOWNLOADING == mStatus);
  status.setVisibility(showProgressBar ? View.INVISIBLE : View.VISIBLE);
  progressBar.setVisibility(showProgressBar ? View.VISIBLE : View.INVISIBLE);
  final ButtonSwitcher buttonSwitcher=(ButtonSwitcher)view.findViewById(R.id.wordlist_button_switcher);
  buttonSwitcher.reset();
  if (mInterfaceState.isOpen(mWordlistId)) {
    final int previousStatus=mInterfaceState.getStatus(mWordlistId);
    buttonSwitcher.setStatusAndUpdateVisuals(getButtonSwitcherStatus(previousStatus));
    if (previousStatus != mStatus) {
      buttonSwitcher.setStatusAndUpdateVisuals(getButtonSwitcherStatus(mStatus));
      mInterfaceState.setOpen(mWordlistId,mStatus);
    }
  }
 else {
    buttonSwitcher.setStatusAndUpdateVisuals(ButtonSwitcher.STATUS_NO_BUTTON);
  }
  buttonSwitcher.setInternalOnClickListener(mActionButtonClickHandler);
  view.setOnClickListener(mPreferenceClickHandler);
}

Fixed version (ground truth):
@Override protected void onBindView(final View view){
  super.onBindView(view);
  ((ViewGroup)view).setLayoutTransition(null);
  final DictionaryDownloadProgressBar progressBar=(DictionaryDownloadProgressBar)view.findViewById(R.id.dictionary_line_progress_bar);
  final TextView status=(TextView)view.findViewById(android.R.id.summary);
  progressBar.setIds(mClientId,mWordlistId);
  progressBar.setMax(mFilesize);
  final boolean showProgressBar=(MetadataDbHelper.STATUS_DOWNLOADING == mStatus);
  status.setVisibility(showProgressBar ? View.INVISIBLE : View.VISIBLE);
  progressBar.setVisibility(showProgressBar ? View.VISIBLE : View.INVISIBLE);
  final ButtonSwitcher buttonSwitcher=(ButtonSwitcher)view.findViewById(R.id.wordlist_button_switcher);
  buttonSwitcher.reset(mInterfaceState);
  if (mInterfaceState.isOpen(mWordlistId)) {
    final int previousStatus=mInterfaceState.getStatus(mWordlistId);
    buttonSwitcher.setStatusAndUpdateVisuals(getButtonSwitcherStatus(previousStatus));
    if (previousStatus != mStatus) {
      buttonSwitcher.setStatusAndUpdateVisuals(getButtonSwitcherStatus(mStatus));
      mInterfaceState.setOpen(mWordlistId,mStatus);
    }
  }
 else {
    buttonSwitcher.setStatusAndUpdateVisuals(ButtonSwitcher.STATUS_NO_BUTTON);
  }
  buttonSwitcher.setInternalOnClickListener(mActionButtonClickHandler);
  view.setOnClickListener(mPreferenceClickHandler);
}
Program: 87612
Project: 87612
Buggy source:
public void reset(){
  mStatus=NOT_INITIALIZED;
  mAnimateToStatus=NOT_INITIALIZED;
}

Fixed version (ground truth):
public void reset(final DictionaryListInterfaceState interfaceState){
  mStatus=NOT_INITIALIZED;
  mAnimateToStatus=NOT_INITIALIZED;
  mInterfaceState=interfaceState;
}
Program: 87613
Project: 87613
Buggy source:
private ViewPropertyAnimator animateButton(final View button,final int direction){
  final float outerX=getWidth();
  final float innerX=button.getX() - button.getTranslationX();
  if (ANIMATION_IN == direction) {
    button.setClickable(true);
    return button.animate().translationX(0);
  }
 else {
    button.setClickable(false);
    return button.animate().translationX(outerX - innerX);
  }
}

Fixed version (ground truth):
private ViewPropertyAnimator animateButton(final View button,final int direction){
  final float outerX=getWidth();
  final float innerX=button.getX() - button.getTranslationX();
  mInterfaceState.removeFromCache((View)getParent());
  if (ANIMATION_IN == direction) {
    button.setClickable(true);
    return button.animate().translationX(0);
  }
 else {
    button.setClickable(false);
    return button.animate().translationX(outerX - innerX);
  }
}
Program: 87614
Project: 87614
Buggy source:
@Override protected void onBindView(final View view){
  super.onBindView(view);
  ((ViewGroup)view).setLayoutTransition(null);
  final DictionaryDownloadProgressBar progressBar=(DictionaryDownloadProgressBar)view.findViewById(R.id.dictionary_line_progress_bar);
  final TextView status=(TextView)view.findViewById(android.R.id.summary);
  progressBar.setIds(mClientId,mWordlistId);
  progressBar.setMax(mFilesize);
  final boolean showProgressBar=(MetadataDbHelper.STATUS_DOWNLOADING == mStatus);
  status.setVisibility(showProgressBar ? View.INVISIBLE : View.VISIBLE);
  progressBar.setVisibility(showProgressBar ? View.VISIBLE : View.INVISIBLE);
  final ButtonSwitcher buttonSwitcher=(ButtonSwitcher)view.findViewById(R.id.wordlist_button_switcher);
  buttonSwitcher.reset();
  if (mInterfaceState.isOpen(mWordlistId)) {
    final int previousStatus=mInterfaceState.getStatus(mWordlistId);
    buttonSwitcher.setStatusAndUpdateVisuals(getButtonSwitcherStatus(previousStatus));
    if (previousStatus != mStatus) {
      buttonSwitcher.setStatusAndUpdateVisuals(getButtonSwitcherStatus(mStatus));
      mInterfaceState.setOpen(mWordlistId,mStatus);
    }
  }
 else {
    buttonSwitcher.setStatusAndUpdateVisuals(ButtonSwitcher.STATUS_NO_BUTTON);
  }
  buttonSwitcher.setInternalOnClickListener(mActionButtonClickHandler);
  view.setOnClickListener(mPreferenceClickHandler);
}

Fixed version (ground truth):
@Override protected void onBindView(final View view){
  super.onBindView(view);
  ((ViewGroup)view).setLayoutTransition(null);
  final DictionaryDownloadProgressBar progressBar=(DictionaryDownloadProgressBar)view.findViewById(R.id.dictionary_line_progress_bar);
  final TextView status=(TextView)view.findViewById(android.R.id.summary);
  progressBar.setIds(mClientId,mWordlistId);
  progressBar.setMax(mFilesize);
  final boolean showProgressBar=(MetadataDbHelper.STATUS_DOWNLOADING == mStatus);
  status.setVisibility(showProgressBar ? View.INVISIBLE : View.VISIBLE);
  progressBar.setVisibility(showProgressBar ? View.VISIBLE : View.INVISIBLE);
  final ButtonSwitcher buttonSwitcher=(ButtonSwitcher)view.findViewById(R.id.wordlist_button_switcher);
  buttonSwitcher.reset(mInterfaceState);
  if (mInterfaceState.isOpen(mWordlistId)) {
    final int previousStatus=mInterfaceState.getStatus(mWordlistId);
    buttonSwitcher.setStatusAndUpdateVisuals(getButtonSwitcherStatus(previousStatus));
    if (previousStatus != mStatus) {
      buttonSwitcher.setStatusAndUpdateVisuals(getButtonSwitcherStatus(mStatus));
      mInterfaceState.setOpen(mWordlistId,mStatus);
    }
  }
 else {
    buttonSwitcher.setStatusAndUpdateVisuals(ButtonSwitcher.STATUS_NO_BUTTON);
  }
  buttonSwitcher.setInternalOnClickListener(mActionButtonClickHandler);
  view.setOnClickListener(mPreferenceClickHandler);
}
Program: 87615
Project: 87615
Buggy source:
private static void reinitializeClientRecordInDictionaryContentProvider(final Context context,final ContentProviderClient client,final String clientId) throws RemoteException {
  final String metadataFileUri=MetadataFileUriGetter.getMetadataUri(context);
  final String metadataAdditionalId=MetadataFileUriGetter.getMetadataAdditionalId(context);
  if (TextUtils.isEmpty(metadataFileUri))   return;
  final Uri metadataContentUri=getProviderUriBuilder(clientId).appendPath(QUERY_PATH_METADATA).appendQueryParameter(QUERY_PARAMETER_PROTOCOL,QUERY_PARAMETER_PROTOCOL_VALUE).build();
  client.delete(metadataContentUri,null,null);
  final ContentValues metadataValues=new ContentValues();
  metadataValues.put(INSERT_METADATA_CLIENT_ID_COLUMN,clientId);
  metadataValues.put(INSERT_METADATA_METADATA_URI_COLUMN,metadataFileUri);
  metadataValues.put(INSERT_METADATA_METADATA_ADDITIONAL_ID_COLUMN,metadataAdditionalId);
  client.insert(metadataContentUri,metadataValues);
  final Uri dictionaryContentUriBase=getProviderUriBuilder(clientId).appendPath(QUERY_PATH_DICT_INFO).appendQueryParameter(QUERY_PARAMETER_PROTOCOL,QUERY_PARAMETER_PROTOCOL_VALUE).build();
  final ArrayList<DictionaryInfo> dictionaryList=DictionaryInfoUtils.getCurrentDictionaryFileNameAndVersionInfo(context);
  final int length=dictionaryList.size();
  for (int i=0; i < length; ++i) {
    final DictionaryInfo info=dictionaryList.get(i);
    client.insert(Uri.withAppendedPath(dictionaryContentUriBase,info.mId),info.toContentValues());
  }
}

Fixed version (ground truth):
private static void reinitializeClientRecordInDictionaryContentProvider(final Context context,final ContentProviderClient client,final String clientId) throws RemoteException {
  final String metadataFileUri=MetadataFileUriGetter.getMetadataUri(context);
  final String metadataAdditionalId=MetadataFileUriGetter.getMetadataAdditionalId(context);
  final Uri metadataContentUri=getProviderUriBuilder(clientId).appendPath(QUERY_PATH_METADATA).appendQueryParameter(QUERY_PARAMETER_PROTOCOL,QUERY_PARAMETER_PROTOCOL_VALUE).build();
  client.delete(metadataContentUri,null,null);
  final ContentValues metadataValues=new ContentValues();
  metadataValues.put(INSERT_METADATA_CLIENT_ID_COLUMN,clientId);
  metadataValues.put(INSERT_METADATA_METADATA_URI_COLUMN,metadataFileUri);
  metadataValues.put(INSERT_METADATA_METADATA_ADDITIONAL_ID_COLUMN,metadataAdditionalId);
  client.insert(metadataContentUri,metadataValues);
  final Uri dictionaryContentUriBase=getProviderUriBuilder(clientId).appendPath(QUERY_PATH_DICT_INFO).appendQueryParameter(QUERY_PARAMETER_PROTOCOL,QUERY_PARAMETER_PROTOCOL_VALUE).build();
  final ArrayList<DictionaryInfo> dictionaryList=DictionaryInfoUtils.getCurrentDictionaryFileNameAndVersionInfo(context);
  final int length=dictionaryList.size();
  for (int i=0; i < length; ++i) {
    final DictionaryInfo info=dictionaryList.get(i);
    client.insert(Uri.withAppendedPath(dictionaryContentUriBase,info.mId),info.toContentValues());
  }
}
Program: 87617
Project: 87617
Buggy source:
private static void dispatchBroadcast(final Context context,final Intent intent){
  if (DATE_CHANGED_INTENT_ACTION.equals(intent.getAction())) {
    checkTimeAndMaybeSetupUpdateAlarm(context);
  }
 else   if (DictionaryPackConstants.UPDATE_NOW_INTENT_ACTION.equals(intent.getAction())) {
    UpdateHandler.update(context,false);
  }
 else {
    UpdateHandler.downloadFinished(context,intent);
  }
}

Fixed version (ground truth):
private static void dispatchBroadcast(final Context context,final Intent intent){
  if (DATE_CHANGED_INTENT_ACTION.equals(intent.getAction())) {
    checkTimeAndMaybeSetupUpdateAlarm(context);
  }
 else   if (DictionaryPackConstants.UPDATE_NOW_INTENT_ACTION.equals(intent.getAction())) {
    UpdateHandler.tryUpdate(context,false);
  }
 else {
    UpdateHandler.downloadFinished(context,intent);
  }
}
Program: 87618
Project: 87618
Buggy source:
/** 
 * Refreshes data if it hasn't been refreshed in a very long time. This will check the last update time, and if it's been more than VERY_LONG_TIME, update metadata now - and possibly take subsequent update actions.
 */
public static void updateNowIfNotUpdatedInAVeryLongTime(final Context context){
  if (!isLastUpdateAtLeastThisOld(context,VERY_LONG_TIME))   return;
  UpdateHandler.update(context,false);
}

Fixed version (ground truth):
/** 
 * Refreshes data if it hasn't been refreshed in a very long time. This will check the last update time, and if it's been more than VERY_LONG_TIME, update metadata now - and possibly take subsequent update actions.
 */
public static void updateNowIfNotUpdatedInAVeryLongTime(final Context context){
  if (!isLastUpdateAtLeastThisOld(context,VERY_LONG_TIME))   return;
  UpdateHandler.tryUpdate(context,false);
}
Program: 87619
Project: 87619
Buggy source:
private void startLoadingAnimation(){
  mLoadingView.setVisibility(View.VISIBLE);
  getView().setVisibility(View.GONE);
  mUpdateNowMenu.setTitle(R.string.cancel);
}

Fixed version (ground truth):
private void startLoadingAnimation(){
  mLoadingView.setVisibility(View.VISIBLE);
  getView().setVisibility(View.GONE);
  if (null != mUpdateNowMenu)   mUpdateNowMenu.setTitle(R.string.cancel);
}
Program: 87620
Project: 87620
Buggy source:
private void startRefresh(){
  startLoadingAnimation();
  mChangedSettings=true;
  UpdateHandler.registerUpdateEventListener(this);
  final Activity activity=getActivity();
  new Thread("String_Node_Str"){
    @Override public void run(){
      UpdateHandler.update(activity,true);
    }
  }
.start();
}

Fixed version (ground truth):
private void startRefresh(){
  startLoadingAnimation();
  mChangedSettings=true;
  UpdateHandler.registerUpdateEventListener(this);
  final Activity activity=getActivity();
  new Thread("String_Node_Str"){
    @Override public void run(){
      if (!UpdateHandler.tryUpdate(activity,true)) {
        stopLoadingAnimation();
      }
    }
  }
.start();
}
Program: 87621
Project: 87621
Buggy source:
@Override public void onCreateOptionsMenu(final Menu menu,final MenuInflater inflater){
  mUpdateNowMenu=menu.add(Menu.NONE,MENU_UPDATE_NOW,0,R.string.check_for_updates_now);
  mUpdateNowMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
  refreshNetworkState();
}

Fixed version (ground truth):
@Override public void onCreateOptionsMenu(final Menu menu,final MenuInflater inflater){
  final String metadataUri=MetadataDbHelper.getMetadataUriAsString(getActivity(),mClientId);
  if (!TextUtils.isEmpty(metadataUri)) {
    mUpdateNowMenu=menu.add(Menu.NONE,MENU_UPDATE_NOW,0,R.string.check_for_updates_now);
    mUpdateNowMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    refreshNetworkState();
  }
}
Program: 87622
Project: 87622
Buggy source:
private static void reinitializeClientRecordInDictionaryContentProvider(final Context context,final ContentProviderClient client,final String clientId) throws RemoteException {
  final String metadataFileUri=MetadataFileUriGetter.getMetadataUri(context);
  final String metadataAdditionalId=MetadataFileUriGetter.getMetadataAdditionalId(context);
  if (TextUtils.isEmpty(metadataFileUri))   return;
  final Uri metadataContentUri=getProviderUriBuilder(clientId).appendPath(QUERY_PATH_METADATA).appendQueryParameter(QUERY_PARAMETER_PROTOCOL,QUERY_PARAMETER_PROTOCOL_VALUE).build();
  client.delete(metadataContentUri,null,null);
  final ContentValues metadataValues=new ContentValues();
  metadataValues.put(INSERT_METADATA_CLIENT_ID_COLUMN,clientId);
  metadataValues.put(INSERT_METADATA_METADATA_URI_COLUMN,metadataFileUri);
  metadataValues.put(INSERT_METADATA_METADATA_ADDITIONAL_ID_COLUMN,metadataAdditionalId);
  client.insert(metadataContentUri,metadataValues);
  final Uri dictionaryContentUriBase=getProviderUriBuilder(clientId).appendPath(QUERY_PATH_DICT_INFO).appendQueryParameter(QUERY_PARAMETER_PROTOCOL,QUERY_PARAMETER_PROTOCOL_VALUE).build();
  final ArrayList<DictionaryInfo> dictionaryList=DictionaryInfoUtils.getCurrentDictionaryFileNameAndVersionInfo(context);
  final int length=dictionaryList.size();
  for (int i=0; i < length; ++i) {
    final DictionaryInfo info=dictionaryList.get(i);
    client.insert(Uri.withAppendedPath(dictionaryContentUriBase,info.mId),info.toContentValues());
  }
}

Fixed version (ground truth):
private static void reinitializeClientRecordInDictionaryContentProvider(final Context context,final ContentProviderClient client,final String clientId) throws RemoteException {
  final String metadataFileUri=MetadataFileUriGetter.getMetadataUri(context);
  final String metadataAdditionalId=MetadataFileUriGetter.getMetadataAdditionalId(context);
  final Uri metadataContentUri=getProviderUriBuilder(clientId).appendPath(QUERY_PATH_METADATA).appendQueryParameter(QUERY_PARAMETER_PROTOCOL,QUERY_PARAMETER_PROTOCOL_VALUE).build();
  client.delete(metadataContentUri,null,null);
  final ContentValues metadataValues=new ContentValues();
  metadataValues.put(INSERT_METADATA_CLIENT_ID_COLUMN,clientId);
  metadataValues.put(INSERT_METADATA_METADATA_URI_COLUMN,metadataFileUri);
  metadataValues.put(INSERT_METADATA_METADATA_ADDITIONAL_ID_COLUMN,metadataAdditionalId);
  client.insert(metadataContentUri,metadataValues);
  final Uri dictionaryContentUriBase=getProviderUriBuilder(clientId).appendPath(QUERY_PATH_DICT_INFO).appendQueryParameter(QUERY_PARAMETER_PROTOCOL,QUERY_PARAMETER_PROTOCOL_VALUE).build();
  final ArrayList<DictionaryInfo> dictionaryList=DictionaryInfoUtils.getCurrentDictionaryFileNameAndVersionInfo(context);
  final int length=dictionaryList.size();
  for (int i=0; i < length; ++i) {
    final DictionaryInfo info=dictionaryList.get(i);
    client.insert(Uri.withAppendedPath(dictionaryContentUriBase,info.mId),info.toContentValues());
  }
}
Program: 87624
Project: 87624
Buggy source:
private static void dispatchBroadcast(final Context context,final Intent intent){
  if (DATE_CHANGED_INTENT_ACTION.equals(intent.getAction())) {
    checkTimeAndMaybeSetupUpdateAlarm(context);
  }
 else   if (DictionaryPackConstants.UPDATE_NOW_INTENT_ACTION.equals(intent.getAction())) {
    UpdateHandler.update(context,false);
  }
 else {
    UpdateHandler.downloadFinished(context,intent);
  }
}

Fixed version (ground truth):
private static void dispatchBroadcast(final Context context,final Intent intent){
  if (DATE_CHANGED_INTENT_ACTION.equals(intent.getAction())) {
    checkTimeAndMaybeSetupUpdateAlarm(context);
  }
 else   if (DictionaryPackConstants.UPDATE_NOW_INTENT_ACTION.equals(intent.getAction())) {
    UpdateHandler.tryUpdate(context,false);
  }
 else {
    UpdateHandler.downloadFinished(context,intent);
  }
}
Program: 87625
Project: 87625
Buggy source:
/** 
 * Refreshes data if it hasn't been refreshed in a very long time. This will check the last update time, and if it's been more than VERY_LONG_TIME, update metadata now - and possibly take subsequent update actions.
 */
public static void updateNowIfNotUpdatedInAVeryLongTime(final Context context){
  if (!isLastUpdateAtLeastThisOld(context,VERY_LONG_TIME))   return;
  UpdateHandler.update(context,false);
}

Fixed version (ground truth):
/** 
 * Refreshes data if it hasn't been refreshed in a very long time. This will check the last update time, and if it's been more than VERY_LONG_TIME, update metadata now - and possibly take subsequent update actions.
 */
public static void updateNowIfNotUpdatedInAVeryLongTime(final Context context){
  if (!isLastUpdateAtLeastThisOld(context,VERY_LONG_TIME))   return;
  UpdateHandler.tryUpdate(context,false);
}
Program: 87626
Project: 87626
Buggy source:
private void startLoadingAnimation(){
  mLoadingView.setVisibility(View.VISIBLE);
  getView().setVisibility(View.GONE);
  mUpdateNowMenu.setTitle(R.string.cancel);
}

Fixed version (ground truth):
private void startLoadingAnimation(){
  mLoadingView.setVisibility(View.VISIBLE);
  getView().setVisibility(View.GONE);
  if (null != mUpdateNowMenu)   mUpdateNowMenu.setTitle(R.string.cancel);
}
Program: 87627
Project: 87627
Buggy source:
private void startRefresh(){
  startLoadingAnimation();
  mChangedSettings=true;
  UpdateHandler.registerUpdateEventListener(this);
  final Activity activity=getActivity();
  new Thread("String_Node_Str"){
    @Override public void run(){
      UpdateHandler.update(activity,true);
    }
  }
.start();
}

Fixed version (ground truth):
private void startRefresh(){
  startLoadingAnimation();
  mChangedSettings=true;
  UpdateHandler.registerUpdateEventListener(this);
  final Activity activity=getActivity();
  new Thread("String_Node_Str"){
    @Override public void run(){
      if (!UpdateHandler.tryUpdate(activity,true)) {
        stopLoadingAnimation();
      }
    }
  }
.start();
}
Program: 87628
Project: 87628
Buggy source:
@Override public void onCreateOptionsMenu(final Menu menu,final MenuInflater inflater){
  mUpdateNowMenu=menu.add(Menu.NONE,MENU_UPDATE_NOW,0,R.string.check_for_updates_now);
  mUpdateNowMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
  refreshNetworkState();
}

Fixed version (ground truth):
@Override public void onCreateOptionsMenu(final Menu menu,final MenuInflater inflater){
  final String metadataUri=MetadataDbHelper.getMetadataUriAsString(getActivity(),mClientId);
  if (!TextUtils.isEmpty(metadataUri)) {
    mUpdateNowMenu=menu.add(Menu.NONE,MENU_UPDATE_NOW,0,R.string.check_for_updates_now);
    mUpdateNowMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    refreshNetworkState();
  }
}
Program: 87629
Project: 87629
Buggy source:
private static void reinitializeClientRecordInDictionaryContentProvider(final Context context,final ContentProviderClient client,final String clientId) throws RemoteException {
  final String metadataFileUri=MetadataFileUriGetter.getMetadataUri(context);
  final String metadataAdditionalId=MetadataFileUriGetter.getMetadataAdditionalId(context);
  if (TextUtils.isEmpty(metadataFileUri))   return;
  final Uri metadataContentUri=getProviderUriBuilder(clientId).appendPath(QUERY_PATH_METADATA).appendQueryParameter(QUERY_PARAMETER_PROTOCOL,QUERY_PARAMETER_PROTOCOL_VALUE).build();
  client.delete(metadataContentUri,null,null);
  final ContentValues metadataValues=new ContentValues();
  metadataValues.put(INSERT_METADATA_CLIENT_ID_COLUMN,clientId);
  metadataValues.put(INSERT_METADATA_METADATA_URI_COLUMN,metadataFileUri);
  metadataValues.put(INSERT_METADATA_METADATA_ADDITIONAL_ID_COLUMN,metadataAdditionalId);
  client.insert(metadataContentUri,metadataValues);
  final Uri dictionaryContentUriBase=getProviderUriBuilder(clientId).appendPath(QUERY_PATH_DICT_INFO).appendQueryParameter(QUERY_PARAMETER_PROTOCOL,QUERY_PARAMETER_PROTOCOL_VALUE).build();
  final ArrayList<DictionaryInfo> dictionaryList=DictionaryInfoUtils.getCurrentDictionaryFileNameAndVersionInfo(context);
  final int length=dictionaryList.size();
  for (int i=0; i < length; ++i) {
    final DictionaryInfo info=dictionaryList.get(i);
    client.insert(Uri.withAppendedPath(dictionaryContentUriBase,info.mId),info.toContentValues());
  }
}

Fixed version (ground truth):
private static void reinitializeClientRecordInDictionaryContentProvider(final Context context,final ContentProviderClient client,final String clientId) throws RemoteException {
  final String metadataFileUri=MetadataFileUriGetter.getMetadataUri(context);
  final String metadataAdditionalId=MetadataFileUriGetter.getMetadataAdditionalId(context);
  final Uri metadataContentUri=getProviderUriBuilder(clientId).appendPath(QUERY_PATH_METADATA).appendQueryParameter(QUERY_PARAMETER_PROTOCOL,QUERY_PARAMETER_PROTOCOL_VALUE).build();
  client.delete(metadataContentUri,null,null);
  final ContentValues metadataValues=new ContentValues();
  metadataValues.put(INSERT_METADATA_CLIENT_ID_COLUMN,clientId);
  metadataValues.put(INSERT_METADATA_METADATA_URI_COLUMN,metadataFileUri);
  metadataValues.put(INSERT_METADATA_METADATA_ADDITIONAL_ID_COLUMN,metadataAdditionalId);
  client.insert(metadataContentUri,metadataValues);
  final Uri dictionaryContentUriBase=getProviderUriBuilder(clientId).appendPath(QUERY_PATH_DICT_INFO).appendQueryParameter(QUERY_PARAMETER_PROTOCOL,QUERY_PARAMETER_PROTOCOL_VALUE).build();
  final ArrayList<DictionaryInfo> dictionaryList=DictionaryInfoUtils.getCurrentDictionaryFileNameAndVersionInfo(context);
  final int length=dictionaryList.size();
  for (int i=0; i < length; ++i) {
    final DictionaryInfo info=dictionaryList.get(i);
    client.insert(Uri.withAppendedPath(dictionaryContentUriBase,info.mId),info.toContentValues());
  }
}
Program: 87633
Project: 87633
Buggy source:
public void setComposingRegion(final int start,final int end){
  if (DEBUG_BATCH_NESTING)   checkBatchEdit();
  if (DEBUG_PREVIOUS_TEXT)   checkConsistencyForDebug();
  mCurrentCursorPosition=end;
  final CharSequence textBeforeCursor=getTextBeforeCursor(DEFAULT_TEXT_CACHE_SIZE + (end - start),0);
  mCommittedTextBeforeComposingText.setLength(0);
  if (!TextUtils.isEmpty(textBeforeCursor)) {
    final int indexOfStartOfComposingText=Math.max(textBeforeCursor.length() - (end - start),0);
    mComposingText.append(textBeforeCursor.subSequence(indexOfStartOfComposingText,textBeforeCursor.length()));
    mCommittedTextBeforeComposingText.append(textBeforeCursor.subSequence(0,indexOfStartOfComposingText));
  }
  if (null != mIC) {
    mIC.setComposingRegion(start,end);
  }
}

Fixed version (ground truth):
public void setComposingRegion(final int start,final int end){
  if (DEBUG_BATCH_NESTING)   checkBatchEdit();
  if (DEBUG_PREVIOUS_TEXT)   checkConsistencyForDebug();
  final CharSequence textBeforeCursor=getTextBeforeCursor(DEFAULT_TEXT_CACHE_SIZE + (end - start),0);
  mCommittedTextBeforeComposingText.setLength(0);
  if (!TextUtils.isEmpty(textBeforeCursor)) {
    final int indexOfStartOfComposingText=Math.max(textBeforeCursor.length() - (end - start),0);
    mComposingText.append(textBeforeCursor.subSequence(indexOfStartOfComposingText,textBeforeCursor.length()));
    mCommittedTextBeforeComposingText.append(textBeforeCursor.subSequence(0,indexOfStartOfComposingText));
  }
  if (null != mIC) {
    mIC.setComposingRegion(start,end);
  }
}
Program: 87635
Project: 87635
Buggy source:
public void setComposingRegion(final int start,final int end){
  if (DEBUG_BATCH_NESTING)   checkBatchEdit();
  if (DEBUG_PREVIOUS_TEXT)   checkConsistencyForDebug();
  mCurrentCursorPosition=end;
  final CharSequence textBeforeCursor=getTextBeforeCursor(DEFAULT_TEXT_CACHE_SIZE + (end - start),0);
  mCommittedTextBeforeComposingText.setLength(0);
  if (!TextUtils.isEmpty(textBeforeCursor)) {
    final int indexOfStartOfComposingText=Math.max(textBeforeCursor.length() - (end - start),0);
    mComposingText.append(textBeforeCursor.subSequence(indexOfStartOfComposingText,textBeforeCursor.length()));
    mCommittedTextBeforeComposingText.append(textBeforeCursor.subSequence(0,indexOfStartOfComposingText));
  }
  if (null != mIC) {
    mIC.setComposingRegion(start,end);
  }
}

Fixed version (ground truth):
public void setComposingRegion(final int start,final int end){
  if (DEBUG_BATCH_NESTING)   checkBatchEdit();
  if (DEBUG_PREVIOUS_TEXT)   checkConsistencyForDebug();
  final CharSequence textBeforeCursor=getTextBeforeCursor(DEFAULT_TEXT_CACHE_SIZE + (end - start),0);
  mCommittedTextBeforeComposingText.setLength(0);
  if (!TextUtils.isEmpty(textBeforeCursor)) {
    final int indexOfStartOfComposingText=Math.max(textBeforeCursor.length() - (end - start),0);
    mComposingText.append(textBeforeCursor.subSequence(indexOfStartOfComposingText,textBeforeCursor.length()));
    mCommittedTextBeforeComposingText.append(textBeforeCursor.subSequence(0,indexOfStartOfComposingText));
  }
  if (null != mIC) {
    mIC.setComposingRegion(start,end);
  }
}
Program: 87641
Project: 87641
Buggy source:
public void setComposingRegion(final int start,final int end){
  if (DEBUG_BATCH_NESTING)   checkBatchEdit();
  if (DEBUG_PREVIOUS_TEXT)   checkConsistencyForDebug();
  mCurrentCursorPosition=end;
  final CharSequence textBeforeCursor=getTextBeforeCursor(DEFAULT_TEXT_CACHE_SIZE + (end - start),0);
  mCommittedTextBeforeComposingText.setLength(0);
  if (!TextUtils.isEmpty(textBeforeCursor)) {
    final int indexOfStartOfComposingText=Math.max(textBeforeCursor.length() - (end - start),0);
    mComposingText.append(textBeforeCursor.subSequence(indexOfStartOfComposingText,textBeforeCursor.length()));
    mCommittedTextBeforeComposingText.append(textBeforeCursor.subSequence(0,indexOfStartOfComposingText));
  }
  if (null != mIC) {
    mIC.setComposingRegion(start,end);
  }
}

Fixed version (ground truth):
public void setComposingRegion(final int start,final int end){
  if (DEBUG_BATCH_NESTING)   checkBatchEdit();
  if (DEBUG_PREVIOUS_TEXT)   checkConsistencyForDebug();
  final CharSequence textBeforeCursor=getTextBeforeCursor(DEFAULT_TEXT_CACHE_SIZE + (end - start),0);
  mCommittedTextBeforeComposingText.setLength(0);
  if (!TextUtils.isEmpty(textBeforeCursor)) {
    final int indexOfStartOfComposingText=Math.max(textBeforeCursor.length() - (end - start),0);
    mComposingText.append(textBeforeCursor.subSequence(indexOfStartOfComposingText,textBeforeCursor.length()));
    mCommittedTextBeforeComposingText.append(textBeforeCursor.subSequence(0,indexOfStartOfComposingText));
  }
  if (null != mIC) {
    mIC.setComposingRegion(start,end);
  }
}
Program: 87643
Project: 87643
Buggy source:
UserDictionaryAddWordContents(final View view,final Bundle args){
  mWordEditText=(EditText)view.findViewById(R.id.user_dictionary_add_word_text);
  mShortcutEditText=(EditText)view.findViewById(R.id.user_dictionary_add_shortcut);
  if (!UserDictionarySettings.IS_SHORTCUT_API_SUPPORTED) {
    mShortcutEditText.setVisibility(View.GONE);
    view.findViewById(R.id.user_dictionary_add_shortcut_label).setVisibility(View.GONE);
  }
  final String word=args.getString(EXTRA_WORD);
  if (null != word) {
    mWordEditText.setText(word);
    mWordEditText.setSelection(word.length());
  }
  final String shortcut;
  if (UserDictionarySettings.IS_SHORTCUT_API_SUPPORTED) {
    shortcut=args.getString(EXTRA_SHORTCUT);
    if (null != shortcut && null != mShortcutEditText) {
      mShortcutEditText.setText(shortcut);
    }
    mOldShortcut=args.getString(EXTRA_SHORTCUT);
  }
 else {
    shortcut=null;
    mOldShortcut=null;
  }
  mMode=args.getInt(EXTRA_MODE);
  mOldWord=args.getString(EXTRA_WORD);
  updateLocale(args.getString(EXTRA_LOCALE));
}

Fixed version (ground truth):
UserDictionaryAddWordContents(final View view,final Bundle args){
  mWordEditText=(EditText)view.findViewById(R.id.user_dictionary_add_word_text);
  mShortcutEditText=(EditText)view.findViewById(R.id.user_dictionary_add_shortcut);
  if (!UserDictionarySettings.IS_SHORTCUT_API_SUPPORTED) {
    mShortcutEditText.setVisibility(View.GONE);
    view.findViewById(R.id.user_dictionary_add_shortcut_label).setVisibility(View.GONE);
  }
  final String word=args.getString(EXTRA_WORD);
  if (null != word) {
    mWordEditText.setText(word);
    mWordEditText.setSelection(mWordEditText.getText().length());
  }
  final String shortcut;
  if (UserDictionarySettings.IS_SHORTCUT_API_SUPPORTED) {
    shortcut=args.getString(EXTRA_SHORTCUT);
    if (null != shortcut && null != mShortcutEditText) {
      mShortcutEditText.setText(shortcut);
    }
    mOldShortcut=args.getString(EXTRA_SHORTCUT);
  }
 else {
    shortcut=null;
    mOldShortcut=null;
  }
  mMode=args.getInt(EXTRA_MODE);
  mOldWord=args.getString(EXTRA_WORD);
  updateLocale(args.getString(EXTRA_LOCALE));
}
Program: 87644
Project: 87644
Buggy source:
UserDictionaryAddWordContents(final View view,final Bundle args){
  mWordEditText=(EditText)view.findViewById(R.id.user_dictionary_add_word_text);
  mShortcutEditText=(EditText)view.findViewById(R.id.user_dictionary_add_shortcut);
  if (!UserDictionarySettings.IS_SHORTCUT_API_SUPPORTED) {
    mShortcutEditText.setVisibility(View.GONE);
    view.findViewById(R.id.user_dictionary_add_shortcut_label).setVisibility(View.GONE);
  }
  final String word=args.getString(EXTRA_WORD);
  if (null != word) {
    mWordEditText.setText(word);
    mWordEditText.setSelection(word.length());
  }
  final String shortcut;
  if (UserDictionarySettings.IS_SHORTCUT_API_SUPPORTED) {
    shortcut=args.getString(EXTRA_SHORTCUT);
    if (null != shortcut && null != mShortcutEditText) {
      mShortcutEditText.setText(shortcut);
    }
    mOldShortcut=args.getString(EXTRA_SHORTCUT);
  }
 else {
    shortcut=null;
    mOldShortcut=null;
  }
  mMode=args.getInt(EXTRA_MODE);
  mOldWord=args.getString(EXTRA_WORD);
  updateLocale(args.getString(EXTRA_LOCALE));
}

Fixed version (ground truth):
UserDictionaryAddWordContents(final View view,final Bundle args){
  mWordEditText=(EditText)view.findViewById(R.id.user_dictionary_add_word_text);
  mShortcutEditText=(EditText)view.findViewById(R.id.user_dictionary_add_shortcut);
  if (!UserDictionarySettings.IS_SHORTCUT_API_SUPPORTED) {
    mShortcutEditText.setVisibility(View.GONE);
    view.findViewById(R.id.user_dictionary_add_shortcut_label).setVisibility(View.GONE);
  }
  final String word=args.getString(EXTRA_WORD);
  if (null != word) {
    mWordEditText.setText(word);
    mWordEditText.setSelection(mWordEditText.getText().length());
  }
  final String shortcut;
  if (UserDictionarySettings.IS_SHORTCUT_API_SUPPORTED) {
    shortcut=args.getString(EXTRA_SHORTCUT);
    if (null != shortcut && null != mShortcutEditText) {
      mShortcutEditText.setText(shortcut);
    }
    mOldShortcut=args.getString(EXTRA_SHORTCUT);
  }
 else {
    shortcut=null;
    mOldShortcut=null;
  }
  mMode=args.getInt(EXTRA_MODE);
  mOldWord=args.getString(EXTRA_WORD);
  updateLocale(args.getString(EXTRA_LOCALE));
}
Program: 87645
Project: 87645
Buggy source:
void stop(){
  if (DEBUG) {
    Log.d(TAG,"String_Node_Str");
  }
  commitCurrentLogUnit();
  try {
    mMainLogBuffer.shiftAndPublishAll();
  }
 catch (  final IOException e) {
    Log.w(TAG,"String_Node_Str",e);
  }
  logStatistics();
  commitCurrentLogUnit();
  mMainLogBuffer.setIsStopping();
  try {
    mMainLogBuffer.shiftAndPublishAll();
  }
 catch (  final IOException e) {
    Log.w(TAG,"String_Node_Str",e);
  }
  mMainResearchLog.blockingClose(RESEARCHLOG_CLOSE_TIMEOUT_IN_MS);
  resetLogBuffers();
}

Fixed version (ground truth):
void stop(){
  if (DEBUG) {
    Log.d(TAG,"String_Node_Str");
  }
  commitCurrentLogUnit();
  try {
    mMainLogBuffer.shiftAndPublishAll();
  }
 catch (  final IOException e) {
    Log.w(TAG,"String_Node_Str",e);
  }
  logStatistics();
  commitCurrentLogUnit();
  mMainLogBuffer.setIsStopping();
  try {
    mMainLogBuffer.shiftAndPublishAll();
  }
 catch (  final IOException e) {
    Log.w(TAG,"String_Node_Str",e);
  }
  mMainResearchLog.blockingClose(RESEARCHLOG_CLOSE_TIMEOUT_IN_MS);
  resetLogBuffers();
  cancelFeedbackDialog();
}
Program: 87646
Project: 87646
Buggy source:
public void initSuggest(final Suggest suggest){
  mSuggest=suggest;
  if (mMainLogBuffer != null) {
    stop();
    start();
  }
}

Fixed version (ground truth):
public void initSuggest(final Suggest suggest){
  mSuggest=suggest;
  if (mMainLogBuffer != null) {
    restart();
  }
}
Program: 87647
Project: 87647
Buggy source:
/** 
 * Remove leading/trailing whitespace from the considered string.
 */
public void trim(){
  final int len=mStringBefore.length();
  int nonWhitespaceStart=0;
  for (; nonWhitespaceStart < len; nonWhitespaceStart=mStringBefore.offsetByCodePoints(nonWhitespaceStart,1)) {
    final int codePoint=mStringBefore.codePointAt(nonWhitespaceStart);
    if (!Character.isWhitespace(codePoint))     break;
  }
  int nonWhitespaceEnd=len;
  for (; nonWhitespaceEnd > 0; nonWhitespaceEnd=mStringBefore.offsetByCodePoints(nonWhitespaceEnd,-1)) {
    final int codePoint=mStringBefore.codePointBefore(nonWhitespaceEnd);
    if (!Character.isWhitespace(codePoint))     break;
  }
  if (0 != nonWhitespaceStart || len != nonWhitespaceEnd) {
    mCursorEndAfter=mCursorStartBefore + nonWhitespaceEnd;
    mCursorStartBefore=mCursorStartAfter=mCursorStartBefore + nonWhitespaceStart;
    mStringAfter=mStringBefore=mStringBefore.substring(nonWhitespaceStart,nonWhitespaceEnd);
  }
}

Fixed version (ground truth):
/** 
 * Remove leading/trailing whitespace from the considered string.
 */
public void trim(){
  final int len=mStringBefore.length();
  int nonWhitespaceStart=0;
  for (; nonWhitespaceStart < len; nonWhitespaceStart=mStringBefore.offsetByCodePoints(nonWhitespaceStart,1)) {
    final int codePoint=mStringBefore.codePointAt(nonWhitespaceStart);
    if (!Character.isWhitespace(codePoint))     break;
  }
  int nonWhitespaceEnd=len;
  for (; nonWhitespaceEnd > 0; nonWhitespaceEnd=mStringBefore.offsetByCodePoints(nonWhitespaceEnd,-1)) {
    final int codePoint=mStringBefore.codePointBefore(nonWhitespaceEnd);
    if (!Character.isWhitespace(codePoint))     break;
  }
  if ((0 != nonWhitespaceStart || len != nonWhitespaceEnd) && nonWhitespaceStart < nonWhitespaceEnd) {
    mCursorEndAfter=mCursorStartBefore + nonWhitespaceEnd;
    mCursorStartBefore=mCursorStartAfter=mCursorStartBefore + nonWhitespaceStart;
    mStringAfter=mStringBefore=mStringBefore.substring(nonWhitespaceStart,nonWhitespaceEnd);
  }
}
Program: 87648
Project: 87648
Buggy source:
UserDictionaryAddWordContents(final View view,final Bundle args){
  mWordEditText=(EditText)view.findViewById(R.id.user_dictionary_add_word_text);
  mShortcutEditText=(EditText)view.findViewById(R.id.user_dictionary_add_shortcut);
  if (!UserDictionarySettings.IS_SHORTCUT_API_SUPPORTED) {
    mShortcutEditText.setVisibility(View.GONE);
    view.findViewById(R.id.user_dictionary_add_shortcut_label).setVisibility(View.GONE);
  }
  final String word=args.getString(EXTRA_WORD);
  if (null != word) {
    mWordEditText.setText(word);
    mWordEditText.setSelection(word.length());
  }
  final String shortcut;
  if (UserDictionarySettings.IS_SHORTCUT_API_SUPPORTED) {
    shortcut=args.getString(EXTRA_SHORTCUT);
    if (null != shortcut && null != mShortcutEditText) {
      mShortcutEditText.setText(shortcut);
    }
    mOldShortcut=args.getString(EXTRA_SHORTCUT);
  }
 else {
    shortcut=null;
    mOldShortcut=null;
  }
  mMode=args.getInt(EXTRA_MODE);
  mOldWord=args.getString(EXTRA_WORD);
  updateLocale(args.getString(EXTRA_LOCALE));
}

Fixed version (ground truth):
UserDictionaryAddWordContents(final View view,final Bundle args){
  mWordEditText=(EditText)view.findViewById(R.id.user_dictionary_add_word_text);
  mShortcutEditText=(EditText)view.findViewById(R.id.user_dictionary_add_shortcut);
  if (!UserDictionarySettings.IS_SHORTCUT_API_SUPPORTED) {
    mShortcutEditText.setVisibility(View.GONE);
    view.findViewById(R.id.user_dictionary_add_shortcut_label).setVisibility(View.GONE);
  }
  final String word=args.getString(EXTRA_WORD);
  if (null != word) {
    mWordEditText.setText(word);
    mWordEditText.setSelection(mWordEditText.getText().length());
  }
  final String shortcut;
  if (UserDictionarySettings.IS_SHORTCUT_API_SUPPORTED) {
    shortcut=args.getString(EXTRA_SHORTCUT);
    if (null != shortcut && null != mShortcutEditText) {
      mShortcutEditText.setText(shortcut);
    }
    mOldShortcut=args.getString(EXTRA_SHORTCUT);
  }
 else {
    shortcut=null;
    mOldShortcut=null;
  }
  mMode=args.getInt(EXTRA_MODE);
  mOldWord=args.getString(EXTRA_WORD);
  updateLocale(args.getString(EXTRA_LOCALE));
}