nus-yam/ex-repair huggingface dataset:
Program: 87695
Project: 87695
Buggy source:
@Override protected int shiftOutWords(final int numWords){
  final int numWordContainingLogUnitsShiftedOut=super.shiftOutWords(numWords);
  mNumWordsUntilSafeToSample=Math.max(0,mNumWordsUntilSafeToSample - numWordContainingLogUnitsShiftedOut);
  if (DEBUG) {
    Log.d(TAG,"String_Node_Str" + mNumWordsUntilSafeToSample);
  }
  return numWordContainingLogUnitsShiftedOut;
}

Fixed version (ground truth):
@Override protected int shiftOutWords(final int numWords){
  final int numWordsShiftedOut=super.shiftOutWords(numWords);
  mNumWordsUntilSafeToSample=Math.max(0,mNumWordsUntilSafeToSample - numWordsShiftedOut);
  if (DEBUG) {
    Log.d(TAG,"String_Node_Str" + mNumWordsUntilSafeToSample);
  }
  return numWordsShiftedOut;
}
Program: 87696
Project: 87696
Buggy source:
protected final void publishLogUnitsAtFrontOfBuffer(){
  ArrayList<LogUnit> logUnits=peekAtFirstNWords(N_GRAM_SIZE);
  if (isSafeNGram(logUnits,N_GRAM_SIZE)) {
    publish(logUnits,true);
    shiftOutWords(N_GRAM_SIZE);
    mNumWordsUntilSafeToSample=mNumWordsBetweenNGrams;
  }
 else {
    logUnits.clear();
    for (LogUnit logUnit=shiftOut(); logUnit != null && !logUnit.hasOneOrMoreWords(); logUnit=shiftOut()) {
      logUnits.add(logUnit);
    }
    publish(logUnits,false);
  }
}

Fixed version (ground truth):
protected final void publishLogUnitsAtFrontOfBuffer(){
  ArrayList<LogUnit> logUnits=peekAtFirstNWords(N_GRAM_SIZE);
  if (isSafeNGram(logUnits,N_GRAM_SIZE)) {
    publish(logUnits,true);
    shiftOutWords(N_GRAM_SIZE);
    mNumWordsUntilSafeToSample=mNumWordsBetweenNGrams;
    return;
  }
  logUnits.clear();
  LogUnit logUnit=shiftOut();
  while (logUnit != null) {
    logUnits.add(logUnit);
    final int numWords=logUnit.getNumWords();
    if (numWords > 0) {
      mNumWordsUntilSafeToSample=Math.max(0,mNumWordsUntilSafeToSample - numWords);
      break;
    }
    logUnit=shiftOut();
  }
  publish(logUnits,false);
}
Program: 87697
Project: 87697
Buggy source:
/** 
 * Remove LogUnits from the front of the LogBuffer until   {@code numWords} have been removed.If there are less than  {@code numWords} word-containing {@link LogUnit}s, shifts out all   {@code LogUnit}s in the buffer.
 * @param numWords the minimum number of word-containing {@link LogUnit}s to shift out
 * @return the number of actual {@code LogUnit}s shifted out
 */
protected int shiftOutWords(final int numWords){
  int numWordContainingLogUnitsShiftedOut=0;
  for (LogUnit logUnit=shiftOut(); logUnit != null && numWordContainingLogUnitsShiftedOut < numWords; logUnit=shiftOut()) {
    if (logUnit.hasOneOrMoreWords()) {
      numWordContainingLogUnitsShiftedOut+=logUnit.getNumWords();
    }
  }
  return numWordContainingLogUnitsShiftedOut;
}

Fixed version (ground truth):
/** 
 * Remove LogUnits from the front of the LogBuffer until   {@code numWords} have been removed.If there are less than  {@code numWords} in the buffer, shifts out all {@code LogUnit}s.
 * @param numWords the minimum number of words in {@link LogUnit}s to shift out
 * @return the number of actual words LogUnit}s shifted out
 */
protected int shiftOutWords(final int numWords){
  int numWordsShiftedOut=0;
  do {
    final LogUnit logUnit=shiftOut();
    if (logUnit == null)     break;
    numWordsShiftedOut+=logUnit.getNumWords();
  }
 while (numWordsShiftedOut < numWords);
  return numWordsShiftedOut;
}
Program: 87698
Project: 87698
Buggy source:
@Override protected int shiftOutWords(final int numWords){
  final int numWordContainingLogUnitsShiftedOut=super.shiftOutWords(numWords);
  mNumWordsUntilSafeToSample=Math.max(0,mNumWordsUntilSafeToSample - numWordContainingLogUnitsShiftedOut);
  if (DEBUG) {
    Log.d(TAG,"String_Node_Str" + mNumWordsUntilSafeToSample);
  }
  return numWordContainingLogUnitsShiftedOut;
}

Fixed version (ground truth):
@Override protected int shiftOutWords(final int numWords){
  final int numWordsShiftedOut=super.shiftOutWords(numWords);
  mNumWordsUntilSafeToSample=Math.max(0,mNumWordsUntilSafeToSample - numWordsShiftedOut);
  if (DEBUG) {
    Log.d(TAG,"String_Node_Str" + mNumWordsUntilSafeToSample);
  }
  return numWordsShiftedOut;
}
Program: 87699
Project: 87699
Buggy source:
protected final void publishLogUnitsAtFrontOfBuffer(){
  ArrayList<LogUnit> logUnits=peekAtFirstNWords(N_GRAM_SIZE);
  if (isSafeNGram(logUnits,N_GRAM_SIZE)) {
    publish(logUnits,true);
    shiftOutWords(N_GRAM_SIZE);
    mNumWordsUntilSafeToSample=mNumWordsBetweenNGrams;
  }
 else {
    logUnits.clear();
    for (LogUnit logUnit=shiftOut(); logUnit != null && !logUnit.hasOneOrMoreWords(); logUnit=shiftOut()) {
      logUnits.add(logUnit);
    }
    publish(logUnits,false);
  }
}

Fixed version (ground truth):
protected final void publishLogUnitsAtFrontOfBuffer(){
  ArrayList<LogUnit> logUnits=peekAtFirstNWords(N_GRAM_SIZE);
  if (isSafeNGram(logUnits,N_GRAM_SIZE)) {
    publish(logUnits,true);
    shiftOutWords(N_GRAM_SIZE);
    mNumWordsUntilSafeToSample=mNumWordsBetweenNGrams;
    return;
  }
  logUnits.clear();
  LogUnit logUnit=shiftOut();
  while (logUnit != null) {
    logUnits.add(logUnit);
    final int numWords=logUnit.getNumWords();
    if (numWords > 0) {
      mNumWordsUntilSafeToSample=Math.max(0,mNumWordsUntilSafeToSample - numWords);
      break;
    }
    logUnit=shiftOut();
  }
  publish(logUnits,false);
}
Program: 87700
Project: 87700
Buggy source:
@Override protected void onPause(){
  mWelcomeVideoView.stopPlayback();
  super.onPause();
}

