nus-yam/ex-repair huggingface dataset:
Program: 87545
Project: 87545
Buggy source:
private void onRestoreKeyboardState(){
  final SavedKeyboardState state=mSavedKeyboardState;
  if (DEBUG_EVENT) {
    Log.d(TAG,"String_Node_Str" + state + "String_Node_Str"+ this);
  }
  if (!state.mIsValid || state.mIsAlphabetMode) {
    setAlphabetKeyboard();
  }
 else   if (state.mIsEmojiMode) {
    setEmojiKeyboard();
  }
 else {
    if (state.mShiftMode == MANUAL_SHIFT) {
      setSymbolsShiftedKeyboard();
    }
 else {
      setSymbolsKeyboard();
    }
  }
  if (!state.mIsValid)   return;
  state.mIsValid=false;
  if (state.mIsAlphabetMode) {
    setShiftLocked(state.mIsAlphabetShiftLocked);
    if (!state.mIsAlphabetShiftLocked) {
      setShifted(state.mShiftMode);
    }
  }
 else {
    mPrevMainKeyboardWasShiftLocked=state.mIsAlphabetShiftLocked;
  }
}

Fixed version (ground truth):
private void onRestoreKeyboardState(){
  final SavedKeyboardState state=mSavedKeyboardState;
  if (DEBUG_EVENT) {
    Log.d(TAG,"String_Node_Str" + state + "String_Node_Str"+ this);
  }
  if (!state.mIsValid || state.mIsAlphabetMode) {
    setAlphabetKeyboard();
  }
 else   if (state.mIsEmojiMode) {
    setEmojiKeyboard();
  }
 else {
    if (state.mShiftMode == MANUAL_SHIFT) {
      setSymbolsShiftedKeyboard();
    }
 else {
      setSymbolsKeyboard();
    }
  }
  if (!state.mIsValid)   return;
  state.mIsValid=false;
  if (state.mIsAlphabetMode) {
    setShiftLocked(state.mIsAlphabetShiftLocked);
    if (!state.mIsAlphabetShiftLocked) {
      setShifted(state.mShiftMode);
    }
    mSwitchActions.requestUpdatingShiftState();
  }
 else {
    mPrevMainKeyboardWasShiftLocked=state.mIsAlphabetShiftLocked;
  }
}
Program: 87546
Project: 87546
Buggy source:
/** 
 * Retry resetting caches in the rich input connection. When the editor can't be accessed we can't reset the caches, so we schedule a retry. This method handles the retry, and re-schedules a new retry if we still can't access. We only retry up to 5 times before giving up.
 * @param tryResumeSuggestions Whether we should resume suggestions or not.
 * @param remainingTries How many times we may try again before giving up.
 */
private void retryResetCaches(final boolean tryResumeSuggestions,final int remainingTries){
  if (!mConnection.resetCachesUponCursorMoveAndReturnSuccess(mLastSelectionStart,false)) {
    if (0 < remainingTries) {
      mHandler.postResetCaches(tryResumeSuggestions,remainingTries - 1);
    }
    return;
  }
  tryFixLyingCursorPosition();
  if (tryResumeSuggestions)   mHandler.postResumeSuggestions();
}

Fixed version (ground truth):
/** 
 * Retry resetting caches in the rich input connection. When the editor can't be accessed we can't reset the caches, so we schedule a retry. This method handles the retry, and re-schedules a new retry if we still can't access. We only retry up to 5 times before giving up.
 * @param tryResumeSuggestions Whether we should resume suggestions or not.
 * @param remainingTries How many times we may try again before giving up.
 */
private void retryResetCaches(final boolean tryResumeSuggestions,final int remainingTries){
  if (!mConnection.resetCachesUponCursorMoveAndReturnSuccess(mLastSelectionStart,false)) {
    if (0 < remainingTries) {
      mHandler.postResetCaches(tryResumeSuggestions,remainingTries - 1);
    }
    return;
  }
  tryFixLyingCursorPosition();
  mKeyboardSwitcher.updateShiftState();
  if (tryResumeSuggestions)   mHandler.postResumeSuggestions();
}
Program: 87549
Project: 87549
Buggy source:
public BinaryDictDecoderEncoderTests(final long seed,final int maxUnigrams){
  super();
  Log.e(TAG,"String_Node_Str" + seed);
  final Random random=new Random(seed);
  sWords.clear();
  final int[] codePointSet=CodePointUtils.generateCodePointSet(DEFAULT_CODE_POINT_SET_SIZE,random);
  generateWords(maxUnigrams,random,codePointSet);
  for (int i=0; i < sWords.size(); ++i) {
    sChainBigrams.put(i,new ArrayList<Integer>());
    if (i > 0) {
      sChainBigrams.get(i - 1).add(i);
    }
  }
  sStarBigrams.put(0,new ArrayList<Integer>());
  for (int i=1; i < sWords.size(); ++i) {
    sStarBigrams.get(0).add(i);
  }
  sShortcuts.clear();
  for (int i=0; i < NUM_OF_NODES_HAVING_SHORTCUTS; ++i) {
    final int from=Math.abs(random.nextInt()) % sWords.size();
    sShortcuts.put(sWords.get(from),new ArrayList<String>());
    for (int j=0; j < NUM_OF_SHORTCUTS; ++j) {
      final int to=Math.abs(random.nextInt()) % sWords.size();
      sShortcuts.get(sWords.get(from)).add(sWords.get(to));
    }
  }
}

