nus-yam/ex-repair huggingface dataset:
Program: 87890
Project: 87890
Buggy source:
@Override public void onTextInput(CharSequence text){
  mConnection.beginBatchEdit(getCurrentInputConnection());
  commitTyped(LastComposedWord.NOT_A_SEPARATOR);
  text=specificTldProcessingOnTextInput(text);
  if (SPACE_STATE_PHANTOM == mSpaceState) {
    sendKeyCodePoint(Keyboard.CODE_SPACE);
  }
  mConnection.commitText(text,1);
  if (ProductionFlag.IS_EXPERIMENTAL) {
    ResearchLogger.latinIME_commitText(text);
  }
  mConnection.endBatchEdit();
  mKeyboardSwitcher.updateShiftState();
  mKeyboardSwitcher.onCodeInput(Keyboard.CODE_OUTPUT_TEXT);
  mSpaceState=SPACE_STATE_NONE;
  mEnteredText=text;
  resetComposingState(true);
}

Fixed version (ground truth):
@Override public void onTextInput(CharSequence text){
  mConnection.beginBatchEdit();
  commitTyped(LastComposedWord.NOT_A_SEPARATOR);
  text=specificTldProcessingOnTextInput(text);
  if (SPACE_STATE_PHANTOM == mSpaceState) {
    sendKeyCodePoint(Keyboard.CODE_SPACE);
  }
  mConnection.commitText(text,1);
  if (ProductionFlag.IS_EXPERIMENTAL) {
    ResearchLogger.latinIME_commitText(text);
  }
  mConnection.endBatchEdit();
  mKeyboardSwitcher.updateShiftState();
  mKeyboardSwitcher.onCodeInput(Keyboard.CODE_OUTPUT_TEXT);
  mSpaceState=SPACE_STATE_NONE;
  mEnteredText=text;
  resetComposingState(true);
}
Program: 87892
Project: 87892
Buggy source:
@Override public void onConfigurationChanged(Configuration conf){
  mSubtypeSwitcher.onConfigurationChanged(conf);
  if (mDisplayOrientation != conf.orientation) {
    mDisplayOrientation=conf.orientation;
    mHandler.startOrientationChanging();
    mConnection.beginBatchEdit(getCurrentInputConnection());
    commitTyped(LastComposedWord.NOT_A_SEPARATOR);
    mConnection.finishComposingText();
    mConnection.endBatchEdit();
    if (isShowingOptionDialog())     mOptionsDialog.dismiss();
  }
  super.onConfigurationChanged(conf);
}

Fixed version (ground truth):
@Override public void onConfigurationChanged(Configuration conf){
  mSubtypeSwitcher.onConfigurationChanged(conf);
  if (mDisplayOrientation != conf.orientation) {
    mDisplayOrientation=conf.orientation;
    mHandler.startOrientationChanging();
    mConnection.beginBatchEdit();
    commitTyped(LastComposedWord.NOT_A_SEPARATOR);
    mConnection.finishComposingText();
    mConnection.endBatchEdit();
    if (isShowingOptionDialog())     mOptionsDialog.dismiss();
  }
  super.onConfigurationChanged(conf);
}
Program: 87894
Project: 87894
Buggy source:
private int getCursorPosition(){
  if (null == mIC)   return INVALID_CURSOR_POSITION;
  final ExtractedText extracted=mIC.getExtractedText(new ExtractedTextRequest(),0);
  if (extracted == null) {
    return INVALID_CURSOR_POSITION;
  }
  return extracted.startOffset + extracted.selectionStart;
}

Fixed version (ground truth):
private int getCursorPosition(){
  mIC=mParent.getCurrentInputConnection();
  if (null == mIC)   return INVALID_CURSOR_POSITION;
  final ExtractedText extracted=mIC.getExtractedText(new ExtractedTextRequest(),0);
  if (extracted == null) {
    return INVALID_CURSOR_POSITION;
  }
  return extracted.startOffset + extracted.selectionStart;
}
Program: 87895
Project: 87895
Buggy source:
public CharSequence getTextAfterCursor(final int i,final int j){
  if (null != mIC)   return mIC.getTextAfterCursor(i,j);
  return null;
}

Fixed version (ground truth):
public CharSequence getTextAfterCursor(final int i,final int j){
  mIC=mParent.getCurrentInputConnection();
  if (null != mIC)   return mIC.getTextAfterCursor(i,j);
  return null;
}
Program: 87896
Project: 87896
Buggy source:
public RichInputConnection(){
  mIC=null;
  mNestLevel=0;
}

Fixed version (ground truth):
public RichInputConnection(final InputMethodService parent){
  mParent=parent;
  mIC=null;
  mNestLevel=0;
}
Program: 87897
Project: 87897
Buggy source:
public CharSequence getTextBeforeCursor(final int i,final int j){
  if (null != mIC)   return mIC.getTextBeforeCursor(i,j);
  return null;
}

Fixed version (ground truth):
public CharSequence getTextBeforeCursor(final int i,final int j){
  mIC=mParent.getCurrentInputConnection();
  if (null != mIC)   return mIC.getTextBeforeCursor(i,j);
  return null;
}
Program: 87898
Project: 87898
Buggy source:
public void performEditorAction(final int actionId){
  if (null != mIC)   mIC.performEditorAction(actionId);
}

Fixed version (ground truth):
public void performEditorAction(final int actionId){
  mIC=mParent.getCurrentInputConnection();
  if (null != mIC)   mIC.performEditorAction(actionId);
}
Program: 87900
Project: 87900
Buggy source:
public void beginBatchEdit(final InputConnection newInputConnection){
  if (++mNestLevel == 1) {
    mIC=newInputConnection;
    if (null != mIC)     mIC.beginBatchEdit();
  }
 else {
    if (DBG) {
      throw new RuntimeException("String_Node_Str");
    }
 else {
      Log.e(TAG,"String_Node_Str" + mNestLevel);
    }
  }
}

Fixed version (ground truth):
public void beginBatchEdit(){
  if (++mNestLevel == 1) {
    mIC=mParent.getCurrentInputConnection();
    if (null != mIC)     mIC.beginBatchEdit();
  }
 else {
    if (DBG) {
      throw new RuntimeException("String_Node_Str");
    }
 else {
      Log.e(TAG,"String_Node_Str" + mNestLevel);
    }
  }
}
Program: 87901
Project: 87901
Buggy source:
public int getCursorCapsMode(final int inputType){
  if (null == mIC)   return Constants.TextUtils.CAP_MODE_OFF;
  return mIC.getCursorCapsMode(inputType);
}