Fixed version (ground truth):
@Override protected void onPause(){
  hideAndStopVideo(mWelcomeVideoView);
  super.onPause();
}
Program: 87701
Project: 87701
Buggy source:
private void updateSetupStepView(){
  final boolean welcomeScreen=(mStepNumber == STEP_WELCOME);
  mWelcomeScreen.setVisibility(welcomeScreen ? View.VISIBLE : View.GONE);
  mSetupScreen.setVisibility(welcomeScreen ? View.GONE : View.VISIBLE);
  if (welcomeScreen) {
    mWelcomeVideoView.setVideoURI(mWelcomeVideoUri);
    mWelcomeVideoView.start();
    return;
  }
  mWelcomeVideoView.stopPlayback();
  final boolean isStepActionAlreadyDone=mStepNumber < determineSetupStepNumber();
  mSetupStepGroup.enableStep(mStepNumber,isStepActionAlreadyDone);
  mActionNext.setVisibility(isStepActionAlreadyDone ? View.VISIBLE : View.GONE);
  mActionFinish.setVisibility((mStepNumber == STEP_3) ? View.VISIBLE : View.GONE);
}

Fixed version (ground truth):
private void updateSetupStepView(){
  final boolean welcomeScreen=(mStepNumber == STEP_WELCOME);
  mWelcomeScreen.setVisibility(welcomeScreen ? View.VISIBLE : View.GONE);
  mSetupScreen.setVisibility(welcomeScreen ? View.GONE : View.VISIBLE);
  if (welcomeScreen) {
    mWelcomeVideoView.setVisibility(View.VISIBLE);
    mWelcomeVideoView.setVideoURI(mWelcomeVideoUri);
    mWelcomeVideoView.start();
    return;
  }
  hideAndStopVideo(mWelcomeVideoView);
  final boolean isStepActionAlreadyDone=mStepNumber < determineSetupStepNumber();
  mSetupStepGroup.enableStep(mStepNumber,isStepActionAlreadyDone);
  mActionNext.setVisibility(isStepActionAlreadyDone ? View.VISIBLE : View.GONE);
  mActionFinish.setVisibility((mStepNumber == STEP_3) ? View.VISIBLE : View.GONE);
}
Program: 87703
Project: 87703
Buggy source:
@Override public void onPrepared(final MediaPlayer mp){
  mWelcomeVideoView.setBackgroundResource(0);
}

Fixed version (ground truth):
@Override public void onPrepared(final MediaPlayer mp){
  mWelcomeVideoView.setBackgroundResource(0);
  mp.setLooping(true);
}
Program: 87704
Project: 87704
Buggy source:
@Override protected void onPause(){
  mWelcomeVideoView.stopPlayback();
  super.onPause();
}

Fixed version (ground truth):
@Override protected void onPause(){
  hideAndStopVideo(mWelcomeVideoView);
  super.onPause();
}
Program: 87705
Project: 87705
Buggy source:
private void updateSetupStepView(){
  final boolean welcomeScreen=(mStepNumber == STEP_WELCOME);
  mWelcomeScreen.setVisibility(welcomeScreen ? View.VISIBLE : View.GONE);
  mSetupScreen.setVisibility(welcomeScreen ? View.GONE : View.VISIBLE);
  if (welcomeScreen) {
    mWelcomeVideoView.setVideoURI(mWelcomeVideoUri);
    mWelcomeVideoView.start();
    return;
  }
  mWelcomeVideoView.stopPlayback();
  final boolean isStepActionAlreadyDone=mStepNumber < determineSetupStepNumber();
  mSetupStepGroup.enableStep(mStepNumber,isStepActionAlreadyDone);
  mActionNext.setVisibility(isStepActionAlreadyDone ? View.VISIBLE : View.GONE);
  mActionFinish.setVisibility((mStepNumber == STEP_3) ? View.VISIBLE : View.GONE);
}

Fixed version (ground truth):
private void updateSetupStepView(){
  final boolean welcomeScreen=(mStepNumber == STEP_WELCOME);
  mWelcomeScreen.setVisibility(welcomeScreen ? View.VISIBLE : View.GONE);
  mSetupScreen.setVisibility(welcomeScreen ? View.GONE : View.VISIBLE);
  if (welcomeScreen) {
    mWelcomeVideoView.setVisibility(View.VISIBLE);
    mWelcomeVideoView.setVideoURI(mWelcomeVideoUri);
    mWelcomeVideoView.start();
    return;
  }
  hideAndStopVideo(mWelcomeVideoView);
  final boolean isStepActionAlreadyDone=mStepNumber < determineSetupStepNumber();
  mSetupStepGroup.enableStep(mStepNumber,isStepActionAlreadyDone);
  mActionNext.setVisibility(isStepActionAlreadyDone ? View.VISIBLE : View.GONE);
  mActionFinish.setVisibility((mStepNumber == STEP_3) ? View.VISIBLE : View.GONE);
}
Program: 87707
Project: 87707
Buggy source:
@Override public void onPrepared(final MediaPlayer mp){
  mWelcomeVideoView.setBackgroundResource(0);
}

Fixed version (ground truth):
@Override public void onPrepared(final MediaPlayer mp){
  mWelcomeVideoView.setBackgroundResource(0);
  mp.setLooping(true);
}
Program: 87708
Project: 87708
Buggy source:
protected void shiftOutWords(final int numWords){
  final int targetNumWords=mNumActualWords - numWords;
  final LinkedList<LogUnit> logUnits=getLogUnits();
  while (mNumActualWords > targetNumWords && !logUnits.isEmpty()) {
    shiftOut();
  }
}

Fixed version (ground truth):
/** 
 * Remove LogUnits from the front of the LogBuffer until   {@code numWords} have been removed.If there are less than  {@code numWords} word-containing {@link LogUnit}s, shifts out all   {@code LogUnit}s in the buffer.
 * @param numWords the number of word-containing {@link LogUnit}s to shift out
 * @return the number of actual {@code LogUnit}s shifted out
 */
protected int shiftOutWords(final int numWords){
  int numWordContainingLogUnitsShiftedOut=0;
  for (LogUnit logUnit=shiftOut(); logUnit != null && numWordContainingLogUnitsShiftedOut < numWords; logUnit=shiftOut()) {
    if (logUnit.hasWord()) {
      numWordContainingLogUnitsShiftedOut++;
    }
  }
  return numWordContainingLogUnitsShiftedOut;
}
Program: 87709
Project: 87709
Buggy source:
@Override protected void shiftOutWords(final int numWords){
  final int oldNumActualWords=getNumActualWords();
  super.shiftOutWords(numWords);
  final int numWordsShifted=oldNumActualWords - getNumActualWords();
  mNumWordsUntilSafeToSample-=numWordsShifted;
  if (DEBUG) {
    Log.d(TAG,"String_Node_Str" + mNumWordsUntilSafeToSample);
  }
}