Fixed version (ground truth):
public BinaryDictDecoderEncoderTests(final long seed,final int maxUnigrams){
  super();
  Log.e(TAG,"String_Node_Str" + seed);
  final Random random=new Random(seed);
  sWords.clear();
  final int[] codePointSet=CodePointUtils.generateCodePointSet(DEFAULT_CODE_POINT_SET_SIZE,random);
  generateWords(maxUnigrams,random,codePointSet);
  for (int i=0; i < sWords.size(); ++i) {
    sChainBigrams.put(i,new ArrayList<Integer>());
    if (i > 0) {
      sChainBigrams.get(i - 1).add(i);
    }
  }
  sStarBigrams.put(0,new ArrayList<Integer>());
  final int maxBigrams=Math.min(sWords.size(),FormatSpec.MAX_BIGRAMS_IN_A_PTNODE - 1);
  for (int i=1; i < maxBigrams; ++i) {
    sStarBigrams.get(0).add(i);
  }
  sShortcuts.clear();
  for (int i=0; i < NUM_OF_NODES_HAVING_SHORTCUTS; ++i) {
    final int from=Math.abs(random.nextInt()) % sWords.size();
    sShortcuts.put(sWords.get(from),new ArrayList<String>());
    for (int j=0; j < NUM_OF_SHORTCUTS; ++j) {
      final int to=Math.abs(random.nextInt()) % sWords.size();
      sShortcuts.get(sWords.get(from)).add(sWords.get(to));
    }
  }
}
Program: 87550
Project: 87550
Buggy source:
private void updateBatchInput(final long eventTime){
synchronized (sAggregratedPointers) {
    final GestureStroke stroke=mGestureStrokeWithPreviewPoints;
    stroke.appendIncrementalBatchPoints(sAggregratedPointers);
    final int size=sAggregratedPointers.getPointerSize();
    if (size > sLastRecognitionPointSize && stroke.hasRecognitionTimePast(eventTime,sLastRecognitionTime)) {
      sLastRecognitionPointSize=size;
      sLastRecognitionTime=eventTime;
      if (DEBUG_LISTENER) {
        Log.d(TAG,String.format("String_Node_Str",mPointerId,size));
      }
      mTimerProxy.startUpdateBatchInputTimer(this);
      mListener.onUpdateBatchInput(sAggregratedPointers);
    }
  }
}

Fixed version (ground truth):
private void updateBatchInput(final long eventTime){
synchronized (sAggregratedPointers) {
    final GestureStroke stroke=mGestureStrokeWithPreviewPoints;
    stroke.appendIncrementalBatchPoints(sAggregratedPointers);
    final int size=sAggregratedPointers.getPointerSize();
    if (size > sLastRecognitionPointSize && stroke.hasRecognitionTimePast(eventTime,sLastRecognitionTime)) {
      if (DEBUG_LISTENER) {
        Log.d(TAG,String.format("String_Node_Str",mPointerId,size));
      }
      mTimerProxy.startUpdateBatchInputTimer(this);
      mListener.onUpdateBatchInput(sAggregratedPointers);
      sLastRecognitionPointSize=sAggregratedPointers.getPointerSize();
      sLastRecognitionTime=eventTime;
    }
  }
}
Program: 87553
Project: 87553
Buggy source:
public BinaryDictDecoderEncoderTests(final long seed,final int maxUnigrams){
  super();
  Log.e(TAG,"String_Node_Str" + seed);
  final Random random=new Random(seed);
  sWords.clear();
  final int[] codePointSet=CodePointUtils.generateCodePointSet(DEFAULT_CODE_POINT_SET_SIZE,random);
  generateWords(maxUnigrams,random,codePointSet);
  for (int i=0; i < sWords.size(); ++i) {
    sChainBigrams.put(i,new ArrayList<Integer>());
    if (i > 0) {
      sChainBigrams.get(i - 1).add(i);
    }
  }
  sStarBigrams.put(0,new ArrayList<Integer>());
  for (int i=1; i < sWords.size(); ++i) {
    sStarBigrams.get(0).add(i);
  }
  sShortcuts.clear();
  for (int i=0; i < NUM_OF_NODES_HAVING_SHORTCUTS; ++i) {
    final int from=Math.abs(random.nextInt()) % sWords.size();
    sShortcuts.put(sWords.get(from),new ArrayList<String>());
    for (int j=0; j < NUM_OF_SHORTCUTS; ++j) {
      final int to=Math.abs(random.nextInt()) % sWords.size();
      sShortcuts.get(sWords.get(from)).add(sWords.get(to));
    }
  }
}

Fixed version (ground truth):
public BinaryDictDecoderEncoderTests(final long seed,final int maxUnigrams){
  super();
  Log.e(TAG,"String_Node_Str" + seed);
  final Random random=new Random(seed);
  sWords.clear();
  final int[] codePointSet=CodePointUtils.generateCodePointSet(DEFAULT_CODE_POINT_SET_SIZE,random);
  generateWords(maxUnigrams,random,codePointSet);
  for (int i=0; i < sWords.size(); ++i) {
    sChainBigrams.put(i,new ArrayList<Integer>());
    if (i > 0) {
      sChainBigrams.get(i - 1).add(i);
    }
  }
  sStarBigrams.put(0,new ArrayList<Integer>());
  final int maxBigrams=Math.min(sWords.size(),FormatSpec.MAX_BIGRAMS_IN_A_PTNODE - 1);
  for (int i=1; i < maxBigrams; ++i) {
    sStarBigrams.get(0).add(i);
  }
  sShortcuts.clear();
  for (int i=0; i < NUM_OF_NODES_HAVING_SHORTCUTS; ++i) {
    final int from=Math.abs(random.nextInt()) % sWords.size();
    sShortcuts.put(sWords.get(from),new ArrayList<String>());
    for (int j=0; j < NUM_OF_SHORTCUTS; ++j) {
      final int to=Math.abs(random.nextInt()) % sWords.size();
      sShortcuts.get(sWords.get(from)).add(sWords.get(to));
    }
  }
}
Program: 87556
Project: 87556
Buggy source:
public BinaryDictDecoderEncoderTests(final long seed,final int maxUnigrams){
  super();
  Log.e(TAG,"String_Node_Str" + seed);
  final Random random=new Random(seed);
  sWords.clear();
  final int[] codePointSet=CodePointUtils.generateCodePointSet(DEFAULT_CODE_POINT_SET_SIZE,random);
  generateWords(maxUnigrams,random,codePointSet);
  for (int i=0; i < sWords.size(); ++i) {
    sChainBigrams.put(i,new ArrayList<Integer>());
    if (i > 0) {
      sChainBigrams.get(i - 1).add(i);
    }
  }
  sStarBigrams.put(0,new ArrayList<Integer>());
  for (int i=1; i < sWords.size(); ++i) {
    sStarBigrams.get(0).add(i);
  }
  sShortcuts.clear();
  for (int i=0; i < NUM_OF_NODES_HAVING_SHORTCUTS; ++i) {
    final int from=Math.abs(random.nextInt()) % sWords.size();
    sShortcuts.put(sWords.get(from),new ArrayList<String>());
    for (int j=0; j < NUM_OF_SHORTCUTS; ++j) {
      final int to=Math.abs(random.nextInt()) % sWords.size();
      sShortcuts.get(sWords.get(from)).add(sWords.get(to));
    }
  }
}