Fixed version (ground truth):
public int getCursorCapsMode(final int inputType){
  mIC=mParent.getCurrentInputConnection();
  if (null == mIC)   return Constants.TextUtils.CAP_MODE_OFF;
  return mIC.getCursorCapsMode(inputType);
}
Program: 87903
Project: 87903
Buggy source:
@Override public void onTextInput(CharSequence text){
  mConnection.beginBatchEdit(getCurrentInputConnection());
  commitTyped(LastComposedWord.NOT_A_SEPARATOR);
  text=specificTldProcessingOnTextInput(text);
  if (SPACE_STATE_PHANTOM == mSpaceState) {
    sendKeyCodePoint(Keyboard.CODE_SPACE);
  }
  mConnection.commitText(text,1);
  if (ProductionFlag.IS_EXPERIMENTAL) {
    ResearchLogger.latinIME_commitText(text);
  }
  mConnection.endBatchEdit();
  mKeyboardSwitcher.updateShiftState();
  mKeyboardSwitcher.onCodeInput(Keyboard.CODE_OUTPUT_TEXT);
  mSpaceState=SPACE_STATE_NONE;
  mEnteredText=text;
  resetComposingState(true);
}

Fixed version (ground truth):
@Override public void onTextInput(CharSequence text){
  mConnection.beginBatchEdit();
  commitTyped(LastComposedWord.NOT_A_SEPARATOR);
  text=specificTldProcessingOnTextInput(text);
  if (SPACE_STATE_PHANTOM == mSpaceState) {
    sendKeyCodePoint(Keyboard.CODE_SPACE);
  }
  mConnection.commitText(text,1);
  if (ProductionFlag.IS_EXPERIMENTAL) {
    ResearchLogger.latinIME_commitText(text);
  }
  mConnection.endBatchEdit();
  mKeyboardSwitcher.updateShiftState();
  mKeyboardSwitcher.onCodeInput(Keyboard.CODE_OUTPUT_TEXT);
  mSpaceState=SPACE_STATE_NONE;
  mEnteredText=text;
  resetComposingState(true);
}
Program: 87905
Project: 87905
Buggy source:
@Override public void onConfigurationChanged(Configuration conf){
  mSubtypeSwitcher.onConfigurationChanged(conf);
  if (mDisplayOrientation != conf.orientation) {
    mDisplayOrientation=conf.orientation;
    mHandler.startOrientationChanging();
    mConnection.beginBatchEdit(getCurrentInputConnection());
    commitTyped(LastComposedWord.NOT_A_SEPARATOR);
    mConnection.finishComposingText();
    mConnection.endBatchEdit();
    if (isShowingOptionDialog())     mOptionsDialog.dismiss();
  }
  super.onConfigurationChanged(conf);
}

Fixed version (ground truth):
@Override public void onConfigurationChanged(Configuration conf){
  mSubtypeSwitcher.onConfigurationChanged(conf);
  if (mDisplayOrientation != conf.orientation) {
    mDisplayOrientation=conf.orientation;
    mHandler.startOrientationChanging();
    mConnection.beginBatchEdit();
    commitTyped(LastComposedWord.NOT_A_SEPARATOR);
    mConnection.finishComposingText();
    mConnection.endBatchEdit();
    if (isShowingOptionDialog())     mOptionsDialog.dismiss();
  }
  super.onConfigurationChanged(conf);
}
Program: 87907
Project: 87907
Buggy source:
private int getCursorPosition(){
  if (null == mIC)   return INVALID_CURSOR_POSITION;
  final ExtractedText extracted=mIC.getExtractedText(new ExtractedTextRequest(),0);
  if (extracted == null) {
    return INVALID_CURSOR_POSITION;
  }
  return extracted.startOffset + extracted.selectionStart;
}

Fixed version (ground truth):
private int getCursorPosition(){
  mIC=mParent.getCurrentInputConnection();
  if (null == mIC)   return INVALID_CURSOR_POSITION;
  final ExtractedText extracted=mIC.getExtractedText(new ExtractedTextRequest(),0);
  if (extracted == null) {
    return INVALID_CURSOR_POSITION;
  }
  return extracted.startOffset + extracted.selectionStart;
}
Program: 87908
Project: 87908
Buggy source:
public CharSequence getTextAfterCursor(final int i,final int j){
  if (null != mIC)   return mIC.getTextAfterCursor(i,j);
  return null;
}

Fixed version (ground truth):
public CharSequence getTextAfterCursor(final int i,final int j){
  mIC=mParent.getCurrentInputConnection();
  if (null != mIC)   return mIC.getTextAfterCursor(i,j);
  return null;
}
Program: 87909
Project: 87909
Buggy source:
public RichInputConnection(){
  mIC=null;
  mNestLevel=0;
}

Fixed version (ground truth):
public RichInputConnection(final InputMethodService parent){
  mParent=parent;
  mIC=null;
  mNestLevel=0;
}
Program: 87910
Project: 87910
Buggy source:
public CharSequence getTextBeforeCursor(final int i,final int j){
  if (null != mIC)   return mIC.getTextBeforeCursor(i,j);
  return null;
}

Fixed version (ground truth):
public CharSequence getTextBeforeCursor(final int i,final int j){
  mIC=mParent.getCurrentInputConnection();
  if (null != mIC)   return mIC.getTextBeforeCursor(i,j);
  return null;
}
Program: 87911
Project: 87911
Buggy source:
public void performEditorAction(final int actionId){
  if (null != mIC)   mIC.performEditorAction(actionId);
}

Fixed version (ground truth):
public void performEditorAction(final int actionId){
  mIC=mParent.getCurrentInputConnection();
  if (null != mIC)   mIC.performEditorAction(actionId);
}
Program: 87913
Project: 87913
Buggy source:
public void beginBatchEdit(final InputConnection newInputConnection){
  if (++mNestLevel == 1) {
    mIC=newInputConnection;
    if (null != mIC)     mIC.beginBatchEdit();
  }
 else {
    if (DBG) {
      throw new RuntimeException("String_Node_Str");
    }
 else {
      Log.e(TAG,"String_Node_Str" + mNestLevel);
    }
  }
}

Fixed version (ground truth):
public void beginBatchEdit(){
  if (++mNestLevel == 1) {
    mIC=mParent.getCurrentInputConnection();
    if (null != mIC)     mIC.beginBatchEdit();
  }
 else {
    if (DBG) {
      throw new RuntimeException("String_Node_Str");
    }
 else {
      Log.e(TAG,"String_Node_Str" + mNestLevel);
    }
  }
}
Program: 87914
Project: 87914
Buggy source:
public int getCursorCapsMode(final int inputType){
  if (null == mIC)   return Constants.TextUtils.CAP_MODE_OFF;
  return mIC.getCursorCapsMode(inputType);
}

Fixed version (ground truth):
public int getCursorCapsMode(final int inputType){
  mIC=mParent.getCurrentInputConnection();
  if (null == mIC)   return Constants.TextUtils.CAP_MODE_OFF;
  return mIC.getCursorCapsMode(inputType);
}
Program: 87916
Project: 87916
Buggy source:
public UserBinaryDictionary(final Context context,final String locale,final boolean alsoUseMoreRestrictiveLocales){
  super(context,getFilenameWithLocale(NAME,locale),Dictionary.TYPE_USER);
  if (null == locale)   throw new NullPointerException();
  mLocale=locale;
  mAlsoUseMoreRestrictiveLocales=alsoUseMoreRestrictiveLocales;
  ContentResolver cres=context.getContentResolver();
  mObserver=new ContentObserver(null){
    @Override public void onChange(    boolean self){
      setRequiresReload(true);
    }
  }
;
  cres.registerContentObserver(Words.CONTENT_URI,true,mObserver);
  loadDictionary();
}