Fixed version (ground truth):
@Override protected int shiftOutWords(final int numWords){
  final int numWordContainingLogUnitsShiftedOut=super.shiftOutWords(numWords);
  mNumWordsUntilSafeToSample=Math.max(0,mNumWordsUntilSafeToSample - numWordContainingLogUnitsShiftedOut);
  if (DEBUG) {
    Log.d(TAG,"String_Node_Str" + mNumWordsUntilSafeToSample);
  }
  return numWordContainingLogUnitsShiftedOut;
}
Program: 87710
Project: 87710
Buggy source:
protected final void publishLogUnitsAtFrontOfBuffer(){
  ArrayList<LogUnit> logUnits=peekAtFirstNWords(N_GRAM_SIZE);
  if (isSafeNGram(logUnits,N_GRAM_SIZE)) {
    publish(logUnits,true);
    shiftOutWords(N_GRAM_SIZE);
    resetWordCounter();
  }
 else {
    logUnits=peekAtFirstNWords(1);
    publish(logUnits,false);
    shiftOutWords(1);
  }
}

Fixed version (ground truth):
protected final void publishLogUnitsAtFrontOfBuffer(){
  ArrayList<LogUnit> logUnits=peekAtFirstNWords(N_GRAM_SIZE);
  if (isSafeNGram(logUnits,N_GRAM_SIZE)) {
    publish(logUnits,true);
    shiftOutWords(N_GRAM_SIZE);
    mNumWordsUntilSafeToSample=mNumWordsBetweenNGrams;
  }
 else {
    logUnits=peekAtFirstNWords(1);
    publish(logUnits,false);
    shiftOutWords(1);
  }
}
Program: 87711
Project: 87711
Buggy source:
protected void shiftOutWords(final int numWords){
  final int targetNumWords=mNumActualWords - numWords;
  final LinkedList<LogUnit> logUnits=getLogUnits();
  while (mNumActualWords > targetNumWords && !logUnits.isEmpty()) {
    shiftOut();
  }
}

Fixed version (ground truth):
/** 
 * Remove LogUnits from the front of the LogBuffer until   {@code numWords} have been removed.If there are less than  {@code numWords} word-containing {@link LogUnit}s, shifts out all   {@code LogUnit}s in the buffer.
 * @param numWords the number of word-containing {@link LogUnit}s to shift out
 * @return the number of actual {@code LogUnit}s shifted out
 */
protected int shiftOutWords(final int numWords){
  int numWordContainingLogUnitsShiftedOut=0;
  for (LogUnit logUnit=shiftOut(); logUnit != null && numWordContainingLogUnitsShiftedOut < numWords; logUnit=shiftOut()) {
    if (logUnit.hasWord()) {
      numWordContainingLogUnitsShiftedOut++;
    }
  }
  return numWordContainingLogUnitsShiftedOut;
}
Program: 87712
Project: 87712
Buggy source:
@Override protected void shiftOutWords(final int numWords){
  final int oldNumActualWords=getNumActualWords();
  super.shiftOutWords(numWords);
  final int numWordsShifted=oldNumActualWords - getNumActualWords();
  mNumWordsUntilSafeToSample-=numWordsShifted;
  if (DEBUG) {
    Log.d(TAG,"String_Node_Str" + mNumWordsUntilSafeToSample);
  }
}

Fixed version (ground truth):
@Override protected int shiftOutWords(final int numWords){
  final int numWordContainingLogUnitsShiftedOut=super.shiftOutWords(numWords);
  mNumWordsUntilSafeToSample=Math.max(0,mNumWordsUntilSafeToSample - numWordContainingLogUnitsShiftedOut);
  if (DEBUG) {
    Log.d(TAG,"String_Node_Str" + mNumWordsUntilSafeToSample);
  }
  return numWordContainingLogUnitsShiftedOut;
}
Program: 87713
Project: 87713
Buggy source:
protected final void publishLogUnitsAtFrontOfBuffer(){
  ArrayList<LogUnit> logUnits=peekAtFirstNWords(N_GRAM_SIZE);
  if (isSafeNGram(logUnits,N_GRAM_SIZE)) {
    publish(logUnits,true);
    shiftOutWords(N_GRAM_SIZE);
    resetWordCounter();
  }
 else {
    logUnits=peekAtFirstNWords(1);
    publish(logUnits,false);
    shiftOutWords(1);
  }
}

Fixed version (ground truth):
protected final void publishLogUnitsAtFrontOfBuffer(){
  ArrayList<LogUnit> logUnits=peekAtFirstNWords(N_GRAM_SIZE);
  if (isSafeNGram(logUnits,N_GRAM_SIZE)) {
    publish(logUnits,true);
    shiftOutWords(N_GRAM_SIZE);
    mNumWordsUntilSafeToSample=mNumWordsBetweenNGrams;
  }
 else {
    logUnits=peekAtFirstNWords(1);
    publish(logUnits,false);
    shiftOutWords(1);
  }
}
Program: 87715
Project: 87715
Buggy source:
@Override public Word next(){
  Position currentPos=mPositions.getLast();
  mCurrentString.setLength(currentPos.length);
  do {
    if (currentPos.pos.hasNext()) {
      final CharGroup currentGroup=currentPos.pos.next();
      currentPos.length=mCurrentString.length();
      for (      int i : currentGroup.mChars)       mCurrentString.append(Character.toChars(i));
      if (null != currentGroup.mChildren) {
        currentPos=new Position(currentGroup.mChildren.mData);
        mPositions.addLast(currentPos);
      }
      if (currentGroup.mFrequency >= 0)       return new Word(mCurrentString.toString(),currentGroup.mFrequency,currentGroup.mShortcutTargets,currentGroup.mBigrams,currentGroup.mIsNotAWord,currentGroup.mIsBlacklistEntry);
    }
 else {
      mPositions.removeLast();
      currentPos=mPositions.getLast();
      mCurrentString.setLength(mPositions.getLast().length);
    }
  }
 while (true);
}