Fixed version (ground truth):
public BinaryDictDecoderEncoderTests(final long seed,final int maxUnigrams){
  super();
  Log.e(TAG,"String_Node_Str" + seed);
  final Random random=new Random(seed);
  sWords.clear();
  final int[] codePointSet=CodePointUtils.generateCodePointSet(DEFAULT_CODE_POINT_SET_SIZE,random);
  generateWords(maxUnigrams,random,codePointSet);
  for (int i=0; i < sWords.size(); ++i) {
    sChainBigrams.put(i,new ArrayList<Integer>());
    if (i > 0) {
      sChainBigrams.get(i - 1).add(i);
    }
  }
  sStarBigrams.put(0,new ArrayList<Integer>());
  final int maxBigrams=Math.min(sWords.size(),FormatSpec.MAX_BIGRAMS_IN_A_PTNODE - 1);
  for (int i=1; i < maxBigrams; ++i) {
    sStarBigrams.get(0).add(i);
  }
  sShortcuts.clear();
  for (int i=0; i < NUM_OF_NODES_HAVING_SHORTCUTS; ++i) {
    final int from=Math.abs(random.nextInt()) % sWords.size();
    sShortcuts.put(sWords.get(from),new ArrayList<String>());
    for (int j=0; j < NUM_OF_SHORTCUTS; ++j) {
      final int to=Math.abs(random.nextInt()) % sWords.size();
      sShortcuts.get(sWords.get(from)).add(sWords.get(to));
    }
  }
}
Program: 87557
Project: 87557
Buggy source:
private void updateBatchInput(final long eventTime){
synchronized (sAggregratedPointers) {
    final GestureStroke stroke=mGestureStrokeWithPreviewPoints;
    stroke.appendIncrementalBatchPoints(sAggregratedPointers);
    final int size=sAggregratedPointers.getPointerSize();
    if (size > sLastRecognitionPointSize && stroke.hasRecognitionTimePast(eventTime,sLastRecognitionTime)) {
      sLastRecognitionPointSize=size;
      sLastRecognitionTime=eventTime;
      if (DEBUG_LISTENER) {
        Log.d(TAG,String.format("String_Node_Str",mPointerId,size));
      }
      mTimerProxy.startUpdateBatchInputTimer(this);
      mListener.onUpdateBatchInput(sAggregratedPointers);
    }
  }
}

Fixed version (ground truth):
private void updateBatchInput(final long eventTime){
synchronized (sAggregratedPointers) {
    final GestureStroke stroke=mGestureStrokeWithPreviewPoints;
    stroke.appendIncrementalBatchPoints(sAggregratedPointers);
    final int size=sAggregratedPointers.getPointerSize();
    if (size > sLastRecognitionPointSize && stroke.hasRecognitionTimePast(eventTime,sLastRecognitionTime)) {
      if (DEBUG_LISTENER) {
        Log.d(TAG,String.format("String_Node_Str",mPointerId,size));
      }
      mTimerProxy.startUpdateBatchInputTimer(this);
      mListener.onUpdateBatchInput(sAggregratedPointers);
      sLastRecognitionPointSize=sAggregratedPointers.getPointerSize();
      sLastRecognitionTime=eventTime;
    }
  }
}
Program: 87558
Project: 87558
Buggy source:
private void updateBatchInput(final long eventTime){
synchronized (sAggregratedPointers) {
    final GestureStroke stroke=mGestureStrokeWithPreviewPoints;
    stroke.appendIncrementalBatchPoints(sAggregratedPointers);
    final int size=sAggregratedPointers.getPointerSize();
    if (size > sLastRecognitionPointSize && stroke.hasRecognitionTimePast(eventTime,sLastRecognitionTime)) {
      sLastRecognitionPointSize=size;
      sLastRecognitionTime=eventTime;
      if (DEBUG_LISTENER) {
        Log.d(TAG,String.format("String_Node_Str",mPointerId,size));
      }
      mTimerProxy.startUpdateBatchInputTimer(this);
      mListener.onUpdateBatchInput(sAggregratedPointers);
    }
  }
}

Fixed version (ground truth):
private void updateBatchInput(final long eventTime){
synchronized (sAggregratedPointers) {
    final GestureStroke stroke=mGestureStrokeWithPreviewPoints;
    stroke.appendIncrementalBatchPoints(sAggregratedPointers);
    final int size=sAggregratedPointers.getPointerSize();
    if (size > sLastRecognitionPointSize && stroke.hasRecognitionTimePast(eventTime,sLastRecognitionTime)) {
      if (DEBUG_LISTENER) {
        Log.d(TAG,String.format("String_Node_Str",mPointerId,size));
      }
      mTimerProxy.startUpdateBatchInputTimer(this);
      mListener.onUpdateBatchInput(sAggregratedPointers);
      sLastRecognitionPointSize=sAggregratedPointers.getPointerSize();
      sLastRecognitionTime=eventTime;
    }
  }
}
Program: 87567
Project: 87567
Buggy source:
public void finishComposingText(){
  if (DEBUG_BATCH_NESTING)   checkBatchEdit();
  if (DEBUG_PREVIOUS_TEXT)   checkConsistencyForDebug();
  mCommittedTextBeforeComposingText.append(mComposingText);
  mExpectedCursorPosition+=mComposingText.length();
  mComposingText.setLength(0);
  if (null != mIC) {
    mIC.finishComposingText();
    if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
      ResearchLogger.richInputConnection_finishComposingText();
    }
  }
}