Fixed version (ground truth):
public UserBinaryDictionary(final Context context,final String locale,final boolean alsoUseMoreRestrictiveLocales){
  super(context,getFilenameWithLocale(NAME,locale),Dictionary.TYPE_USER);
  if (null == locale)   throw new NullPointerException();
  if (SubtypeLocale.NO_LANGUAGE.equals(locale)) {
    mLocale=USER_DICTIONARY_ALL_LANGUAGES;
  }
 else {
    mLocale=locale;
  }
  mAlsoUseMoreRestrictiveLocales=alsoUseMoreRestrictiveLocales;
  ContentResolver cres=context.getContentResolver();
  mObserver=new ContentObserver(null){
    @Override public void onChange(    boolean self){
      setRequiresReload(true);
    }
  }
;
  cres.registerContentObserver(Words.CONTENT_URI,true,mObserver);
  loadDictionary();
}
Program: 87919
Project: 87919
Buggy source:
public UserBinaryDictionary(final Context context,final String locale,final boolean alsoUseMoreRestrictiveLocales){
  super(context,getFilenameWithLocale(NAME,locale),Dictionary.TYPE_USER);
  if (null == locale)   throw new NullPointerException();
  mLocale=locale;
  mAlsoUseMoreRestrictiveLocales=alsoUseMoreRestrictiveLocales;
  ContentResolver cres=context.getContentResolver();
  mObserver=new ContentObserver(null){
    @Override public void onChange(    boolean self){
      setRequiresReload(true);
    }
  }
;
  cres.registerContentObserver(Words.CONTENT_URI,true,mObserver);
  loadDictionary();
}

Fixed version (ground truth):
public UserBinaryDictionary(final Context context,final String locale,final boolean alsoUseMoreRestrictiveLocales){
  super(context,getFilenameWithLocale(NAME,locale),Dictionary.TYPE_USER);
  if (null == locale)   throw new NullPointerException();
  if (SubtypeLocale.NO_LANGUAGE.equals(locale)) {
    mLocale=USER_DICTIONARY_ALL_LANGUAGES;
  }
 else {
    mLocale=locale;
  }
  mAlsoUseMoreRestrictiveLocales=alsoUseMoreRestrictiveLocales;
  ContentResolver cres=context.getContentResolver();
  mObserver=new ContentObserver(null){
    @Override public void onChange(    boolean self){
      setRequiresReload(true);
    }
  }
;
  cres.registerContentObserver(Words.CONTENT_URI,true,mObserver);
  loadDictionary();
}
Program: 87921
Project: 87921
Buggy source:
private static boolean shouldAutoCorrectToSelf(final ConcurrentHashMap<String,Dictionary> dictionaries,final WordComposer wordComposer,final SuggestedWordInfo suggestion,final CharSequence consideredWord){
  if (TextUtils.isEmpty(consideredWord))   return false;
  return wordComposer.size() > 1 && null != suggestion && !allowsToBeAutoCorrected(dictionaries,consideredWord,false);
}

Fixed version (ground truth):
private static boolean shouldAutoCorrectToSelf(final ConcurrentHashMap<String,Dictionary> dictionaries,final WordComposer wordComposer,final CharSequence consideredWord){
  if (TextUtils.isEmpty(consideredWord))   return false;
  return wordComposer.size() > 1 && !allowsToBeAutoCorrected(dictionaries,consideredWord,false);
}
Program: 87922
Project: 87922
Buggy source:
public static CharSequence computeAutoCorrectionWord(final ConcurrentHashMap<String,Dictionary> dictionaries,final WordComposer wordComposer,SuggestedWordInfo suggestion,final CharSequence consideredWord,final float autoCorrectionThreshold,final CharSequence whitelistedWord){
  if (hasAutoCorrectionForWhitelistedWord(whitelistedWord)) {
    return whitelistedWord;
  }
 else   if (shouldAutoCorrectToSelf(dictionaries,wordComposer,suggestion,consideredWord)) {
    return consideredWord;
  }
 else   if (hasAutoCorrectionForBinaryDictionary(wordComposer,suggestion,consideredWord,autoCorrectionThreshold)) {
    return suggestion.mWord;
  }
  return null;
}

Fixed version (ground truth):
public static CharSequence computeAutoCorrectionWord(final ConcurrentHashMap<String,Dictionary> dictionaries,final WordComposer wordComposer,SuggestedWordInfo suggestion,final CharSequence consideredWord,final float autoCorrectionThreshold,final CharSequence whitelistedWord){
  if (hasAutoCorrectionForWhitelistedWord(whitelistedWord)) {
    return whitelistedWord;
  }
 else   if (shouldAutoCorrectToSelf(dictionaries,wordComposer,consideredWord)) {
    return consideredWord;
  }
 else   if (hasAutoCorrectionForBinaryDictionary(wordComposer,suggestion,consideredWord,autoCorrectionThreshold)) {
    return suggestion.mWord;
  }
  return null;
}
Program: 87923
Project: 87923
Buggy source:
public boolean addWord(final SuggestedWordInfo wordInfo,final int dicTypeId,final int dataType,final ArrayList<SuggestedWordInfo> suggestions,final String consideredWord){
  int dataTypeForLog=dataType;
  final int prefMaxSuggestions=MAX_SUGGESTIONS;
  final CharSequence word=wordInfo.mWord;
  final int score=wordInfo.mScore;
  int pos=0;
  if (StringUtils.equalsIgnoreCase(consideredWord,word)) {
    if (suggestions.size() > 0) {
      final SuggestedWordInfo currentHighestWord=suggestions.get(0);
      if (StringUtils.equalsIgnoreCase(currentHighestWord.mWord,word) && score <= currentHighestWord.mScore) {
        pos=1;
      }
    }
  }
 else {
    if (suggestions.size() >= prefMaxSuggestions && suggestions.get(prefMaxSuggestions - 1).mScore >= score)     return true;
    final int length=wordInfo.mCodePointCount;
    while (pos < suggestions.size()) {
      final int curScore=suggestions.get(pos).mScore;
      if (curScore < score || (curScore == score && length < suggestions.get(pos).mCodePointCount)) {
        break;
      }
      pos++;
    }
  }
  if (pos >= prefMaxSuggestions) {
    return true;
  }
  final SuggestedWordInfo transformedWordInfo=getTransformedSuggestedWordInfo(wordInfo,mLocale,mIsAllUpperCase,mIsFirstCharCapitalized,mTrailingSingleQuotesCount);
  suggestions.add(pos,transformedWordInfo);
  if (suggestions.size() > prefMaxSuggestions) {
    suggestions.remove(prefMaxSuggestions);
  }
 else {
    LatinImeLogger.onAddSuggestedWord(transformedWordInfo.mWord.toString(),dicTypeId,dataTypeForLog);
  }
  return true;
}