Fixed version (ground truth):
@Override public Word next(){
  Position currentPos=mPositions.getLast();
  mCurrentString.setLength(currentPos.length);
  do {
    if (currentPos.pos.hasNext()) {
      final CharGroup currentGroup=currentPos.pos.next();
      currentPos.length=mCurrentString.length();
      for (      int i : currentGroup.mChars) {
        mCurrentString.append(Character.toChars(i));
      }
      if (null != currentGroup.mChildren) {
        currentPos=new Position(currentGroup.mChildren.mData);
        currentPos.length=mCurrentString.length();
        mPositions.addLast(currentPos);
      }
      if (currentGroup.mFrequency >= 0) {
        return new Word(mCurrentString.toString(),currentGroup.mFrequency,currentGroup.mShortcutTargets,currentGroup.mBigrams,currentGroup.mIsNotAWord,currentGroup.mIsBlacklistEntry);
      }
    }
 else {
      mPositions.removeLast();
      currentPos=mPositions.getLast();
      mCurrentString.setLength(mPositions.getLast().length);
    }
  }
 while (true);
}
Program: 87716
Project: 87716
Buggy source:
/** 
 * Helper method to find a word in a given branch.
 */
@SuppressWarnings("String_Node_Str") public static CharGroup findWordInTree(Node node,final String string){
  int index=0;
  final StringBuilder checker=DBG ? new StringBuilder() : null;
  final int[] codePoints=getCodePoints(string);
  CharGroup currentGroup;
  do {
    int indexOfGroup=findIndexOfChar(node,codePoints[index]);
    if (CHARACTER_NOT_FOUND == indexOfGroup)     return null;
    currentGroup=node.mData.get(indexOfGroup);
    if (codePoints.length - index < currentGroup.mChars.length)     return null;
    int newIndex=index;
    while (newIndex < codePoints.length && newIndex - index < currentGroup.mChars.length) {
      if (currentGroup.mChars[newIndex - index] != codePoints[newIndex])       return null;
      newIndex++;
    }
    index=newIndex;
    if (DBG)     checker.append(new String(currentGroup.mChars,0,currentGroup.mChars.length));
    if (index < codePoints.length) {
      node=currentGroup.mChildren;
    }
  }
 while (null != node && index < codePoints.length);
  if (index < codePoints.length)   return null;
  if (!currentGroup.isTerminal())   return null;
  if (DBG && !codePoints.equals(checker.toString()))   return null;
  return currentGroup;
}

Fixed version (ground truth):
/** 
 * Helper method to find a word in a given branch.
 */
@SuppressWarnings("String_Node_Str") public static CharGroup findWordInTree(Node node,final String string){
  int index=0;
  final StringBuilder checker=DBG ? new StringBuilder() : null;
  final int[] codePoints=getCodePoints(string);
  CharGroup currentGroup;
  do {
    int indexOfGroup=findIndexOfChar(node,codePoints[index]);
    if (CHARACTER_NOT_FOUND == indexOfGroup)     return null;
    currentGroup=node.mData.get(indexOfGroup);
    if (codePoints.length - index < currentGroup.mChars.length)     return null;
    int newIndex=index;
    while (newIndex < codePoints.length && newIndex - index < currentGroup.mChars.length) {
      if (currentGroup.mChars[newIndex - index] != codePoints[newIndex])       return null;
      newIndex++;
    }
    index=newIndex;
    if (DBG)     checker.append(new String(currentGroup.mChars,0,currentGroup.mChars.length));
    if (index < codePoints.length) {
      node=currentGroup.mChildren;
    }
  }
 while (null != node && index < codePoints.length);
  if (index < codePoints.length)   return null;
  if (!currentGroup.isTerminal())   return null;
  if (DBG && !string.equals(checker.toString()))   return null;
  return currentGroup;
}
Program: 87717
Project: 87717
Buggy source:
@Override public void onDisplayCompletions(final CompletionInfo[] applicationSpecifiedCompletions){
  if (DEBUG) {
    Log.i(TAG,"String_Node_Str");
    if (applicationSpecifiedCompletions != null) {
      for (int i=0; i < applicationSpecifiedCompletions.length; i++) {
        Log.i(TAG,"String_Node_Str" + i + "String_Node_Str"+ applicationSpecifiedCompletions[i]);
      }
    }
  }
  if (!mSettings.getCurrent().isApplicationSpecifiedCompletionsOn())   return;
  mApplicationSpecifiedCompletions=applicationSpecifiedCompletions;
  if (applicationSpecifiedCompletions == null) {
    clearSuggestionStrip();
    if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
      ResearchLogger.latinIME_onDisplayCompletions(null);
    }
    return;
  }
  final ArrayList<SuggestedWords.SuggestedWordInfo> applicationSuggestedWords=SuggestedWords.getFromApplicationSpecifiedCompletions(applicationSpecifiedCompletions);
  final SuggestedWords suggestedWords=new SuggestedWords(applicationSuggestedWords,false,false,false,false,false);
  final boolean isAutoCorrection=false;
  setSuggestedWords(suggestedWords,isAutoCorrection);
  setAutoCorrectionIndicator(isAutoCorrection);
  setSuggestionStripShown(true);
  if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
    ResearchLogger.latinIME_onDisplayCompletions(applicationSpecifiedCompletions);
  }
}

Fixed version (ground truth):
@Override public void onDisplayCompletions(final CompletionInfo[] applicationSpecifiedCompletions){
  if (DEBUG) {
    Log.i(TAG,"String_Node_Str");
    if (applicationSpecifiedCompletions != null) {
      for (int i=0; i < applicationSpecifiedCompletions.length; i++) {
        Log.i(TAG,"String_Node_Str" + i + "String_Node_Str"+ applicationSpecifiedCompletions[i]);
      }
    }
  }
  if (!mSettings.getCurrent().isApplicationSpecifiedCompletionsOn())   return;
  mApplicationSpecifiedCompletions=CompletionInfoUtils.removeNulls(applicationSpecifiedCompletions);
  if (applicationSpecifiedCompletions == null) {
    clearSuggestionStrip();
    if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
      ResearchLogger.latinIME_onDisplayCompletions(null);
    }
    return;
  }
  final ArrayList<SuggestedWords.SuggestedWordInfo> applicationSuggestedWords=SuggestedWords.getFromApplicationSpecifiedCompletions(applicationSpecifiedCompletions);
  final SuggestedWords suggestedWords=new SuggestedWords(applicationSuggestedWords,false,false,false,false,false);
  final boolean isAutoCorrection=false;
  setSuggestedWords(suggestedWords,isAutoCorrection);
  setAutoCorrectionIndicator(isAutoCorrection);
  setSuggestionStripShown(true);
  if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
    ResearchLogger.latinIME_onDisplayCompletions(applicationSpecifiedCompletions);
  }
}
Program: 87718
Project: 87718
Buggy source:
public void commitCompletion(final CompletionInfo completionInfo){
  if (DEBUG_BATCH_NESTING)   checkBatchEdit();
  if (DEBUG_PREVIOUS_TEXT)   checkConsistencyForDebug();
  final CharSequence text=completionInfo.getText();
  mCommittedTextBeforeComposingText.append(text);
  mCurrentCursorPosition+=text.length() - mComposingText.length();
  mComposingText.setLength(0);
  if (null != mIC) {
    mIC.commitCompletion(completionInfo);
    if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
      ResearchLogger.richInputConnection_commitCompletion(completionInfo);
    }
  }
  if (DEBUG_PREVIOUS_TEXT)   checkConsistencyForDebug();
}