Fixed version (ground truth):
public void finishComposingText(){
  if (DEBUG_BATCH_NESTING)   checkBatchEdit();
  if (DEBUG_PREVIOUS_TEXT)   checkConsistencyForDebug();
  mCommittedTextBeforeComposingText.append(mComposingText);
  mComposingText.setLength(0);
  if (null != mIC) {
    mIC.finishComposingText();
    if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
      ResearchLogger.richInputConnection_finishComposingText();
    }
  }
}
Program: 87568
Project: 87568
Buggy source:
public void finishComposingText(){
  if (DEBUG_BATCH_NESTING)   checkBatchEdit();
  if (DEBUG_PREVIOUS_TEXT)   checkConsistencyForDebug();
  mCommittedTextBeforeComposingText.append(mComposingText);
  mExpectedCursorPosition+=mComposingText.length();
  mComposingText.setLength(0);
  if (null != mIC) {
    mIC.finishComposingText();
    if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
      ResearchLogger.richInputConnection_finishComposingText();
    }
  }
}

Fixed version (ground truth):
public void finishComposingText(){
  if (DEBUG_BATCH_NESTING)   checkBatchEdit();
  if (DEBUG_PREVIOUS_TEXT)   checkConsistencyForDebug();
  mCommittedTextBeforeComposingText.append(mComposingText);
  mComposingText.setLength(0);
  if (null != mIC) {
    mIC.finishComposingText();
    if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
      ResearchLogger.richInputConnection_finishComposingText();
    }
  }
}
Program: 87569
Project: 87569
Buggy source:
public void finishComposingText(){
  if (DEBUG_BATCH_NESTING)   checkBatchEdit();
  if (DEBUG_PREVIOUS_TEXT)   checkConsistencyForDebug();
  mCommittedTextBeforeComposingText.append(mComposingText);
  mExpectedCursorPosition+=mComposingText.length();
  mComposingText.setLength(0);
  if (null != mIC) {
    mIC.finishComposingText();
    if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
      ResearchLogger.richInputConnection_finishComposingText();
    }
  }
}

Fixed version (ground truth):
public void finishComposingText(){
  if (DEBUG_BATCH_NESTING)   checkBatchEdit();
  if (DEBUG_PREVIOUS_TEXT)   checkConsistencyForDebug();
  mCommittedTextBeforeComposingText.append(mComposingText);
  mComposingText.setLength(0);
  if (null != mIC) {
    mIC.finishComposingText();
    if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
      ResearchLogger.richInputConnection_finishComposingText();
    }
  }
}
Program: 87570
Project: 87570
Buggy source:
private void addOrReplaceDictionaryInternal(final String key,final Dictionary dict){
  if (mOnlyDictionarySetForDebug != null && mOnlyDictionarySetForDebug.contains(key)) {
    Log.w(TAG,"String_Node_Str" + key + "String_Node_Str");
    return;
  }
  addOrReplaceDictionary(mDictionaries,key,dict);
}

Fixed version (ground truth):
private void addOrReplaceDictionaryInternal(final String key,final Dictionary dict){
  if (mOnlyDictionarySetForDebug != null && !mOnlyDictionarySetForDebug.contains(key)) {
    Log.w(TAG,"String_Node_Str" + key + "String_Node_Str");
    return;
  }
  addOrReplaceDictionary(mDictionaries,key,dict);
}
Program: 87571
Project: 87571
Buggy source:
private void addOrReplaceDictionaryInternal(final String key,final Dictionary dict){
  if (mOnlyDictionarySetForDebug != null && mOnlyDictionarySetForDebug.contains(key)) {
    Log.w(TAG,"String_Node_Str" + key + "String_Node_Str");
    return;
  }
  addOrReplaceDictionary(mDictionaries,key,dict);
}

Fixed version (ground truth):
private void addOrReplaceDictionaryInternal(final String key,final Dictionary dict){
  if (mOnlyDictionarySetForDebug != null && !mOnlyDictionarySetForDebug.contains(key)) {
    Log.w(TAG,"String_Node_Str" + key + "String_Node_Str");
    return;
  }
  addOrReplaceDictionary(mDictionaries,key,dict);
}
Program: 87572
Project: 87572
Buggy source:
private void addOrReplaceDictionaryInternal(final String key,final Dictionary dict){
  if (mOnlyDictionarySetForDebug != null && mOnlyDictionarySetForDebug.contains(key)) {
    Log.w(TAG,"String_Node_Str" + key + "String_Node_Str");
    return;
  }
  addOrReplaceDictionary(mDictionaries,key,dict);
}

Fixed version (ground truth):
private void addOrReplaceDictionaryInternal(final String key,final Dictionary dict){
  if (mOnlyDictionarySetForDebug != null && !mOnlyDictionarySetForDebug.contains(key)) {
    Log.w(TAG,"String_Node_Str" + key + "String_Node_Str");
    return;
  }
  addOrReplaceDictionary(mDictionaries,key,dict);
}
Program: 87576
Project: 87576
Buggy source:
public void loadSettings(final Locale locale,final InputAttributes inputAttributes){
  final SharedPreferences prefs=mPrefs;
  final RunInLocale<SettingsValues> job=new RunInLocale<SettingsValues>(){
    @Override protected SettingsValues job(    final Resources res){
      return new SettingsValues(prefs,locale,res,inputAttributes);
    }
  }
;
  mSettingsValues=job.runInLocale(mRes,locale);
}

Fixed version (ground truth):
public void loadSettings(final Locale locale,final InputAttributes inputAttributes){
  mSettingsValuesLock.lock();
  try {
    final SharedPreferences prefs=mPrefs;
    final RunInLocale<SettingsValues> job=new RunInLocale<SettingsValues>(){
      @Override protected SettingsValues job(      final Resources res){
        return new SettingsValues(prefs,locale,res,inputAttributes);
      }
    }
;
    mSettingsValues=job.runInLocale(mRes,locale);
  }
  finally {
    mSettingsValuesLock.unlock();
  }
}
Program: 87577
Project: 87577
Buggy source:
@Override public void onSharedPreferenceChanged(final SharedPreferences prefs,final String key){
  if (mSettingsValues == null) {
    Log.w(TAG,"String_Node_Str");
    return;
  }
  loadSettings(mSettingsValues.mLocale,mSettingsValues.mInputAttributes);
}