Fixed version (ground truth):
public boolean addWord(final SuggestedWordInfo wordInfo,final int dicTypeId,final int dataType,final ArrayList<SuggestedWordInfo> suggestions,final String consideredWord){
  int dataTypeForLog=dataType;
  final int prefMaxSuggestions=MAX_SUGGESTIONS;
  final CharSequence word=wordInfo.mWord;
  final int score=wordInfo.mScore;
  int pos=0;
  if (StringUtils.equalsIgnoreCase(consideredWord,word)) {
    if (suggestions.size() > 0) {
      final SuggestedWordInfo currentHighestWord=suggestions.get(0);
      if (StringUtils.equalsIgnoreCase(currentHighestWord.mWord,word) && score <= currentHighestWord.mScore) {
        pos=1;
      }
    }
  }
 else {
    if (suggestions.size() >= prefMaxSuggestions && suggestions.get(prefMaxSuggestions - 1).mScore >= score)     return true;
    final int length=wordInfo.mCodePointCount;
    while (pos < suggestions.size()) {
      final int curScore=suggestions.get(pos).mScore;
      if (curScore < score || (curScore == score && length < suggestions.get(pos).mCodePointCount)) {
        break;
      }
      pos++;
    }
  }
  if (pos >= prefMaxSuggestions) {
    return true;
  }
  final SuggestedWordInfo transformedWordInfo=getTransformedSuggestedWordInfo(wordInfo,mLocale,mIsAllUpperCase,mIsFirstCharCapitalized,mTrailingSingleQuotesCount);
  suggestions.add(pos,transformedWordInfo);
  if (suggestions.size() > prefMaxSuggestions) {
    suggestions.remove(prefMaxSuggestions);
  }
  LatinImeLogger.onAddSuggestedWord(transformedWordInfo.mWord.toString(),dicTypeId,dataTypeForLog);
  return true;
}
Program: 87924
Project: 87924
Buggy source:
public CharSequence getWordBeforeCursorIfAtEndOfWord(final SettingsValues settings){
  final CharSequence textBeforeCursor=getTextBeforeCursor(1,0);
  if (TextUtils.isEmpty(textBeforeCursor) || settings.isWordSeparator(textBeforeCursor.charAt(0)))   return null;
  final CharSequence textAfterCursor=getTextAfterCursor(1,0);
  if (!TextUtils.isEmpty(textAfterCursor) && !settings.isWordSeparator(textAfterCursor.charAt(0)))   return null;
  CharSequence word=getWordAtCursor(settings.mWordSeparators);
  while (!TextUtils.isEmpty(word) && Keyboard.CODE_SINGLE_QUOTE == word.charAt(0)) {
    word=word.subSequence(1,word.length());
  }
  if (TextUtils.isEmpty(word))   return null;
  final char firstChar=word.charAt(0);
  if (word.length() == 1 && !Character.isLetter(firstChar))   return null;
  if (!(Character.isLetter(firstChar) || settings.isSymbolExcludedFromWordSeparators(firstChar))) {
    return null;
  }
  return word;
}

Fixed version (ground truth):
public CharSequence getWordBeforeCursorIfAtEndOfWord(final SettingsValues settings){
  final CharSequence textAfterCursor=getTextAfterCursor(1,0);
  if (!TextUtils.isEmpty(textAfterCursor) && !settings.isWordSeparator(textAfterCursor.charAt(0)))   return null;
  CharSequence word=getWordAtCursor(settings.mWordSeparators);
  while (!TextUtils.isEmpty(word) && Keyboard.CODE_SINGLE_QUOTE == word.charAt(0)) {
    word=word.subSequence(1,word.length());
  }
  if (TextUtils.isEmpty(word))   return null;
  final int lastCodePoint=Character.codePointBefore(word,word.length());
  if (!Character.isDefined(lastCodePoint))   return null;
  if (settings.isWordSeparator(lastCodePoint))   return null;
  final char firstChar=word.charAt(0);
  if (word.length() == 1 && !Character.isLetter(firstChar))   return null;
  if (!(Character.isLetter(firstChar) || settings.isSymbolExcludedFromWordSeparators(firstChar))) {
    return null;
  }
  return word;
}
Program: 87925
Project: 87925
Buggy source:
public CharSequence getWordBeforeCursorIfAtEndOfWord(final SettingsValues settings){
  final CharSequence textBeforeCursor=getTextBeforeCursor(1,0);
  if (TextUtils.isEmpty(textBeforeCursor) || settings.isWordSeparator(textBeforeCursor.charAt(0)))   return null;
  final CharSequence textAfterCursor=getTextAfterCursor(1,0);
  if (!TextUtils.isEmpty(textAfterCursor) && !settings.isWordSeparator(textAfterCursor.charAt(0)))   return null;
  CharSequence word=getWordAtCursor(settings.mWordSeparators);
  while (!TextUtils.isEmpty(word) && Keyboard.CODE_SINGLE_QUOTE == word.charAt(0)) {
    word=word.subSequence(1,word.length());
  }
  if (TextUtils.isEmpty(word))   return null;
  final char firstChar=word.charAt(0);
  if (word.length() == 1 && !Character.isLetter(firstChar))   return null;
  if (!(Character.isLetter(firstChar) || settings.isSymbolExcludedFromWordSeparators(firstChar))) {
    return null;
  }
  return word;
}

Fixed version (ground truth):
public CharSequence getWordBeforeCursorIfAtEndOfWord(final SettingsValues settings){
  final CharSequence textAfterCursor=getTextAfterCursor(1,0);
  if (!TextUtils.isEmpty(textAfterCursor) && !settings.isWordSeparator(textAfterCursor.charAt(0)))   return null;
  CharSequence word=getWordAtCursor(settings.mWordSeparators);
  while (!TextUtils.isEmpty(word) && Keyboard.CODE_SINGLE_QUOTE == word.charAt(0)) {
    word=word.subSequence(1,word.length());
  }
  if (TextUtils.isEmpty(word))   return null;
  final int lastCodePoint=Character.codePointBefore(word,word.length());
  if (!Character.isDefined(lastCodePoint))   return null;
  if (settings.isWordSeparator(lastCodePoint))   return null;
  final char firstChar=word.charAt(0);
  if (word.length() == 1 && !Character.isLetter(firstChar))   return null;
  if (!(Character.isLetter(firstChar) || settings.isSymbolExcludedFromWordSeparators(firstChar))) {
    return null;
  }
  return word;
}
Program: 87926
Project: 87926
Buggy source:
private CharSequence addToUserHistoryDictionary(final CharSequence suggestion){
  if (TextUtils.isEmpty(suggestion))   return null;
  if (!mCurrentSettings.mCorrectionEnabled)   return null;
  if (mUserHistoryDictionary != null) {
    final CharSequence prevWord=mConnection.getPreviousWord(mCurrentSettings.mWordSeparators);
    final String secondWord;
    if (mWordComposer.isAutoCapitalized() && !mWordComposer.isMostlyCaps()) {
      secondWord=suggestion.toString().toLowerCase(mSubtypeSwitcher.getCurrentSubtypeLocale());
    }
 else {
      secondWord=suggestion.toString();
    }
    final int maxFreq=AutoCorrection.getMaxFrequency(mSuggest.getUnigramDictionaries(),suggestion);
    if (maxFreq == 0)     return null;
    mUserHistoryDictionary.addToUserHistory(null == prevWord ? null : prevWord.toString(),secondWord,maxFreq > 0);
    return prevWord;
  }
  return null;
}