Fixed version (ground truth):
public void commitCompletion(final CompletionInfo completionInfo){
  if (DEBUG_BATCH_NESTING)   checkBatchEdit();
  if (DEBUG_PREVIOUS_TEXT)   checkConsistencyForDebug();
  CharSequence text=completionInfo.getText();
  if (null == text)   text="String_Node_Str";
  mCommittedTextBeforeComposingText.append(text);
  mCurrentCursorPosition+=text.length() - mComposingText.length();
  mComposingText.setLength(0);
  if (null != mIC) {
    mIC.commitCompletion(completionInfo);
    if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
      ResearchLogger.richInputConnection_commitCompletion(completionInfo);
    }
  }
  if (DEBUG_PREVIOUS_TEXT)   checkConsistencyForDebug();
}
Program: 87719
Project: 87719
Buggy source:
/** 
 * Arrange for the UploaderService to be run on a regular basis. Any existing scheduled invocation of UploaderService is removed and optionally rescheduled. This may cause problems if this method is called so often that no scheduled invocation is ever run.  But if the delay is short enough that it will go off when the user is sleeping, then there should be no starvation.
 * @param context {@link Context} object
 * @param needsRescheduling whether to schedule a future intent to be delivered to this service
 */
public static void cancelAndRescheduleUploadingService(final Context context,final boolean needsRescheduling){
  final PendingIntent pendingIntent=getPendingIntentForService(context);
  final AlarmManager alarmManager=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
  cancelAnyScheduledServiceAlarm(alarmManager,pendingIntent);
  if (needsRescheduling) {
    scheduleServiceAlarm(alarmManager,pendingIntent);
  }
}

Fixed version (ground truth):
/** 
 * Arrange for the UploaderService to be run on a regular basis. Any existing scheduled invocation of UploaderService is removed and optionally rescheduled. This may cause problems if this method is called so often that no scheduled invocation is ever run.  But if the delay is short enough that it will go off when the user is sleeping, then there should be no starvation.
 * @param context {@link Context} object
 * @param needsRescheduling whether to schedule a future intent to be delivered to this service
 */
public static void cancelAndRescheduleUploadingService(final Context context,final boolean needsRescheduling){
  final Intent intent=new Intent(context,UploaderService.class);
  final PendingIntent pendingIntent=PendingIntent.getService(context,0,intent,0);
  final AlarmManager alarmManager=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
  alarmManager.cancel(pendingIntent);
  if (needsRescheduling) {
    alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,SystemClock.elapsedRealtime() + UploaderService.RUN_INTERVAL,pendingIntent);
  }
}
Program: 87720
Project: 87720
Buggy source:
private boolean isDevTeamBuild(){
  try {
    final PackageInfo packageInfo;
    packageInfo=mLatinIME.getPackageManager().getPackageInfo(mLatinIME.getPackageName(),0);
    final String versionName=packageInfo.versionName;
    return !(developerBuildRegex.matcher(versionName).find());
  }
 catch (  final NameNotFoundException e) {
    Log.e(TAG,"String_Node_Str",e);
    return false;
  }
}

Fixed version (ground truth):
private boolean isDevTeamBuild(){
  try {
    final PackageInfo packageInfo;
    packageInfo=mLatinIME.getPackageManager().getPackageInfo(mLatinIME.getPackageName(),0);
    final String versionName=packageInfo.versionName;
    return developerBuildRegex.matcher(versionName).find();
  }
 catch (  final NameNotFoundException e) {
    Log.e(TAG,"String_Node_Str",e);
    return false;
  }
}
Program: 87721
Project: 87721
Buggy source:
/** 
 * Arrange for the UploaderService to be run on a regular basis. Any existing scheduled invocation of UploaderService is removed and optionally rescheduled. This may cause problems if this method is called so often that no scheduled invocation is ever run.  But if the delay is short enough that it will go off when the user is sleeping, then there should be no starvation.
 * @param context {@link Context} object
 * @param needsRescheduling whether to schedule a future intent to be delivered to this service
 */
public static void cancelAndRescheduleUploadingService(final Context context,final boolean needsRescheduling){
  final PendingIntent pendingIntent=getPendingIntentForService(context);
  final AlarmManager alarmManager=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
  cancelAnyScheduledServiceAlarm(alarmManager,pendingIntent);
  if (needsRescheduling) {
    scheduleServiceAlarm(alarmManager,pendingIntent);
  }
}

Fixed version (ground truth):
/** 
 * Arrange for the UploaderService to be run on a regular basis. Any existing scheduled invocation of UploaderService is removed and optionally rescheduled. This may cause problems if this method is called so often that no scheduled invocation is ever run.  But if the delay is short enough that it will go off when the user is sleeping, then there should be no starvation.
 * @param context {@link Context} object
 * @param needsRescheduling whether to schedule a future intent to be delivered to this service
 */
public static void cancelAndRescheduleUploadingService(final Context context,final boolean needsRescheduling){
  final Intent intent=new Intent(context,UploaderService.class);
  final PendingIntent pendingIntent=PendingIntent.getService(context,0,intent,0);
  final AlarmManager alarmManager=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
  alarmManager.cancel(pendingIntent);
  if (needsRescheduling) {
    alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,SystemClock.elapsedRealtime() + UploaderService.RUN_INTERVAL,pendingIntent);
  }
}
Program: 87722
Project: 87722
Buggy source:
static String getShortDisplayName(final InputMethodSubtype subtype){
  if (SubtypeLocale.isNoLanguage(subtype)) {
    return "String_Node_Str";
  }
  final Locale locale=SubtypeLocale.getSubtypeLocale(subtype);
  return StringUtils.capitalizeFirstCharacter(locale.getLanguage(),locale);
}

Fixed version (ground truth):
static String getShortDisplayName(final InputMethodSubtype subtype){
  if (SubtypeLocale.isNoLanguage(subtype)) {
    return "String_Node_Str";
  }
  final Locale locale=SubtypeLocale.getSubtypeLocale(subtype);
  return StringUtils.capitalizeFirstCodePoint(locale.getLanguage(),locale);
}
Program: 87723
Project: 87723
Buggy source:
/** 
 * Apply an auto-caps mode to a string. This intentionally does NOT apply manual caps mode. It only changes the capitalization if the mode is one of the auto-caps modes.
 * @param s The string to capitalize.
 * @param capitalizeMode The mode in which to capitalize.
 * @param locale The locale for capitalizing.
 * @return The capitalized string.
 */