Fixed version (ground truth):
@Override public void onSharedPreferenceChanged(final SharedPreferences prefs,final String key){
  mSettingsValuesLock.lock();
  try {
    if (mSettingsValues == null) {
      Log.w(TAG,"String_Node_Str");
      return;
    }
    loadSettings(mSettingsValues.mLocale,mSettingsValues.mInputAttributes);
  }
  finally {
    mSettingsValuesLock.unlock();
  }
}
Program: 87578
Project: 87578
Buggy source:
public Builder setIsSpellChecker(final boolean isSpellChecker){
  mParams.mIsSpellChecker=true;
  return this;
}

Fixed version (ground truth):
public Builder setIsSpellChecker(final boolean isSpellChecker){
  mParams.mIsSpellChecker=isSpellChecker;
  return this;
}
Program: 87579
Project: 87579
Buggy source:
public Builder setIsSpellChecker(final boolean isSpellChecker){
  mParams.mIsSpellChecker=true;
  return this;
}

Fixed version (ground truth):
public Builder setIsSpellChecker(final boolean isSpellChecker){
  mParams.mIsSpellChecker=isSpellChecker;
  return this;
}
Program: 87580
Project: 87580
Buggy source:
public void loadSettings(final Locale locale,final InputAttributes inputAttributes){
  final SharedPreferences prefs=mPrefs;
  final RunInLocale<SettingsValues> job=new RunInLocale<SettingsValues>(){
    @Override protected SettingsValues job(    final Resources res){
      return new SettingsValues(prefs,locale,res,inputAttributes);
    }
  }
;
  mSettingsValues=job.runInLocale(mRes,locale);
}

Fixed version (ground truth):
public void loadSettings(final Locale locale,final InputAttributes inputAttributes){
  mSettingsValuesLock.lock();
  try {
    final SharedPreferences prefs=mPrefs;
    final RunInLocale<SettingsValues> job=new RunInLocale<SettingsValues>(){
      @Override protected SettingsValues job(      final Resources res){
        return new SettingsValues(prefs,locale,res,inputAttributes);
      }
    }
;
    mSettingsValues=job.runInLocale(mRes,locale);
  }
  finally {
    mSettingsValuesLock.unlock();
  }
}
Program: 87581
Project: 87581
Buggy source:
@Override public void onSharedPreferenceChanged(final SharedPreferences prefs,final String key){
  if (mSettingsValues == null) {
    Log.w(TAG,"String_Node_Str");
    return;
  }
  loadSettings(mSettingsValues.mLocale,mSettingsValues.mInputAttributes);
}

Fixed version (ground truth):
@Override public void onSharedPreferenceChanged(final SharedPreferences prefs,final String key){
  mSettingsValuesLock.lock();
  try {
    if (mSettingsValues == null) {
      Log.w(TAG,"String_Node_Str");
      return;
    }
    loadSettings(mSettingsValues.mLocale,mSettingsValues.mInputAttributes);
  }
  finally {
    mSettingsValuesLock.unlock();
  }
}
Program: 87582
Project: 87582
Buggy source:
public void loadSettings(final Locale locale,final InputAttributes inputAttributes){
  final SharedPreferences prefs=mPrefs;
  final RunInLocale<SettingsValues> job=new RunInLocale<SettingsValues>(){
    @Override protected SettingsValues job(    final Resources res){
      return new SettingsValues(prefs,locale,res,inputAttributes);
    }
  }
;
  mSettingsValues=job.runInLocale(mRes,locale);
}

Fixed version (ground truth):
public void loadSettings(final Locale locale,final InputAttributes inputAttributes){
  mSettingsValuesLock.lock();
  try {
    final SharedPreferences prefs=mPrefs;
    final RunInLocale<SettingsValues> job=new RunInLocale<SettingsValues>(){
      @Override protected SettingsValues job(      final Resources res){
        return new SettingsValues(prefs,locale,res,inputAttributes);
      }
    }
;
    mSettingsValues=job.runInLocale(mRes,locale);
  }
  finally {
    mSettingsValuesLock.unlock();
  }
}
Program: 87583
Project: 87583
Buggy source:
@Override public void onSharedPreferenceChanged(final SharedPreferences prefs,final String key){
  if (mSettingsValues == null) {
    Log.w(TAG,"String_Node_Str");
    return;
  }
  loadSettings(mSettingsValues.mLocale,mSettingsValues.mInputAttributes);
}

Fixed version (ground truth):
@Override public void onSharedPreferenceChanged(final SharedPreferences prefs,final String key){
  mSettingsValuesLock.lock();
  try {
    if (mSettingsValues == null) {
      Log.w(TAG,"String_Node_Str");
      return;
    }
    loadSettings(mSettingsValues.mLocale,mSettingsValues.mInputAttributes);
  }
  finally {
    mSettingsValuesLock.unlock();
  }
}
Program: 87584
Project: 87584
Buggy source:
public Builder setIsSpellChecker(final boolean isSpellChecker){
  mParams.mIsSpellChecker=true;
  return this;
}

Fixed version (ground truth):
public Builder setIsSpellChecker(final boolean isSpellChecker){
  mParams.mIsSpellChecker=isSpellChecker;
  return this;
}
Program: 87588
Project: 87588
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(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));
}