Fixed version (ground truth):
private CharSequence addToUserHistoryDictionary(final CharSequence suggestion){
  if (TextUtils.isEmpty(suggestion))   return null;
  if (!mCurrentSettings.mCorrectionEnabled)   return null;
  final UserHistoryDictionary userHistoryDictionary=mUserHistoryDictionary;
  if (userHistoryDictionary != null) {
    final CharSequence prevWord=mConnection.getPreviousWord(mCurrentSettings.mWordSeparators);
    final String secondWord;
    if (mWordComposer.isAutoCapitalized() && !mWordComposer.isMostlyCaps()) {
      secondWord=suggestion.toString().toLowerCase(mSubtypeSwitcher.getCurrentSubtypeLocale());
    }
 else {
      secondWord=suggestion.toString();
    }
    final int maxFreq=AutoCorrection.getMaxFrequency(mSuggest.getUnigramDictionaries(),suggestion);
    if (maxFreq == 0)     return null;
    userHistoryDictionary.addToUserHistory(null == prevWord ? null : prevWord.toString(),secondWord,maxFreq > 0);
    return prevWord;
  }
  return null;
}
Program: 87927
Project: 87927
Buggy source:
private CharSequence addToUserHistoryDictionary(final CharSequence suggestion){
  if (TextUtils.isEmpty(suggestion))   return null;
  if (!mCurrentSettings.isCorrectionOn())   return null;
  if (mUserHistoryDictionary != null) {
    final CharSequence prevWord=mConnection.getPreviousWord(mCurrentSettings.mWordSeparators);
    final String secondWord;
    if (mWordComposer.isAutoCapitalized() && !mWordComposer.isMostlyCaps()) {
      secondWord=suggestion.toString().toLowerCase(mSubtypeSwitcher.getCurrentSubtypeLocale());
    }
 else {
      secondWord=suggestion.toString();
    }
    final int maxFreq=AutoCorrection.getMaxFrequency(mSuggest.getUnigramDictionaries(),suggestion);
    if (maxFreq == 0)     return null;
    mUserHistoryDictionary.addToUserHistory(null == prevWord ? null : prevWord.toString(),secondWord,maxFreq > 0);
    return prevWord;
  }
  return null;
}

Fixed version (ground truth):
private CharSequence addToUserHistoryDictionary(final CharSequence suggestion){
  if (TextUtils.isEmpty(suggestion))   return null;
  if (!mCurrentSettings.isCorrectionOn())   return null;
  final UserHistoryDictionary userHistoryDictionary=mUserHistoryDictionary;
  if (userHistoryDictionary != null) {
    final CharSequence prevWord=mConnection.getPreviousWord(mCurrentSettings.mWordSeparators);
    final String secondWord;
    if (mWordComposer.isAutoCapitalized() && !mWordComposer.isMostlyCaps()) {
      secondWord=suggestion.toString().toLowerCase(mSubtypeSwitcher.getCurrentSubtypeLocale());
    }
 else {
      secondWord=suggestion.toString();
    }
    final int maxFreq=AutoCorrection.getMaxFrequency(mSuggest.getUnigramDictionaries(),suggestion);
    if (maxFreq == 0)     return null;
    userHistoryDictionary.addToUserHistory(null == prevWord ? null : prevWord.toString(),secondWord,maxFreq > 0);
    return prevWord;
  }
  return null;
}
Program: 87929
Project: 87929
Buggy source:
private void updateElapsedTime(long now){
  final int elapsedTimeCount=(int)((now - mLastTouchedTime) / ELAPSED_TIME_INTERVAL_MILLIS);
  if (elapsedTimeCount <= 0) {
    return;
  }
  for (int i=0; i < elapsedTimeCount; ++i) {
    mLastTouchedTime+=ELAPSED_TIME_INTERVAL_MILLIS;
    mFc=pushElapsedTime(mFc);
  }
}

Fixed version (ground truth):
private void updateElapsedTime(long now){
  final int elapsedTimeCount=(int)((now - mLastTouchedTime) / ELAPSED_TIME_INTERVAL_MILLIS);
  if (elapsedTimeCount <= 0) {
    return;
  }
  if (elapsedTimeCount >= MAX_PUSH_ELAPSED) {
    mLastTouchedTime=now;
    mFc=0;
    return;
  }
  for (int i=0; i < elapsedTimeCount; ++i) {
    mLastTouchedTime+=ELAPSED_TIME_INTERVAL_MILLIS;
    mFc=pushElapsedTime(mFc);
  }
}
Program: 87931
Project: 87931
Buggy source:
private void updateElapsedTime(long now){
  final int elapsedTimeCount=(int)((now - mLastTouchedTime) / ELAPSED_TIME_INTERVAL_MILLIS);
  if (elapsedTimeCount <= 0) {
    return;
  }
  for (int i=0; i < elapsedTimeCount; ++i) {
    mLastTouchedTime+=ELAPSED_TIME_INTERVAL_MILLIS;
    mFc=pushElapsedTime(mFc);
  }
}

Fixed version (ground truth):
private void updateElapsedTime(long now){
  final int elapsedTimeCount=(int)((now - mLastTouchedTime) / ELAPSED_TIME_INTERVAL_MILLIS);
  if (elapsedTimeCount <= 0) {
    return;
  }
  if (elapsedTimeCount >= MAX_PUSH_ELAPSED) {
    mLastTouchedTime=now;
    mFc=0;
    return;
  }
  for (int i=0; i < elapsedTimeCount; ++i) {
    mLastTouchedTime+=ELAPSED_TIME_INTERVAL_MILLIS;
    mFc=pushElapsedTime(mFc);
  }
}
Program: 87933
Project: 87933
Buggy source:
private void updateElapsedTime(long now){
  final int elapsedTimeCount=(int)((now - mLastTouchedTime) / ELAPSED_TIME_INTERVAL_MILLIS);
  if (elapsedTimeCount <= 0) {
    return;
  }
  for (int i=0; i < elapsedTimeCount; ++i) {
    mLastTouchedTime+=ELAPSED_TIME_INTERVAL_MILLIS;
    mFc=pushElapsedTime(mFc);
  }
}