public static String applyAutoCapsMode(final String s,final int capitalizeMode,final Locale locale){
  if (WordComposer.CAPS_MODE_AUTO_SHIFT_LOCKED == capitalizeMode) {
    return s.toUpperCase(locale);
  }
 else   if (WordComposer.CAPS_MODE_AUTO_SHIFTED == capitalizeMode) {
    return StringUtils.toTitleCase(s,locale);
  }
 else {
    return s;
  }
}

Fixed version (ground truth):
/** 
 * Apply an auto-caps mode to a string. This intentionally does NOT apply manual caps mode. It only changes the capitalization if the mode is one of the auto-caps modes.
 * @param s The string to capitalize.
 * @param capitalizeMode The mode in which to capitalize.
 * @param locale The locale for capitalizing.
 * @return The capitalized string.
 */
public static String applyAutoCapsMode(final String s,final int capitalizeMode,final Locale locale){
  if (WordComposer.CAPS_MODE_AUTO_SHIFT_LOCKED == capitalizeMode) {
    return s.toUpperCase(locale);
  }
 else   if (WordComposer.CAPS_MODE_AUTO_SHIFTED == capitalizeMode) {
    return StringUtils.capitalizeFirstCodePoint(s,locale);
  }
 else {
    return s;
  }
}
Program: 87724
Project: 87724
Buggy source:
private static String getSubtypeDisplayNameInternal(final InputMethodSubtype subtype,final Locale displayLocale){
  final String replacementString=getReplacementString(subtype,displayLocale);
  final int nameResId=subtype.getNameResId();
  final RunInLocale<String> getSubtypeName=new RunInLocale<String>(){
    @Override protected String job(    final Resources res){
      try {
        return res.getString(nameResId,replacementString);
      }
 catch (      Resources.NotFoundException e) {
        Log.w(TAG,"String_Node_Str" + subtype.getMode() + "String_Node_Str"+ subtype.getNameResId()+ "String_Node_Str"+ subtype.getLocale()+ "String_Node_Str"+ subtype.getExtraValue()+ "String_Node_Str"+ Utils.getStackTrace());
        return "String_Node_Str";
      }
    }
  }
;
  return StringUtils.capitalizeFirstCharacter(getSubtypeName.runInLocale(sResources,displayLocale),displayLocale);
}

Fixed version (ground truth):
private static String getSubtypeDisplayNameInternal(final InputMethodSubtype subtype,final Locale displayLocale){
  final String replacementString=getReplacementString(subtype,displayLocale);
  final int nameResId=subtype.getNameResId();
  final RunInLocale<String> getSubtypeName=new RunInLocale<String>(){
    @Override protected String job(    final Resources res){
      try {
        return res.getString(nameResId,replacementString);
      }
 catch (      Resources.NotFoundException e) {
        Log.w(TAG,"String_Node_Str" + subtype.getMode() + "String_Node_Str"+ subtype.getNameResId()+ "String_Node_Str"+ subtype.getLocale()+ "String_Node_Str"+ subtype.getExtraValue()+ "String_Node_Str"+ Utils.getStackTrace());
        return "String_Node_Str";
      }
    }
  }
;
  return StringUtils.capitalizeFirstCodePoint(getSubtypeName.runInLocale(sResources,displayLocale),displayLocale);
}
Program: 87725
Project: 87725
Buggy source:
private static String getSubtypeLocaleDisplayNameInternal(final String localeString,final Locale displayLocale){
  final Integer exceptionalNameResId=sExceptionalLocaleToNameIdsMap.get(localeString);
  final String displayName;
  if (exceptionalNameResId != null) {
    final RunInLocale<String> getExceptionalName=new RunInLocale<String>(){
      @Override protected String job(      final Resources res){
        return res.getString(exceptionalNameResId);
      }
    }
;
    displayName=getExceptionalName.runInLocale(sResources,displayLocale);
  }
 else   if (NO_LANGUAGE.equals(localeString)) {
    return sResources.getString(R.string.subtype_no_language);
  }
 else {
    final Locale locale=LocaleUtils.constructLocaleFromString(localeString);
    displayName=locale.getDisplayName(displayLocale);
  }
  return StringUtils.capitalizeFirstCharacter(displayName,displayLocale);
}

Fixed version (ground truth):
private static String getSubtypeLocaleDisplayNameInternal(final String localeString,final Locale displayLocale){
  final Integer exceptionalNameResId=sExceptionalLocaleToNameIdsMap.get(localeString);
  final String displayName;
  if (exceptionalNameResId != null) {
    final RunInLocale<String> getExceptionalName=new RunInLocale<String>(){
      @Override protected String job(      final Resources res){
        return res.getString(exceptionalNameResId);
      }
    }
;
    displayName=getExceptionalName.runInLocale(sResources,displayLocale);
  }
 else   if (NO_LANGUAGE.equals(localeString)) {
    return sResources.getString(R.string.subtype_no_language);
  }
 else {
    final Locale locale=LocaleUtils.constructLocaleFromString(localeString);
    displayName=locale.getDisplayName(displayLocale);
  }
  return StringUtils.capitalizeFirstCodePoint(displayName,displayLocale);
}
Program: 87726
Project: 87726
Buggy source:
private static SuggestedWordInfo getTransformedSuggestedWordInfo(final SuggestedWordInfo wordInfo,final Locale locale,final boolean isAllUpperCase,final boolean isFirstCharCapitalized,final int trailingSingleQuotesCount){
  final StringBuilder sb=new StringBuilder(wordInfo.mWord.length());
  if (isAllUpperCase) {
    sb.append(wordInfo.mWord.toUpperCase(locale));
  }
 else   if (isFirstCharCapitalized) {
    sb.append(StringUtils.toTitleCase(wordInfo.mWord,locale));
  }
 else {
    sb.append(wordInfo.mWord);
  }
  for (int i=trailingSingleQuotesCount - 1; i >= 0; --i) {
    sb.appendCodePoint(Constants.CODE_SINGLE_QUOTE);
  }
  return new SuggestedWordInfo(sb.toString(),wordInfo.mScore,wordInfo.mKind,wordInfo.mSourceDict);
}