Fixed version (ground truth):
UserDictionaryAddWordContents(final View view,final UserDictionaryAddWordContents oldInstanceToBeEdited){
  mWordEditText=(EditText)view.findViewById(R.id.user_dictionary_add_word_text);
  mShortcutEditText=(EditText)view.findViewById(R.id.user_dictionary_add_shortcut);
  mMode=MODE_EDIT;
  mOldWord=oldInstanceToBeEdited.mSavedWord;
  mOldShortcut=oldInstanceToBeEdited.mSavedShortcut;
  updateLocale(mLocale);
}
Program: 87589
Project: 87589
Buggy source:
int apply(final Context context,final Bundle outParameters){
  if (null != outParameters)   saveStateIntoBundle(outParameters);
  final ContentResolver resolver=context.getContentResolver();
  if (MODE_EDIT == mMode && !TextUtils.isEmpty(mOldWord)) {
    UserDictionarySettings.deleteWord(mOldWord,mOldShortcut,resolver);
  }
  final String newWord=mWordEditText.getText().toString();
  final String newShortcut;
  if (!UserDictionarySettings.IS_SHORTCUT_API_SUPPORTED) {
    newShortcut=null;
  }
 else   if (null == mShortcutEditText) {
    newShortcut=null;
  }
 else {
    final String tmpShortcut=mShortcutEditText.getText().toString();
    if (TextUtils.isEmpty(tmpShortcut)) {
      newShortcut=null;
    }
 else {
      newShortcut=tmpShortcut;
    }
  }
  if (TextUtils.isEmpty(newWord)) {
    return CODE_CANCEL;
  }
  if (hasWord(newWord,context))   return CODE_ALREADY_PRESENT;
  UserDictionarySettings.deleteWord(newWord,null,resolver);
  if (!TextUtils.isEmpty(newShortcut)) {
    UserDictionarySettings.deleteWord(newWord,newShortcut,resolver);
  }
  UserDictionaryCompatUtils.addWord(context,newWord.toString(),FREQUENCY_FOR_USER_DICTIONARY_ADDS,newShortcut,TextUtils.isEmpty(mLocale) ? null : LocaleUtils.constructLocaleFromString(mLocale));
  return CODE_WORD_ADDED;
}

Fixed version (ground truth):
int apply(final Context context,final Bundle outParameters){
  if (null != outParameters)   saveStateIntoBundle(outParameters);
  final ContentResolver resolver=context.getContentResolver();
  if (MODE_EDIT == mMode && !TextUtils.isEmpty(mOldWord)) {
    UserDictionarySettings.deleteWord(mOldWord,mOldShortcut,resolver);
  }
  final String newWord=mWordEditText.getText().toString();
  final String newShortcut;
  if (!UserDictionarySettings.IS_SHORTCUT_API_SUPPORTED) {
    newShortcut=null;
  }
 else   if (null == mShortcutEditText) {
    newShortcut=null;
  }
 else {
    final String tmpShortcut=mShortcutEditText.getText().toString();
    if (TextUtils.isEmpty(tmpShortcut)) {
      newShortcut=null;
    }
 else {
      newShortcut=tmpShortcut;
    }
  }
  if (TextUtils.isEmpty(newWord)) {
    return CODE_CANCEL;
  }
  mSavedWord=newWord;
  mSavedShortcut=newShortcut;
  if (hasWord(newWord,context))   return CODE_ALREADY_PRESENT;
  UserDictionarySettings.deleteWord(newWord,null,resolver);
  if (!TextUtils.isEmpty(newShortcut)) {
    UserDictionarySettings.deleteWord(newWord,newShortcut,resolver);
  }
  UserDictionaryCompatUtils.addWord(context,newWord.toString(),FREQUENCY_FOR_USER_DICTIONARY_ADDS,newShortcut,TextUtils.isEmpty(mLocale) ? null : LocaleUtils.constructLocaleFromString(mLocale));
  return CODE_WORD_ADDED;
}
Program: 87590
Project: 87590
Buggy source:
@Override public void onActivityCreated(Bundle savedInstanceState){
  super.onActivityCreated(savedInstanceState);
  setHasOptionsMenu(true);
}

Fixed version (ground truth):
@Override public void onActivityCreated(final Bundle savedInstanceState){
  super.onActivityCreated(savedInstanceState);
  setHasOptionsMenu(true);
  setRetainInstance(true);
}
Program: 87591
Project: 87591
Buggy source:
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedState){
  mRootView=inflater.inflate(R.layout.user_dictionary_add_word_fullscreen,null);
  mIsDeleting=false;
  if (null == mContents) {
    mContents=new UserDictionaryAddWordContents(mRootView,getArguments());
  }
  return mRootView;
}

Fixed version (ground truth):
@Override public View onCreateView(final LayoutInflater inflater,final ViewGroup container,final Bundle savedState){
  mRootView=inflater.inflate(R.layout.user_dictionary_add_word_fullscreen,null);
  mIsDeleting=false;
  if (null == mContents) {
    mContents=new UserDictionaryAddWordContents(mRootView,getArguments());
  }
 else {
    mContents=new UserDictionaryAddWordContents(mRootView,mContents);
  }
  return mRootView;
}
Program: 87592
Project: 87592
Buggy source:
@Override public void onCreateOptionsMenu(Menu menu,MenuInflater inflater){
  final MenuItem actionItemAdd=menu.add(0,OPTIONS_MENU_ADD,0,R.string.user_dict_settings_add_menu_title).setIcon(R.drawable.ic_menu_add);
  actionItemAdd.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
  final MenuItem actionItemDelete=menu.add(0,OPTIONS_MENU_DELETE,0,R.string.user_dict_settings_delete).setIcon(android.R.drawable.ic_menu_delete);
  actionItemDelete.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
}

Fixed version (ground truth):
@Override public void onCreateOptionsMenu(final Menu menu,final MenuInflater inflater){
  final MenuItem actionItemAdd=menu.add(0,OPTIONS_MENU_ADD,0,R.string.user_dict_settings_add_menu_title).setIcon(R.drawable.ic_menu_add);
  actionItemAdd.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
  final MenuItem actionItemDelete=menu.add(0,OPTIONS_MENU_DELETE,0,R.string.user_dict_settings_delete).setIcon(android.R.drawable.ic_menu_delete);
  actionItemDelete.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
}
Program: 87593
Project: 87593
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(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));
}