Fixed version (ground truth):
private void updateElapsedTime(long now){
  final int elapsedTimeCount=(int)((now - mLastTouchedTime) / ELAPSED_TIME_INTERVAL_MILLIS);
  if (elapsedTimeCount <= 0) {
    return;
  }
  if (elapsedTimeCount >= MAX_PUSH_ELAPSED) {
    mLastTouchedTime=now;
    mFc=0;
    return;
  }
  for (int i=0; i < elapsedTimeCount; ++i) {
    mLastTouchedTime+=ELAPSED_TIME_INTERVAL_MILLIS;
    mFc=pushElapsedTime(mFc);
  }
}
Program: 87934
Project: 87934
Buggy source:
private void startUsingContactsDictionaryLocked(){
  if (null == mContactsDictionary) {
    mContactsDictionary=new SynchronouslyLoadedContactsDictionary(this);
  }
  final Iterator<WeakReference<DictionaryCollection>> iterator=mDictionaryCollectionsList.iterator();
  while (iterator.hasNext()) {
    final WeakReference<DictionaryCollection> dictRef=iterator.next();
    final DictionaryCollection dict=dictRef.get();
    if (null == dict) {
      iterator.remove();
    }
 else {
      dict.addDictionary(mContactsDictionary);
    }
  }
}

Fixed version (ground truth):
private void startUsingContactsDictionaryLocked(){
  if (null == mContactsDictionary) {
    if (LatinIME.USE_BINARY_CONTACTS_DICTIONARY) {
      mContactsDictionary=new SynchronouslyLoadedContactsBinaryDictionary(this);
    }
 else {
      mContactsDictionary=new SynchronouslyLoadedContactsDictionary(this);
    }
  }
  final Iterator<WeakReference<DictionaryCollection>> iterator=mDictionaryCollectionsList.iterator();
  while (iterator.hasNext()) {
    final WeakReference<DictionaryCollection> dictRef=iterator.next();
    final DictionaryCollection dict=dictRef.get();
    if (null == dict) {
      iterator.remove();
    }
 else {
      dict.addDictionary(mContactsDictionary);
    }
  }
}
Program: 87935
Project: 87935
Buggy source:
public SynchronouslyLoadedContactsBinaryDictionary(final Context context){
  super(context,Suggest.DIC_CONTACTS,null);
}

Fixed version (ground truth):
public SynchronouslyLoadedContactsBinaryDictionary(final Context context,final Locale locale){
  super(context,Suggest.DIC_CONTACTS,locale);
}
Program: 87937
Project: 87937
Buggy source:
private void startUsingContactsDictionaryLocked(){
  if (null == mContactsDictionary) {
    if (LatinIME.USE_BINARY_CONTACTS_DICTIONARY) {
      mContactsDictionary=new SynchronouslyLoadedContactsBinaryDictionary(this);
    }
 else {
      mContactsDictionary=new SynchronouslyLoadedContactsDictionary(this);
    }
  }
  final Iterator<WeakReference<DictionaryCollection>> iterator=mDictionaryCollectionsList.iterator();
  while (iterator.hasNext()) {
    final WeakReference<DictionaryCollection> dictRef=iterator.next();
    final DictionaryCollection dict=dictRef.get();
    if (null == dict) {
      iterator.remove();
    }
 else {
      dict.addDictionary(mContactsDictionary);
    }
  }
}

Fixed version (ground truth):
private void startUsingContactsDictionaryLocked(){
  if (null == mContactsDictionary) {
    if (LatinIME.USE_BINARY_CONTACTS_DICTIONARY) {
      mContactsDictionary=new SynchronouslyLoadedContactsBinaryDictionary(this,Locale.getDefault());
    }
 else {
      mContactsDictionary=new SynchronouslyLoadedContactsDictionary(this);
    }
  }
  final Iterator<WeakReference<DictionaryCollection>> iterator=mDictionaryCollectionsList.iterator();
  while (iterator.hasNext()) {
    final WeakReference<DictionaryCollection> dictRef=iterator.next();
    final DictionaryCollection dict=dictRef.get();
    if (null == dict) {
      iterator.remove();
    }
 else {
      dict.addDictionary(mContactsDictionary);
    }
  }
}
Program: 87938
Project: 87938
Buggy source:
private void startUsingContactsDictionaryLocked(){
  if (null == mContactsDictionary) {
    mContactsDictionary=new SynchronouslyLoadedContactsDictionary(this);
  }
  final Iterator<WeakReference<DictionaryCollection>> iterator=mDictionaryCollectionsList.iterator();
  while (iterator.hasNext()) {
    final WeakReference<DictionaryCollection> dictRef=iterator.next();
    final DictionaryCollection dict=dictRef.get();
    if (null == dict) {
      iterator.remove();
    }
 else {
      dict.addDictionary(mContactsDictionary);
    }
  }
}

Fixed version (ground truth):
private void startUsingContactsDictionaryLocked(){
  if (null == mContactsDictionary) {
    if (LatinIME.USE_BINARY_CONTACTS_DICTIONARY) {
      mContactsDictionary=new SynchronouslyLoadedContactsBinaryDictionary(this);
    }
 else {
      mContactsDictionary=new SynchronouslyLoadedContactsDictionary(this);
    }
  }
  final Iterator<WeakReference<DictionaryCollection>> iterator=mDictionaryCollectionsList.iterator();
  while (iterator.hasNext()) {
    final WeakReference<DictionaryCollection> dictRef=iterator.next();
    final DictionaryCollection dict=dictRef.get();
    if (null == dict) {
      iterator.remove();
    }
 else {
      dict.addDictionary(mContactsDictionary);
    }
  }
}
Program: 87939
Project: 87939
Buggy source:
public SynchronouslyLoadedContactsBinaryDictionary(final Context context){
  super(context,Suggest.DIC_CONTACTS,null);
}

Fixed version (ground truth):
public SynchronouslyLoadedContactsBinaryDictionary(final Context context,final Locale locale){
  super(context,Suggest.DIC_CONTACTS,locale);
}
Program: 87941
Project: 87941
Buggy source:
private void startUsingContactsDictionaryLocked(){
  if (null == mContactsDictionary) {
    if (LatinIME.USE_BINARY_CONTACTS_DICTIONARY) {
      mContactsDictionary=new SynchronouslyLoadedContactsBinaryDictionary(this);
    }
 else {
      mContactsDictionary=new SynchronouslyLoadedContactsDictionary(this);
    }
  }
  final Iterator<WeakReference<DictionaryCollection>> iterator=mDictionaryCollectionsList.iterator();
  while (iterator.hasNext()) {
    final WeakReference<DictionaryCollection> dictRef=iterator.next();
    final DictionaryCollection dict=dictRef.get();
    if (null == dict) {
      iterator.remove();
    }
 else {
      dict.addDictionary(mContactsDictionary);
    }
  }
}