Fixed version (ground truth):
private static SuggestedWordInfo getTransformedSuggestedWordInfo(final SuggestedWordInfo wordInfo,final Locale locale,final boolean isAllUpperCase,final boolean isFirstCharCapitalized,final int trailingSingleQuotesCount){
  final StringBuilder sb=new StringBuilder(wordInfo.mWord.length());
  if (isAllUpperCase) {
    sb.append(wordInfo.mWord.toUpperCase(locale));
  }
 else   if (isFirstCharCapitalized) {
    sb.append(StringUtils.capitalizeFirstCodePoint(wordInfo.mWord,locale));
  }
 else {
    sb.append(wordInfo.mWord);
  }
  for (int i=trailingSingleQuotesCount - 1; i >= 0; --i) {
    sb.appendCodePoint(Constants.CODE_SINGLE_QUOTE);
  }
  return new SuggestedWordInfo(sb.toString(),wordInfo.mScore,wordInfo.mKind,wordInfo.mSourceDict);
}
Program: 87728
Project: 87728
Buggy source:
/** 
 * Helper method to test valid capitalizations of a word. If the "text" is lower-case, we test only the exact string. If the "Text" is capitalized, we test the exact string "Text" and the lower-cased version of it "text". If the "TEXT" is fully upper case, we test the exact string "TEXT", the lower-cased version of it "text" and the capitalized version of it "Text".
 */
private boolean isInDictForAnyCapitalization(final Dictionary dict,final String text,final int capitalizeType){
  if (dict.isValidWord(text))   return true;
  if (StringUtils.CAPITALIZE_NONE == capitalizeType)   return false;
  final String lowerCaseText=text.toLowerCase(mLocale);
  if (dict.isValidWord(lowerCaseText))   return true;
  if (StringUtils.CAPITALIZE_FIRST == capitalizeType)   return false;
  return dict.isValidWord(StringUtils.toTitleCase(lowerCaseText,mLocale));
}

Fixed version (ground truth):
/** 
 * Helper method to test valid capitalizations of a word. If the "text" is lower-case, we test only the exact string. If the "Text" is capitalized, we test the exact string "Text" and the lower-cased version of it "text". If the "TEXT" is fully upper case, we test the exact string "TEXT", the lower-cased version of it "text" and the capitalized version of it "Text".
 */
private boolean isInDictForAnyCapitalization(final Dictionary dict,final String text,final int capitalizeType){
  if (dict.isValidWord(text))   return true;
  if (StringUtils.CAPITALIZE_NONE == capitalizeType)   return false;
  final String lowerCaseText=text.toLowerCase(mLocale);
  if (dict.isValidWord(lowerCaseText))   return true;
  if (StringUtils.CAPITALIZE_FIRST == capitalizeType)   return false;
  return dict.isValidWord(StringUtils.capitalizeFirstAndDowncaseRest(lowerCaseText,mLocale));
}
Program: 87729
Project: 87729
Buggy source:
public void testAllShortDisplayName(){
  for (  final InputMethodSubtype subtype : mSubtypesList) {
    final String subtypeName=SubtypeLocale.getSubtypeDisplayName(subtype);
    final Locale locale=SubtypeLocale.getSubtypeLocale(subtype);
    final String spacebarText=MainKeyboardView.getShortDisplayName(subtype);
    final String languageCode=StringUtils.capitalizeFirstCharacter(locale.getLanguage(),locale);
    if (SubtypeLocale.isNoLanguage(subtype)) {
      assertEquals(subtypeName,"String_Node_Str",spacebarText);
    }
 else {
      assertEquals(subtypeName,languageCode,spacebarText);
    }
  }
}

Fixed version (ground truth):
public void testAllShortDisplayName(){
  for (  final InputMethodSubtype subtype : mSubtypesList) {
    final String subtypeName=SubtypeLocale.getSubtypeDisplayName(subtype);
    final Locale locale=SubtypeLocale.getSubtypeLocale(subtype);
    final String spacebarText=MainKeyboardView.getShortDisplayName(subtype);
    final String languageCode=StringUtils.capitalizeFirstCodePoint(locale.getLanguage(),locale);
    if (SubtypeLocale.isNoLanguage(subtype)) {
      assertEquals(subtypeName,"String_Node_Str",spacebarText);
    }
 else {
      assertEquals(subtypeName,languageCode,spacebarText);
    }
  }
}
Program: 87730
Project: 87730
Buggy source:
private boolean isDevTeamBuild(){
  try {
    final PackageInfo packageInfo;
    packageInfo=mLatinIME.getPackageManager().getPackageInfo(mLatinIME.getPackageName(),0);
    final String versionName=packageInfo.versionName;
    return !(developerBuildRegex.matcher(versionName).find());
  }
 catch (  final NameNotFoundException e) {
    Log.e(TAG,"String_Node_Str",e);
    return false;
  }
}

Fixed version (ground truth):
private boolean isDevTeamBuild(){
  try {
    final PackageInfo packageInfo;
    packageInfo=mLatinIME.getPackageManager().getPackageInfo(mLatinIME.getPackageName(),0);
    final String versionName=packageInfo.versionName;
    return developerBuildRegex.matcher(versionName).find();
  }
 catch (  final NameNotFoundException e) {
    Log.e(TAG,"String_Node_Str",e);
    return false;
  }
}
Program: 87732
Project: 87732
Buggy source:
/** 
 * Waits for publication requests to finish, closes the JsonWriter, but then deletes the backing output file.
 * @param onAbort run after the abort() operation has completed asynchronously
 */
private synchronized void abort(final Runnable onAbort){
  mExecutor.submit(new Callable<Object>(){
    @Override public Object call() throws Exception {
      try {
        if (mHasWrittenData) {
          mJsonWriter.endArray();
          mJsonWriter.close();
          mHasWrittenData=false;
        }
      }
  finally {
        if (mFile != null) {
          mFile.delete();
        }
        if (onAbort != null) {
          onAbort.run();
        }
      }
      return null;
    }
  }
);
  removeAnyScheduledFlush();
  mExecutor.shutdown();
}

Fixed version (ground truth):
/** 
 * Waits for publication requests to finish, closes the JsonWriter, but then deletes the backing output file.
 * @param onAbort run after the abort() operation has completed asynchronously
 */
private synchronized void abort(final Runnable onAbort){
  mExecutor.submit(new Callable<Object>(){
    @Override public Object call() throws Exception {
      try {
        if (mHasWrittenData) {
          if (!mHasWrittenData) {
            mJsonWriter.beginArray();
          }
          mJsonWriter.endArray();
          mJsonWriter.close();
          mHasWrittenData=false;
        }
      }
  finally {
        if (mFile != null) {
          mFile.delete();
        }
        if (onAbort != null) {
          onAbort.run();
        }
      }
      return null;
    }
  }
);
  removeAnyScheduledFlush();
  mExecutor.shutdown();
}
Program: 87733
Project: 87733
Buggy source:
/** 
 * Waits for any publication requests to finish and closes the   {@link JsonWriter} used foroutput. See class comment for details about  {@code JsonWriter} construction.
 * @param onClosed run after the close() operation has completed asynchronously
 */