Fixed version (ground truth):
UserDictionaryAddWordContents(final View view,final UserDictionaryAddWordContents oldInstanceToBeEdited){
  mWordEditText=(EditText)view.findViewById(R.id.user_dictionary_add_word_text);
  mShortcutEditText=(EditText)view.findViewById(R.id.user_dictionary_add_shortcut);
  mMode=MODE_EDIT;
  mOldWord=oldInstanceToBeEdited.mSavedWord;
  mOldShortcut=oldInstanceToBeEdited.mSavedShortcut;
  updateLocale(mLocale);
}
Program: 87594
Project: 87594
Buggy source:
int apply(final Context context,final Bundle outParameters){
  if (null != outParameters)   saveStateIntoBundle(outParameters);
  final ContentResolver resolver=context.getContentResolver();
  if (MODE_EDIT == mMode && !TextUtils.isEmpty(mOldWord)) {
    UserDictionarySettings.deleteWord(mOldWord,mOldShortcut,resolver);
  }
  final String newWord=mWordEditText.getText().toString();
  final String newShortcut;
  if (!UserDictionarySettings.IS_SHORTCUT_API_SUPPORTED) {
    newShortcut=null;
  }
 else   if (null == mShortcutEditText) {
    newShortcut=null;
  }
 else {
    final String tmpShortcut=mShortcutEditText.getText().toString();
    if (TextUtils.isEmpty(tmpShortcut)) {
      newShortcut=null;
    }
 else {
      newShortcut=tmpShortcut;
    }
  }
  if (TextUtils.isEmpty(newWord)) {
    return CODE_CANCEL;
  }
  if (hasWord(newWord,context))   return CODE_ALREADY_PRESENT;
  UserDictionarySettings.deleteWord(newWord,null,resolver);
  if (!TextUtils.isEmpty(newShortcut)) {
    UserDictionarySettings.deleteWord(newWord,newShortcut,resolver);
  }
  UserDictionaryCompatUtils.addWord(context,newWord.toString(),FREQUENCY_FOR_USER_DICTIONARY_ADDS,newShortcut,TextUtils.isEmpty(mLocale) ? null : LocaleUtils.constructLocaleFromString(mLocale));
  return CODE_WORD_ADDED;
}

Fixed version (ground truth):
int apply(final Context context,final Bundle outParameters){
  if (null != outParameters)   saveStateIntoBundle(outParameters);
  final ContentResolver resolver=context.getContentResolver();
  if (MODE_EDIT == mMode && !TextUtils.isEmpty(mOldWord)) {
    UserDictionarySettings.deleteWord(mOldWord,mOldShortcut,resolver);
  }
  final String newWord=mWordEditText.getText().toString();
  final String newShortcut;
  if (!UserDictionarySettings.IS_SHORTCUT_API_SUPPORTED) {
    newShortcut=null;
  }
 else   if (null == mShortcutEditText) {
    newShortcut=null;
  }
 else {
    final String tmpShortcut=mShortcutEditText.getText().toString();
    if (TextUtils.isEmpty(tmpShortcut)) {
      newShortcut=null;
    }
 else {
      newShortcut=tmpShortcut;
    }
  }
  if (TextUtils.isEmpty(newWord)) {
    return CODE_CANCEL;
  }
  mSavedWord=newWord;
  mSavedShortcut=newShortcut;
  if (hasWord(newWord,context))   return CODE_ALREADY_PRESENT;
  UserDictionarySettings.deleteWord(newWord,null,resolver);
  if (!TextUtils.isEmpty(newShortcut)) {
    UserDictionarySettings.deleteWord(newWord,newShortcut,resolver);
  }
  UserDictionaryCompatUtils.addWord(context,newWord.toString(),FREQUENCY_FOR_USER_DICTIONARY_ADDS,newShortcut,TextUtils.isEmpty(mLocale) ? null : LocaleUtils.constructLocaleFromString(mLocale));
  return CODE_WORD_ADDED;
}
Program: 87595
Project: 87595
Buggy source:
@Override public void onActivityCreated(Bundle savedInstanceState){
  super.onActivityCreated(savedInstanceState);
  setHasOptionsMenu(true);
}

Fixed version (ground truth):
@Override public void onActivityCreated(final Bundle savedInstanceState){
  super.onActivityCreated(savedInstanceState);
  setHasOptionsMenu(true);
  setRetainInstance(true);
}
Program: 87596
Project: 87596
Buggy source:
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedState){
  mRootView=inflater.inflate(R.layout.user_dictionary_add_word_fullscreen,null);
  mIsDeleting=false;
  if (null == mContents) {
    mContents=new UserDictionaryAddWordContents(mRootView,getArguments());
  }
  return mRootView;
}

Fixed version (ground truth):
@Override public View onCreateView(final LayoutInflater inflater,final ViewGroup container,final Bundle savedState){
  mRootView=inflater.inflate(R.layout.user_dictionary_add_word_fullscreen,null);
  mIsDeleting=false;
  if (null == mContents) {
    mContents=new UserDictionaryAddWordContents(mRootView,getArguments());
  }
 else {
    mContents=new UserDictionaryAddWordContents(mRootView,mContents);
  }
  return mRootView;
}
Program: 87597
Project: 87597
Buggy source:
@Override public void onCreateOptionsMenu(Menu menu,MenuInflater inflater){
  final MenuItem actionItemAdd=menu.add(0,OPTIONS_MENU_ADD,0,R.string.user_dict_settings_add_menu_title).setIcon(R.drawable.ic_menu_add);
  actionItemAdd.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
  final MenuItem actionItemDelete=menu.add(0,OPTIONS_MENU_DELETE,0,R.string.user_dict_settings_delete).setIcon(android.R.drawable.ic_menu_delete);
  actionItemDelete.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
}

Fixed version (ground truth):
@Override public void onCreateOptionsMenu(final Menu menu,final MenuInflater inflater){
  final MenuItem actionItemAdd=menu.add(0,OPTIONS_MENU_ADD,0,R.string.user_dict_settings_add_menu_title).setIcon(R.drawable.ic_menu_add);
  actionItemAdd.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
  final MenuItem actionItemDelete=menu.add(0,OPTIONS_MENU_DELETE,0,R.string.user_dict_settings_delete).setIcon(android.R.drawable.ic_menu_delete);
  actionItemDelete.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
}
Program: 87598
Project: 87598
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(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));
}