Fixed version (ground truth):
private void startUsingContactsDictionaryLocked(){
  if (null == mContactsDictionary) {
    if (LatinIME.USE_BINARY_CONTACTS_DICTIONARY) {
      mContactsDictionary=new SynchronouslyLoadedContactsBinaryDictionary(this,Locale.getDefault());
    }
 else {
      mContactsDictionary=new SynchronouslyLoadedContactsDictionary(this);
    }
  }
  final Iterator<WeakReference<DictionaryCollection>> iterator=mDictionaryCollectionsList.iterator();
  while (iterator.hasNext()) {
    final WeakReference<DictionaryCollection> dictRef=iterator.next();
    final DictionaryCollection dict=dictRef.get();
    if (null == dict) {
      iterator.remove();
    }
 else {
      dict.addDictionary(mContactsDictionary);
    }
  }
}
Program: 87942
Project: 87942
Buggy source:
public SynchronouslyLoadedContactsBinaryDictionary(final Context context){
  super(context,Suggest.DIC_CONTACTS,null);
}

Fixed version (ground truth):
public SynchronouslyLoadedContactsBinaryDictionary(final Context context,final Locale locale){
  super(context,Suggest.DIC_CONTACTS,locale);
}
Program: 87944
Project: 87944
Buggy source:
private void startUsingContactsDictionaryLocked(){
  if (null == mContactsDictionary) {
    if (LatinIME.USE_BINARY_CONTACTS_DICTIONARY) {
      mContactsDictionary=new SynchronouslyLoadedContactsBinaryDictionary(this);
    }
 else {
      mContactsDictionary=new SynchronouslyLoadedContactsDictionary(this);
    }
  }
  final Iterator<WeakReference<DictionaryCollection>> iterator=mDictionaryCollectionsList.iterator();
  while (iterator.hasNext()) {
    final WeakReference<DictionaryCollection> dictRef=iterator.next();
    final DictionaryCollection dict=dictRef.get();
    if (null == dict) {
      iterator.remove();
    }
 else {
      dict.addDictionary(mContactsDictionary);
    }
  }
}

Fixed version (ground truth):
private void startUsingContactsDictionaryLocked(){
  if (null == mContactsDictionary) {
    if (LatinIME.USE_BINARY_CONTACTS_DICTIONARY) {
      mContactsDictionary=new SynchronouslyLoadedContactsBinaryDictionary(this,Locale.getDefault());
    }
 else {
      mContactsDictionary=new SynchronouslyLoadedContactsDictionary(this);
    }
  }
  final Iterator<WeakReference<DictionaryCollection>> iterator=mDictionaryCollectionsList.iterator();
  while (iterator.hasNext()) {
    final WeakReference<DictionaryCollection> dictRef=iterator.next();
    final DictionaryCollection dict=dictRef.get();
    if (null == dict) {
      iterator.remove();
    }
 else {
      dict.addDictionary(mContactsDictionary);
    }
  }
}
Program: 87945
Project: 87945
Buggy source:
private void startUsingContactsDictionaryLocked(){
  if (null == mContactsDictionary) {
    mContactsDictionary=new SynchronouslyLoadedContactsDictionary(this);
  }
  final Iterator<WeakReference<DictionaryCollection>> iterator=mDictionaryCollectionsList.iterator();
  while (iterator.hasNext()) {
    final WeakReference<DictionaryCollection> dictRef=iterator.next();
    final DictionaryCollection dict=dictRef.get();
    if (null == dict) {
      iterator.remove();
    }
 else {
      dict.addDictionary(mContactsDictionary);
    }
  }
}

Fixed version (ground truth):
private void startUsingContactsDictionaryLocked(){
  if (null == mContactsDictionary) {
    if (LatinIME.USE_BINARY_CONTACTS_DICTIONARY) {
      mContactsDictionary=new SynchronouslyLoadedContactsBinaryDictionary(this);
    }
 else {
      mContactsDictionary=new SynchronouslyLoadedContactsDictionary(this);
    }
  }
  final Iterator<WeakReference<DictionaryCollection>> iterator=mDictionaryCollectionsList.iterator();
  while (iterator.hasNext()) {
    final WeakReference<DictionaryCollection> dictRef=iterator.next();
    final DictionaryCollection dict=dictRef.get();
    if (null == dict) {
      iterator.remove();
    }
 else {
      dict.addDictionary(mContactsDictionary);
    }
  }
}
Program: 87946
Project: 87946
Buggy source:
private void startUsingContactsDictionaryLocked(){
  if (null == mContactsDictionary) {
    mContactsDictionary=new SynchronouslyLoadedContactsDictionary(this);
  }
  final Iterator<WeakReference<DictionaryCollection>> iterator=mDictionaryCollectionsList.iterator();
  while (iterator.hasNext()) {
    final WeakReference<DictionaryCollection> dictRef=iterator.next();
    final DictionaryCollection dict=dictRef.get();
    if (null == dict) {
      iterator.remove();
    }
 else {
      dict.addDictionary(mContactsDictionary);
    }
  }
}

Fixed version (ground truth):
private void startUsingContactsDictionaryLocked(){
  if (null == mContactsDictionary) {
    if (LatinIME.USE_BINARY_CONTACTS_DICTIONARY) {
      mContactsDictionary=new SynchronouslyLoadedContactsBinaryDictionary(this);
    }
 else {
      mContactsDictionary=new SynchronouslyLoadedContactsDictionary(this);
    }
  }
  final Iterator<WeakReference<DictionaryCollection>> iterator=mDictionaryCollectionsList.iterator();
  while (iterator.hasNext()) {
    final WeakReference<DictionaryCollection> dictRef=iterator.next();
    final DictionaryCollection dict=dictRef.get();
    if (null == dict) {
      iterator.remove();
    }
 else {
      dict.addDictionary(mContactsDictionary);
    }
  }
}
Program: 87947
Project: 87947
Buggy source:
@Override protected boolean hasContentChanged(){
  final long startTime=SystemClock.uptimeMillis();
  final int contactCount=getContactCount();
  if (contactCount > MAX_CONTACT_COUNT) {
    return false;
  }
  if (contactCount != sContactCountAtLastRebuild) {
    return true;
  }
  Cursor cursor=mContext.getContentResolver().query(Contacts.CONTENT_URI,PROJECTION,null,null,null);
  if (cursor != null) {
    try {
      if (cursor.moveToFirst()) {
        while (!cursor.isAfterLast()) {
          String name=cursor.getString(INDEX_NAME);
          if (isValidName(name) && !isNameInDictionary(name)) {
            if (DEBUG) {
              Log.d(TAG,"String_Node_Str" + name + "String_Node_Str"+ (SystemClock.uptimeMillis() - startTime)+ "String_Node_Str");
            }
            return true;
          }
          cursor.moveToNext();
        }
      }
    }
  finally {
      cursor.close();
    }
  }
  if (DEBUG) {
    Log.d(TAG,"String_Node_Str" + (SystemClock.uptimeMillis() - startTime) + "String_Node_Str");
  }
  return false;
}