private synchronized void close(final Runnable onClosed){
  mExecutor.submit(new Callable<Object>(){
    @Override public Object call() throws Exception {
      try {
        if (mHasWrittenData) {
          mJsonWriter.endArray();
          mHasWrittenData=false;
        }
        mJsonWriter.flush();
        mJsonWriter.close();
        if (DEBUG) {
          Log.d(TAG,"String_Node_Str" + mFile);
        }
      }
 catch (      Exception e) {
        Log.d(TAG,"String_Node_Str",e);
      }
 finally {
        if (mFile != null && mFile.exists()) {
          mFile.setWritable(false,false);
        }
        if (onClosed != null) {
          onClosed.run();
        }
      }
      return null;
    }
  }
);
  removeAnyScheduledFlush();
  mExecutor.shutdown();
}

Fixed version (ground truth):
/** 
 * Waits for any publication requests to finish and closes the   {@link JsonWriter} used foroutput. See class comment for details about  {@code JsonWriter} construction.
 * @param onClosed run after the close() operation has completed asynchronously
 */
private synchronized void close(final Runnable onClosed){
  mExecutor.submit(new Callable<Object>(){
    @Override public Object call() throws Exception {
      try {
        if (!mHasWrittenData) {
          mJsonWriter.beginArray();
        }
        mJsonWriter.endArray();
        mHasWrittenData=false;
        mJsonWriter.flush();
        mJsonWriter.close();
        if (DEBUG) {
          Log.d(TAG,"String_Node_Str" + mFile);
        }
      }
 catch (      Exception e) {
        Log.d(TAG,"String_Node_Str",e);
      }
 finally {
        if (mFile != null && mFile.exists()) {
          mFile.setWritable(false,false);
        }
        if (onClosed != null) {
          onClosed.run();
        }
      }
      return null;
    }
  }
);
  removeAnyScheduledFlush();
  mExecutor.shutdown();
}
Program: 87735
Project: 87735
Buggy source:
protected void shiftOutWords(final int numWords){
  final int targetNumWords=mNumActualWords - numWords;
  final LinkedList<LogUnit> logUnits=getLogUnits();
  while (mNumActualWords > targetNumWords && !logUnits.isEmpty()) {
    shiftOut();
  }
}

Fixed version (ground truth):
/** 
 * Remove LogUnits from the front of the LogBuffer until   {@code numWords} have been removed.If there are less than  {@code numWords} word-containing {@link LogUnit}s, shifts out all   {@code LogUnit}s in the buffer.
 * @param numWords the number of word-containing {@link LogUnit}s to shift out
 * @return the number of actual {@code LogUnit}s shifted out
 */
protected int shiftOutWords(final int numWords){
  int numWordContainingLogUnitsShiftedOut=0;
  for (LogUnit logUnit=shiftOut(); logUnit != null && numWordContainingLogUnitsShiftedOut < numWords; logUnit=shiftOut()) {
    if (logUnit.hasWord()) {
      numWordContainingLogUnitsShiftedOut++;
    }
  }
  return numWordContainingLogUnitsShiftedOut;
}
Program: 87736
Project: 87736
Buggy source:
@Override protected void shiftOutWords(final int numWords){
  final int oldNumActualWords=getNumActualWords();
  super.shiftOutWords(numWords);
  final int numWordsShifted=oldNumActualWords - getNumActualWords();
  mNumWordsUntilSafeToSample-=numWordsShifted;
  if (DEBUG) {
    Log.d(TAG,"String_Node_Str" + mNumWordsUntilSafeToSample);
  }
}

Fixed version (ground truth):
@Override protected int shiftOutWords(final int numWords){
  final int numWordContainingLogUnitsShiftedOut=super.shiftOutWords(numWords);
  mNumWordsUntilSafeToSample=Math.max(0,mNumWordsUntilSafeToSample - numWordContainingLogUnitsShiftedOut);
  if (DEBUG) {
    Log.d(TAG,"String_Node_Str" + mNumWordsUntilSafeToSample);
  }
  return numWordContainingLogUnitsShiftedOut;
}
Program: 87737
Project: 87737
Buggy source:
protected final void publishLogUnitsAtFrontOfBuffer(){
  ArrayList<LogUnit> logUnits=peekAtFirstNWords(N_GRAM_SIZE);
  if (isSafeNGram(logUnits,N_GRAM_SIZE)) {
    publish(logUnits,true);
    shiftOutWords(N_GRAM_SIZE);
    resetWordCounter();
  }
 else {
    logUnits=peekAtFirstNWords(1);
    publish(logUnits,false);
    shiftOutWords(1);
  }
}

Fixed version (ground truth):
protected final void publishLogUnitsAtFrontOfBuffer(){
  ArrayList<LogUnit> logUnits=peekAtFirstNWords(N_GRAM_SIZE);
  if (isSafeNGram(logUnits,N_GRAM_SIZE)) {
    publish(logUnits,true);
    shiftOutWords(N_GRAM_SIZE);
    mNumWordsUntilSafeToSample=mNumWordsBetweenNGrams;
  }
 else {
    logUnits=peekAtFirstNWords(1);
    publish(logUnits,false);
    shiftOutWords(1);
  }
}
Program: 87738
Project: 87738
Buggy source:
/** 
 * Waits for publication requests to finish, closes the JsonWriter, but then deletes the backing output file.
 * @param onAbort run after the abort() operation has completed asynchronously
 */
private synchronized void abort(final Runnable onAbort){
  mExecutor.submit(new Callable<Object>(){
    @Override public Object call() throws Exception {
      try {
        if (mHasWrittenData) {
          mJsonWriter.endArray();
          mJsonWriter.close();
          mHasWrittenData=false;
        }
      }
  finally {
        if (mFile != null) {
          mFile.delete();
        }
        if (onAbort != null) {
          onAbort.run();
        }
      }
      return null;
    }
  }
);
  removeAnyScheduledFlush();
  mExecutor.shutdown();
}

Fixed version (ground truth):
/** 
 * Waits for publication requests to finish, closes the JsonWriter, but then deletes the backing output file.
 * @param onAbort run after the abort() operation has completed asynchronously
 */
private synchronized void abort(final Runnable onAbort){
  mExecutor.submit(new Callable<Object>(){
    @Override public Object call() throws Exception {
      try {
        if (mHasWrittenData) {
          if (!mHasWrittenData) {
            mJsonWriter.beginArray();
          }
          mJsonWriter.endArray();
          mJsonWriter.close();
          mHasWrittenData=false;
        }
      }
  finally {
        if (mFile != null) {
          mFile.delete();
        }
        if (onAbort != null) {
          onAbort.run();
        }
      }
      return null;
    }
  }
);
  removeAnyScheduledFlush();
  mExecutor.shutdown();
}