Fixed version (ground truth):
UserDictionaryAddWordContents(final View view,final UserDictionaryAddWordContents oldInstanceToBeEdited){
  mWordEditText=(EditText)view.findViewById(R.id.user_dictionary_add_word_text);
  mShortcutEditText=(EditText)view.findViewById(R.id.user_dictionary_add_shortcut);
  mMode=MODE_EDIT;
  mOldWord=oldInstanceToBeEdited.mSavedWord;
  mOldShortcut=oldInstanceToBeEdited.mSavedShortcut;
  updateLocale(mLocale);
}
Program: 87599
Project: 87599
Buggy source:
int apply(final Context context,final Bundle outParameters){
  if (null != outParameters)   saveStateIntoBundle(outParameters);
  final ContentResolver resolver=context.getContentResolver();
  if (MODE_EDIT == mMode && !TextUtils.isEmpty(mOldWord)) {
    UserDictionarySettings.deleteWord(mOldWord,mOldShortcut,resolver);
  }
  final String newWord=mWordEditText.getText().toString();
  final String newShortcut;
  if (!UserDictionarySettings.IS_SHORTCUT_API_SUPPORTED) {
    newShortcut=null;
  }
 else   if (null == mShortcutEditText) {
    newShortcut=null;
  }
 else {
    final String tmpShortcut=mShortcutEditText.getText().toString();
    if (TextUtils.isEmpty(tmpShortcut)) {
      newShortcut=null;
    }
 else {
      newShortcut=tmpShortcut;
    }
  }
  if (TextUtils.isEmpty(newWord)) {
    return CODE_CANCEL;
  }
  if (hasWord(newWord,context))   return CODE_ALREADY_PRESENT;
  UserDictionarySettings.deleteWord(newWord,null,resolver);
  if (!TextUtils.isEmpty(newShortcut)) {
    UserDictionarySettings.deleteWord(newWord,newShortcut,resolver);
  }
  UserDictionaryCompatUtils.addWord(context,newWord.toString(),FREQUENCY_FOR_USER_DICTIONARY_ADDS,newShortcut,TextUtils.isEmpty(mLocale) ? null : LocaleUtils.constructLocaleFromString(mLocale));
  return CODE_WORD_ADDED;
}

Fixed version (ground truth):
int apply(final Context context,final Bundle outParameters){
  if (null != outParameters)   saveStateIntoBundle(outParameters);
  final ContentResolver resolver=context.getContentResolver();
  if (MODE_EDIT == mMode && !TextUtils.isEmpty(mOldWord)) {
    UserDictionarySettings.deleteWord(mOldWord,mOldShortcut,resolver);
  }
  final String newWord=mWordEditText.getText().toString();
  final String newShortcut;
  if (!UserDictionarySettings.IS_SHORTCUT_API_SUPPORTED) {
    newShortcut=null;
  }
 else   if (null == mShortcutEditText) {
    newShortcut=null;
  }
 else {
    final String tmpShortcut=mShortcutEditText.getText().toString();
    if (TextUtils.isEmpty(tmpShortcut)) {
      newShortcut=null;
    }
 else {
      newShortcut=tmpShortcut;
    }
  }
  if (TextUtils.isEmpty(newWord)) {
    return CODE_CANCEL;
  }
  mSavedWord=newWord;
  mSavedShortcut=newShortcut;
  if (hasWord(newWord,context))   return CODE_ALREADY_PRESENT;
  UserDictionarySettings.deleteWord(newWord,null,resolver);
  if (!TextUtils.isEmpty(newShortcut)) {
    UserDictionarySettings.deleteWord(newWord,newShortcut,resolver);
  }
  UserDictionaryCompatUtils.addWord(context,newWord.toString(),FREQUENCY_FOR_USER_DICTIONARY_ADDS,newShortcut,TextUtils.isEmpty(mLocale) ? null : LocaleUtils.constructLocaleFromString(mLocale));
  return CODE_WORD_ADDED;
}
Program: 87600
Project: 87600
Buggy source:
@Override public void onActivityCreated(Bundle savedInstanceState){
  super.onActivityCreated(savedInstanceState);
  setHasOptionsMenu(true);
}

Fixed version (ground truth):
@Override public void onActivityCreated(final Bundle savedInstanceState){
  super.onActivityCreated(savedInstanceState);
  setHasOptionsMenu(true);
  setRetainInstance(true);
}
Program: 87601
Project: 87601
Buggy source:
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedState){
  mRootView=inflater.inflate(R.layout.user_dictionary_add_word_fullscreen,null);
  mIsDeleting=false;
  if (null == mContents) {
    mContents=new UserDictionaryAddWordContents(mRootView,getArguments());
  }
  return mRootView;
}

Fixed version (ground truth):
@Override public View onCreateView(final LayoutInflater inflater,final ViewGroup container,final Bundle savedState){
  mRootView=inflater.inflate(R.layout.user_dictionary_add_word_fullscreen,null);
  mIsDeleting=false;
  if (null == mContents) {
    mContents=new UserDictionaryAddWordContents(mRootView,getArguments());
  }
 else {
    mContents=new UserDictionaryAddWordContents(mRootView,mContents);
  }
  return mRootView;
}
Program: 87602
Project: 87602
Buggy source:
@Override public void onCreateOptionsMenu(Menu menu,MenuInflater inflater){
  final MenuItem actionItemAdd=menu.add(0,OPTIONS_MENU_ADD,0,R.string.user_dict_settings_add_menu_title).setIcon(R.drawable.ic_menu_add);
  actionItemAdd.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
  final MenuItem actionItemDelete=menu.add(0,OPTIONS_MENU_DELETE,0,R.string.user_dict_settings_delete).setIcon(android.R.drawable.ic_menu_delete);
  actionItemDelete.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
}

Fixed version (ground truth):
@Override public void onCreateOptionsMenu(final Menu menu,final MenuInflater inflater){
  final MenuItem actionItemAdd=menu.add(0,OPTIONS_MENU_ADD,0,R.string.user_dict_settings_add_menu_title).setIcon(R.drawable.ic_menu_add);
  actionItemAdd.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
  final MenuItem actionItemDelete=menu.add(0,OPTIONS_MENU_DELETE,0,R.string.user_dict_settings_delete).setIcon(android.R.drawable.ic_menu_delete);
  actionItemDelete.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
}
Program: 87603
Project: 87603
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;
}