Fixed version (ground truth):
@Override protected boolean hasContentChanged(){
  final long startTime=SystemClock.uptimeMillis();
  final int contactCount=getContactCount();
  if (contactCount > MAX_CONTACT_COUNT) {
    return false;
  }
  if (contactCount != sContactCountAtLastRebuild) {
    if (DEBUG) {
      Log.d(TAG,"String_Node_Str" + sContactCountAtLastRebuild + "String_Node_Str"+ contactCount);
    }
    return true;
  }
  Cursor cursor=mContext.getContentResolver().query(Contacts.CONTENT_URI,PROJECTION,null,null,null);
  if (cursor != null) {
    try {
      if (cursor.moveToFirst()) {
        while (!cursor.isAfterLast()) {
          String name=cursor.getString(INDEX_NAME);
          if (isValidName(name) && !isNameInDictionary(name)) {
            if (DEBUG) {
              Log.d(TAG,"String_Node_Str" + name + "String_Node_Str"+ (SystemClock.uptimeMillis() - startTime)+ "String_Node_Str");
            }
            return true;
          }
          cursor.moveToNext();
        }
      }
    }
  finally {
      cursor.close();
    }
  }
  if (DEBUG) {
    Log.d(TAG,"String_Node_Str" + (SystemClock.uptimeMillis() - startTime) + "String_Node_Str");
  }
  return false;
}
Program: 87948
Project: 87948
Buggy source:
/** 
 * Loads the current binary dictionary from internal storage. Assumes the dictionary file exists.
 */
protected void loadBinaryDictionary(){
  if (DEBUG) {
    Log.d(TAG,"String_Node_Str" + mSharedDictionaryController.mLastUpdateRequestTime + "String_Node_Str"+ mSharedDictionaryController.mLastUpdateTime);
  }
  final File file=new File(mContext.getFilesDir(),mFilename);
  final String filename=file.getAbsolutePath();
  final long length=file.length();
  final BinaryDictionary newBinaryDictionary=new BinaryDictionary(mContext,filename,0,length,true,null);
  if (mBinaryDictionary != null) {
    final BinaryDictionary oldBinaryDictionary=mBinaryDictionary;
    mLocalDictionaryController.lock();
    mBinaryDictionary=newBinaryDictionary;
    mLocalDictionaryController.unlock();
    oldBinaryDictionary.close();
  }
 else {
    mBinaryDictionary=newBinaryDictionary;
  }
}

Fixed version (ground truth):
/** 
 * Loads the current binary dictionary from internal storage. Assumes the dictionary file exists.
 */
protected void loadBinaryDictionary(){
  if (DEBUG) {
    Log.d(TAG,"String_Node_Str" + mFilename + "String_Node_Str"+ mSharedDictionaryController.mLastUpdateRequestTime+ "String_Node_Str"+ mSharedDictionaryController.mLastUpdateTime);
  }
  final File file=new File(mContext.getFilesDir(),mFilename);
  final String filename=file.getAbsolutePath();
  final long length=file.length();
  final BinaryDictionary newBinaryDictionary=new BinaryDictionary(mContext,filename,0,length,true,null);
  if (mBinaryDictionary != null) {
    final BinaryDictionary oldBinaryDictionary=mBinaryDictionary;
    mLocalDictionaryController.lock();
    mBinaryDictionary=newBinaryDictionary;
    mLocalDictionaryController.unlock();
    oldBinaryDictionary.close();
  }
 else {
    mBinaryDictionary=newBinaryDictionary;
  }
}
Program: 87949
Project: 87949
Buggy source:
@Override public void run(){
  syncReloadDictionaryIfRequired();
}

Fixed version (ground truth):
@Override public void run(){
  syncReloadDictionaryInternal();
}
Program: 87950
Project: 87950
Buggy source:
/** 
 * Reloads the dictionary if required. Reload will occur asynchronously in a separate thread.
 */
void asyncReloadDictionaryIfRequired(){
  new AsyncReloadDictionaryTask().start();
}

Fixed version (ground truth):
/** 
 * Reloads the dictionary if required. Reload will occur asynchronously in a separate thread.
 */
void asyncReloadDictionaryIfRequired(){
  if (!isReloadRequired())   return;
  if (DEBUG) {
    Log.d(TAG,"String_Node_Str" + mFilename);
  }
  new AsyncReloadDictionaryTask().start();
}
Program: 87951
Project: 87951
Buggy source:
/** 
 * Marks that the dictionary is out of date and requires a reload.
 * @param requiresRebuild Indicates that the source dictionary content has changed and a rebuildof the binary file is required. If not true, the next reload process will only read the current binary dictionary from file.
 */
protected void setRequiresReload(final boolean requiresRebuild){
  final long time=SystemClock.uptimeMillis();
  mLocalDictionaryController.mLastUpdateRequestTime=time;
  mSharedDictionaryController.mLastUpdateRequestTime=time;
  if (DEBUG) {
    Log.d(TAG,"String_Node_Str" + time + "String_Node_Str"+ mSharedDictionaryController.mLastUpdateTime);
  }
}

Fixed version (ground truth):
/** 
 * Marks that the dictionary is out of date and requires a reload.
 * @param requiresRebuild Indicates that the source dictionary content has changed and a rebuildof the binary file is required. If not true, the next reload process will only read the current binary dictionary from file.
 */
protected void setRequiresReload(final boolean requiresRebuild){
  final long time=SystemClock.uptimeMillis();
  mLocalDictionaryController.mLastUpdateRequestTime=time;
  mSharedDictionaryController.mLastUpdateRequestTime=time;
  if (DEBUG) {
    Log.d(TAG,"String_Node_Str" + mFilename + "String_Node_Str"+ time+ "String_Node_Str"+ mSharedDictionaryController.mLastUpdateTime);
  }
}
Program: 87952
Project: 87952
Buggy source:
/** 
 * Reloads the dictionary if required. Access is controlled on a per dictionary file basis and supports concurrent calls from multiple instances that share the same dictionary file.
 */
protected final void syncReloadDictionaryIfRequired(){
  if (mBinaryDictionary != null && !mLocalDictionaryController.isOutOfDate()) {
    return;
  }
  mSharedDictionaryController.lock();
  try {
    final long time=SystemClock.uptimeMillis();
    if (mSharedDictionaryController.isOutOfDate() || !dictionaryFileExists()) {
      if (hasContentChanged()) {
        mSharedDictionaryController.mLastUpdateTime=time;
        generateBinaryDictionary();
        loadBinaryDictionary();
      }
 else {
        mSharedDictionaryController.mLastUpdateRequestTime=mSharedDictionaryController.mLastUpdateTime;
      }
    }
 else     if (mBinaryDictionary == null || mLocalDictionaryController.mLastUpdateTime < mSharedDictionaryController.mLastUpdateTime) {
      loadBinaryDictionary();
    }
    mLocalDictionaryController.mLastUpdateTime=time;
  }
  finally {
    mSharedDictionaryController.unlock();
  }
}

Fixed version (ground truth):
/** 
 * Reloads the dictionary if required.
 */
protected final void syncReloadDictionaryIfRequired(){
  if (!isReloadRequired())   return;
  syncReloadDictionaryInternal();
}