nus-yam/ex-repair huggingface dataset:
Program: 87649
Project: 87649
Buggy source:
void stop(){
  if (DEBUG) {
    Log.d(TAG,"String_Node_Str");
  }
  commitCurrentLogUnit();
  try {
    mMainLogBuffer.shiftAndPublishAll();
  }
 catch (  final IOException e) {
    Log.w(TAG,"String_Node_Str",e);
  }
  logStatistics();
  commitCurrentLogUnit();
  mMainLogBuffer.setIsStopping();
  try {
    mMainLogBuffer.shiftAndPublishAll();
  }
 catch (  final IOException e) {
    Log.w(TAG,"String_Node_Str",e);
  }
  mMainResearchLog.blockingClose(RESEARCHLOG_CLOSE_TIMEOUT_IN_MS);
  resetLogBuffers();
}

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

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

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

Fixed version (ground truth):
/** 
 * Remove leading/trailing whitespace from the considered string.
 */
public void trim(){
  final int len=mStringBefore.length();
  int nonWhitespaceStart=0;
  for (; nonWhitespaceStart < len; nonWhitespaceStart=mStringBefore.offsetByCodePoints(nonWhitespaceStart,1)) {
    final int codePoint=mStringBefore.codePointAt(nonWhitespaceStart);
    if (!Character.isWhitespace(codePoint))     break;
  }
  int nonWhitespaceEnd=len;
  for (; nonWhitespaceEnd > 0; nonWhitespaceEnd=mStringBefore.offsetByCodePoints(nonWhitespaceEnd,-1)) {
    final int codePoint=mStringBefore.codePointBefore(nonWhitespaceEnd);
    if (!Character.isWhitespace(codePoint))     break;
  }
  if ((0 != nonWhitespaceStart || len != nonWhitespaceEnd) && nonWhitespaceStart < nonWhitespaceEnd) {
    mCursorEndAfter=mCursorStartBefore + nonWhitespaceEnd;
    mCursorStartBefore=mCursorStartAfter=mCursorStartBefore + nonWhitespaceStart;
    mStringAfter=mStringBefore=mStringBefore.substring(nonWhitespaceStart,nonWhitespaceEnd);
  }
}
Program: 87653
Project: 87653
Buggy source:
void stop(){
  if (DEBUG) {
    Log.d(TAG,"String_Node_Str");
  }
  commitCurrentLogUnit();
  try {
    mMainLogBuffer.shiftAndPublishAll();
  }
 catch (  final IOException e) {
    Log.w(TAG,"String_Node_Str",e);
  }
  logStatistics();
  commitCurrentLogUnit();
  mMainLogBuffer.setIsStopping();
  try {
    mMainLogBuffer.shiftAndPublishAll();
  }
 catch (  final IOException e) {
    Log.w(TAG,"String_Node_Str",e);
  }
  mMainResearchLog.blockingClose(RESEARCHLOG_CLOSE_TIMEOUT_IN_MS);
  resetLogBuffers();
}

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

Fixed version (ground truth):
public void initSuggest(final Suggest suggest){
  mSuggest=suggest;
  if (mMainLogBuffer != null) {
    restart();
  }
}
Program: 87655
Project: 87655
Buggy source:
private static double degreeToRadian(final int degree){
  return (double)degree / 180.0d * Math.PI;
}

Fixed version (ground truth):
private static double degreeToRadian(final int degree){
  return degree / 180.0d * Math.PI;
}
Program: 87656
Project: 87656
Buggy source:
public void appendPreviewStroke(final ResizableIntArray eventTimes,final ResizableIntArray xCoords,final ResizableIntArray yCoords){
  final int length=mPreviewEventTimes.getLength() - mLastPreviewSize;
  if (length <= 0) {
    return;
  }
  eventTimes.append(mPreviewEventTimes,mLastPreviewSize,length);
  xCoords.append(mPreviewXCoordinates,mLastPreviewSize,length);
  yCoords.append(mPreviewYCoordinates,mLastPreviewSize,length);
  mLastPreviewSize=mPreviewEventTimes.getLength();
}

Fixed version (ground truth):
/** 
 * Append sampled preview points.
 * @param eventTimes the event time array of gesture trail to be drawn.
 * @param xCoords the x-coordinates array of gesture trail to be drawn.
 * @param yCoords the y-coordinates array of gesture trail to be drawn.
 * @param types the point types array of gesture trail. This is valid only when{@link GestureTrail#DEBUG_SHOW_POINTS} is true.
 */
public void appendPreviewStroke(final ResizableIntArray eventTimes,final ResizableIntArray xCoords,final ResizableIntArray yCoords,final ResizableIntArray types){
  final int length=mPreviewEventTimes.getLength() - mLastPreviewSize;
  if (length <= 0) {
    return;
  }
  eventTimes.append(mPreviewEventTimes,mLastPreviewSize,length);
  xCoords.append(mPreviewXCoordinates,mLastPreviewSize,length);
  yCoords.append(mPreviewYCoordinates,mLastPreviewSize,length);
  if (GestureTrail.DEBUG_SHOW_POINTS) {
    types.fill(GestureTrail.POINT_TYPE_SAMPLED,types.getLength(),length);
  }
  mLastPreviewSize=mPreviewEventTimes.getLength();
}
Program: 87659
Project: 87659
Buggy source:
public Params(final TypedArray mainKeyboardViewAttr){
  mTrailColor=mainKeyboardViewAttr.getColor(R.styleable.MainKeyboardView_gestureTrailColor,0);
  mTrailStartWidth=mainKeyboardViewAttr.getDimension(R.styleable.MainKeyboardView_gestureTrailStartWidth,0.0f);
  mTrailEndWidth=mainKeyboardViewAttr.getDimension(R.styleable.MainKeyboardView_gestureTrailEndWidth,0.0f);
  final int PERCENTAGE_INT=100;
  mTrailBodyRatio=(float)mainKeyboardViewAttr.getInt(R.styleable.MainKeyboardView_gestureTrailBodyRatio,PERCENTAGE_INT) / (float)PERCENTAGE_INT;
  final int trailShadowRatioInt=mainKeyboardViewAttr.getInt(R.styleable.MainKeyboardView_gestureTrailShadowRatio,0);
  mTrailShadowEnabled=(trailShadowRatioInt > 0);
  mTrailShadowRatio=(float)trailShadowRatioInt / (float)PERCENTAGE_INT;
  mFadeoutStartDelay=DBG_SHOW_POINTS ? 2000 : mainKeyboardViewAttr.getInt(R.styleable.MainKeyboardView_gestureTrailFadeoutStartDelay,0);
  mFadeoutDuration=DBG_SHOW_POINTS ? 200 : mainKeyboardViewAttr.getInt(R.styleable.MainKeyboardView_gestureTrailFadeoutDuration,0);
  mTrailLingerDuration=mFadeoutStartDelay + mFadeoutDuration;
  mUpdateInterval=mainKeyboardViewAttr.getInt(R.styleable.MainKeyboardView_gestureTrailUpdateInterval,0);
}

Fixed version (ground truth):
public Params(final TypedArray mainKeyboardViewAttr){
  mTrailColor=mainKeyboardViewAttr.getColor(R.styleable.MainKeyboardView_gestureTrailColor,0);
  mTrailStartWidth=mainKeyboardViewAttr.getDimension(R.styleable.MainKeyboardView_gestureTrailStartWidth,0.0f);
  mTrailEndWidth=mainKeyboardViewAttr.getDimension(R.styleable.MainKeyboardView_gestureTrailEndWidth,0.0f);
  final int PERCENTAGE_INT=100;
  mTrailBodyRatio=(float)mainKeyboardViewAttr.getInt(R.styleable.MainKeyboardView_gestureTrailBodyRatio,PERCENTAGE_INT) / (float)PERCENTAGE_INT;
  final int trailShadowRatioInt=mainKeyboardViewAttr.getInt(R.styleable.MainKeyboardView_gestureTrailShadowRatio,0);
  mTrailShadowEnabled=(trailShadowRatioInt > 0);
  mTrailShadowRatio=(float)trailShadowRatioInt / (float)PERCENTAGE_INT;
  mFadeoutStartDelay=DEBUG_SHOW_POINTS ? FADEOUT_START_DELAY_FOR_DEBUG : mainKeyboardViewAttr.getInt(R.styleable.MainKeyboardView_gestureTrailFadeoutStartDelay,0);
  mFadeoutDuration=DEBUG_SHOW_POINTS ? FADEOUT_DURATION_FOR_DEBUG : mainKeyboardViewAttr.getInt(R.styleable.MainKeyboardView_gestureTrailFadeoutDuration,0);
  mTrailLingerDuration=mFadeoutStartDelay + mFadeoutDuration;
  mUpdateInterval=mainKeyboardViewAttr.getInt(R.styleable.MainKeyboardView_gestureTrailUpdateInterval,0);
}
Program: 87660
Project: 87660
Buggy source:
private void addStrokeLocked(final GestureStrokeWithPreviewPoints stroke,final long downTime){
  final int trailSize=mEventTimes.getLength();
  stroke.appendPreviewStroke(mEventTimes,mXCoordinates,mYCoordinates);
  if (mEventTimes.getLength() == trailSize) {
    return;
  }
  final int[] eventTimes=mEventTimes.getPrimitiveArray();
  final int strokeId=stroke.getGestureStrokeId();
  final int lastInterpolatedIndex=(strokeId == mCurrentStrokeId) ? mLastInterpolatedDrawIndex : trailSize;
  mLastInterpolatedDrawIndex=stroke.interpolateStrokeAndReturnStartIndexOfLastSegment(lastInterpolatedIndex,mEventTimes,mXCoordinates,mYCoordinates,mPointTypes);
  if (strokeId != mCurrentStrokeId) {
    final int elapsedTime=(int)(downTime - mCurrentTimeBase);
    for (int i=mTrailStartIndex; i < trailSize; i++) {
      eventTimes[i]-=elapsedTime;
    }
    final int[] xCoords=mXCoordinates.getPrimitiveArray();
    final int downIndex=trailSize;
    xCoords[downIndex]=markAsDownEvent(xCoords[downIndex]);
    mCurrentTimeBase=downTime - eventTimes[downIndex];
    mCurrentStrokeId=strokeId;
  }
}

Fixed version (ground truth):
private void addStrokeLocked(final GestureStrokeWithPreviewPoints stroke,final long downTime){
  final int trailSize=mEventTimes.getLength();
  stroke.appendPreviewStroke(mEventTimes,mXCoordinates,mYCoordinates,mPointTypes);
  if (mEventTimes.getLength() == trailSize) {
    return;
  }
  final int[] eventTimes=mEventTimes.getPrimitiveArray();
  final int strokeId=stroke.getGestureStrokeId();
  final int lastInterpolatedIndex=(strokeId == mCurrentStrokeId) ? mLastInterpolatedDrawIndex : trailSize;
  mLastInterpolatedDrawIndex=stroke.interpolateStrokeAndReturnStartIndexOfLastSegment(lastInterpolatedIndex,mEventTimes,mXCoordinates,mYCoordinates,mPointTypes);
  if (strokeId != mCurrentStrokeId) {
    final int elapsedTime=(int)(downTime - mCurrentTimeBase);
    for (int i=mTrailStartIndex; i < trailSize; i++) {
      eventTimes[i]-=elapsedTime;
    }
    final int[] xCoords=mXCoordinates.getPrimitiveArray();
    final int downIndex=trailSize;
    xCoords[downIndex]=markAsDownEvent(xCoords[downIndex]);
    mCurrentTimeBase=downTime - eventTimes[downIndex];
    mCurrentStrokeId=strokeId;
  }
}
Program: 87661
Project: 87661
Buggy source:
private static double degreeToRadian(final int degree){
  return (double)degree / 180.0d * Math.PI;
}

Fixed version (ground truth):
private static double degreeToRadian(final int degree){
  return degree / 180.0d * Math.PI;
}
Program: 87662
Project: 87662
Buggy source:
public void appendPreviewStroke(final ResizableIntArray eventTimes,final ResizableIntArray xCoords,final ResizableIntArray yCoords){
  final int length=mPreviewEventTimes.getLength() - mLastPreviewSize;
  if (length <= 0) {
    return;
  }
  eventTimes.append(mPreviewEventTimes,mLastPreviewSize,length);
  xCoords.append(mPreviewXCoordinates,mLastPreviewSize,length);
  yCoords.append(mPreviewYCoordinates,mLastPreviewSize,length);
  mLastPreviewSize=mPreviewEventTimes.getLength();
}

Fixed version (ground truth):
/** 
 * Append sampled preview points.
 * @param eventTimes the event time array of gesture trail to be drawn.
 * @param xCoords the x-coordinates array of gesture trail to be drawn.
 * @param yCoords the y-coordinates array of gesture trail to be drawn.
 * @param types the point types array of gesture trail. This is valid only when{@link GestureTrail#DEBUG_SHOW_POINTS} is true.
 */
public void appendPreviewStroke(final ResizableIntArray eventTimes,final ResizableIntArray xCoords,final ResizableIntArray yCoords,final ResizableIntArray types){
  final int length=mPreviewEventTimes.getLength() - mLastPreviewSize;
  if (length <= 0) {
    return;
  }
  eventTimes.append(mPreviewEventTimes,mLastPreviewSize,length);
  xCoords.append(mPreviewXCoordinates,mLastPreviewSize,length);
  yCoords.append(mPreviewYCoordinates,mLastPreviewSize,length);
  if (GestureTrail.DEBUG_SHOW_POINTS) {
    types.fill(GestureTrail.POINT_TYPE_SAMPLED,types.getLength(),length);
  }
  mLastPreviewSize=mPreviewEventTimes.getLength();
}
Program: 87665
Project: 87665
Buggy source:
public Params(final TypedArray mainKeyboardViewAttr){
  mTrailColor=mainKeyboardViewAttr.getColor(R.styleable.MainKeyboardView_gestureTrailColor,0);
  mTrailStartWidth=mainKeyboardViewAttr.getDimension(R.styleable.MainKeyboardView_gestureTrailStartWidth,0.0f);
  mTrailEndWidth=mainKeyboardViewAttr.getDimension(R.styleable.MainKeyboardView_gestureTrailEndWidth,0.0f);
  final int PERCENTAGE_INT=100;
  mTrailBodyRatio=(float)mainKeyboardViewAttr.getInt(R.styleable.MainKeyboardView_gestureTrailBodyRatio,PERCENTAGE_INT) / (float)PERCENTAGE_INT;
  final int trailShadowRatioInt=mainKeyboardViewAttr.getInt(R.styleable.MainKeyboardView_gestureTrailShadowRatio,0);
  mTrailShadowEnabled=(trailShadowRatioInt > 0);
  mTrailShadowRatio=(float)trailShadowRatioInt / (float)PERCENTAGE_INT;
  mFadeoutStartDelay=DBG_SHOW_POINTS ? 2000 : mainKeyboardViewAttr.getInt(R.styleable.MainKeyboardView_gestureTrailFadeoutStartDelay,0);
  mFadeoutDuration=DBG_SHOW_POINTS ? 200 : mainKeyboardViewAttr.getInt(R.styleable.MainKeyboardView_gestureTrailFadeoutDuration,0);
  mTrailLingerDuration=mFadeoutStartDelay + mFadeoutDuration;
  mUpdateInterval=mainKeyboardViewAttr.getInt(R.styleable.MainKeyboardView_gestureTrailUpdateInterval,0);
}

Fixed version (ground truth):
public Params(final TypedArray mainKeyboardViewAttr){
  mTrailColor=mainKeyboardViewAttr.getColor(R.styleable.MainKeyboardView_gestureTrailColor,0);
  mTrailStartWidth=mainKeyboardViewAttr.getDimension(R.styleable.MainKeyboardView_gestureTrailStartWidth,0.0f);
  mTrailEndWidth=mainKeyboardViewAttr.getDimension(R.styleable.MainKeyboardView_gestureTrailEndWidth,0.0f);
  final int PERCENTAGE_INT=100;
  mTrailBodyRatio=(float)mainKeyboardViewAttr.getInt(R.styleable.MainKeyboardView_gestureTrailBodyRatio,PERCENTAGE_INT) / (float)PERCENTAGE_INT;
  final int trailShadowRatioInt=mainKeyboardViewAttr.getInt(R.styleable.MainKeyboardView_gestureTrailShadowRatio,0);
  mTrailShadowEnabled=(trailShadowRatioInt > 0);
  mTrailShadowRatio=(float)trailShadowRatioInt / (float)PERCENTAGE_INT;
  mFadeoutStartDelay=DEBUG_SHOW_POINTS ? FADEOUT_START_DELAY_FOR_DEBUG : mainKeyboardViewAttr.getInt(R.styleable.MainKeyboardView_gestureTrailFadeoutStartDelay,0);
  mFadeoutDuration=DEBUG_SHOW_POINTS ? FADEOUT_DURATION_FOR_DEBUG : mainKeyboardViewAttr.getInt(R.styleable.MainKeyboardView_gestureTrailFadeoutDuration,0);
  mTrailLingerDuration=mFadeoutStartDelay + mFadeoutDuration;
  mUpdateInterval=mainKeyboardViewAttr.getInt(R.styleable.MainKeyboardView_gestureTrailUpdateInterval,0);
}
Program: 87666
Project: 87666
Buggy source:
private void addStrokeLocked(final GestureStrokeWithPreviewPoints stroke,final long downTime){
  final int trailSize=mEventTimes.getLength();
  stroke.appendPreviewStroke(mEventTimes,mXCoordinates,mYCoordinates);
  if (mEventTimes.getLength() == trailSize) {
    return;
  }
  final int[] eventTimes=mEventTimes.getPrimitiveArray();
  final int strokeId=stroke.getGestureStrokeId();
  final int lastInterpolatedIndex=(strokeId == mCurrentStrokeId) ? mLastInterpolatedDrawIndex : trailSize;
  mLastInterpolatedDrawIndex=stroke.interpolateStrokeAndReturnStartIndexOfLastSegment(lastInterpolatedIndex,mEventTimes,mXCoordinates,mYCoordinates,mPointTypes);
  if (strokeId != mCurrentStrokeId) {
    final int elapsedTime=(int)(downTime - mCurrentTimeBase);
    for (int i=mTrailStartIndex; i < trailSize; i++) {
      eventTimes[i]-=elapsedTime;
    }
    final int[] xCoords=mXCoordinates.getPrimitiveArray();
    final int downIndex=trailSize;
    xCoords[downIndex]=markAsDownEvent(xCoords[downIndex]);
    mCurrentTimeBase=downTime - eventTimes[downIndex];
    mCurrentStrokeId=strokeId;
  }
}

Fixed version (ground truth):
private void addStrokeLocked(final GestureStrokeWithPreviewPoints stroke,final long downTime){
  final int trailSize=mEventTimes.getLength();
  stroke.appendPreviewStroke(mEventTimes,mXCoordinates,mYCoordinates,mPointTypes);
  if (mEventTimes.getLength() == trailSize) {
    return;
  }
  final int[] eventTimes=mEventTimes.getPrimitiveArray();
  final int strokeId=stroke.getGestureStrokeId();
  final int lastInterpolatedIndex=(strokeId == mCurrentStrokeId) ? mLastInterpolatedDrawIndex : trailSize;
  mLastInterpolatedDrawIndex=stroke.interpolateStrokeAndReturnStartIndexOfLastSegment(lastInterpolatedIndex,mEventTimes,mXCoordinates,mYCoordinates,mPointTypes);
  if (strokeId != mCurrentStrokeId) {
    final int elapsedTime=(int)(downTime - mCurrentTimeBase);
    for (int i=mTrailStartIndex; i < trailSize; i++) {
      eventTimes[i]-=elapsedTime;
    }
    final int[] xCoords=mXCoordinates.getPrimitiveArray();
    final int downIndex=trailSize;
    xCoords[downIndex]=markAsDownEvent(xCoords[downIndex]);
    mCurrentTimeBase=downTime - eventTimes[downIndex];
    mCurrentStrokeId=strokeId;
  }
}
Program: 87667
Project: 87667
Buggy source:
private static double degreeToRadian(final int degree){
  return (double)degree / 180.0d * Math.PI;
}

Fixed version (ground truth):
private static double degreeToRadian(final int degree){
  return degree / 180.0d * Math.PI;
}
Program: 87668
Project: 87668
Buggy source:
public void appendPreviewStroke(final ResizableIntArray eventTimes,final ResizableIntArray xCoords,final ResizableIntArray yCoords){
  final int length=mPreviewEventTimes.getLength() - mLastPreviewSize;
  if (length <= 0) {
    return;
  }
  eventTimes.append(mPreviewEventTimes,mLastPreviewSize,length);
  xCoords.append(mPreviewXCoordinates,mLastPreviewSize,length);
  yCoords.append(mPreviewYCoordinates,mLastPreviewSize,length);
  mLastPreviewSize=mPreviewEventTimes.getLength();
}

Fixed version (ground truth):
/** 
 * Append sampled preview points.
 * @param eventTimes the event time array of gesture trail to be drawn.
 * @param xCoords the x-coordinates array of gesture trail to be drawn.
 * @param yCoords the y-coordinates array of gesture trail to be drawn.
 * @param types the point types array of gesture trail. This is valid only when{@link GestureTrail#DEBUG_SHOW_POINTS} is true.
 */
public void appendPreviewStroke(final ResizableIntArray eventTimes,final ResizableIntArray xCoords,final ResizableIntArray yCoords,final ResizableIntArray types){
  final int length=mPreviewEventTimes.getLength() - mLastPreviewSize;
  if (length <= 0) {
    return;
  }
  eventTimes.append(mPreviewEventTimes,mLastPreviewSize,length);
  xCoords.append(mPreviewXCoordinates,mLastPreviewSize,length);
  yCoords.append(mPreviewYCoordinates,mLastPreviewSize,length);
  if (GestureTrail.DEBUG_SHOW_POINTS) {
    types.fill(GestureTrail.POINT_TYPE_SAMPLED,types.getLength(),length);
  }
  mLastPreviewSize=mPreviewEventTimes.getLength();
}
Program: 87671
Project: 87671
Buggy source:
public Params(final TypedArray mainKeyboardViewAttr){
  mTrailColor=mainKeyboardViewAttr.getColor(R.styleable.MainKeyboardView_gestureTrailColor,0);
  mTrailStartWidth=mainKeyboardViewAttr.getDimension(R.styleable.MainKeyboardView_gestureTrailStartWidth,0.0f);
  mTrailEndWidth=mainKeyboardViewAttr.getDimension(R.styleable.MainKeyboardView_gestureTrailEndWidth,0.0f);
  final int PERCENTAGE_INT=100;
  mTrailBodyRatio=(float)mainKeyboardViewAttr.getInt(R.styleable.MainKeyboardView_gestureTrailBodyRatio,PERCENTAGE_INT) / (float)PERCENTAGE_INT;
  final int trailShadowRatioInt=mainKeyboardViewAttr.getInt(R.styleable.MainKeyboardView_gestureTrailShadowRatio,0);
  mTrailShadowEnabled=(trailShadowRatioInt > 0);
  mTrailShadowRatio=(float)trailShadowRatioInt / (float)PERCENTAGE_INT;
  mFadeoutStartDelay=DBG_SHOW_POINTS ? 2000 : mainKeyboardViewAttr.getInt(R.styleable.MainKeyboardView_gestureTrailFadeoutStartDelay,0);
  mFadeoutDuration=DBG_SHOW_POINTS ? 200 : mainKeyboardViewAttr.getInt(R.styleable.MainKeyboardView_gestureTrailFadeoutDuration,0);
  mTrailLingerDuration=mFadeoutStartDelay + mFadeoutDuration;
  mUpdateInterval=mainKeyboardViewAttr.getInt(R.styleable.MainKeyboardView_gestureTrailUpdateInterval,0);
}

Fixed version (ground truth):
public Params(final TypedArray mainKeyboardViewAttr){
  mTrailColor=mainKeyboardViewAttr.getColor(R.styleable.MainKeyboardView_gestureTrailColor,0);
  mTrailStartWidth=mainKeyboardViewAttr.getDimension(R.styleable.MainKeyboardView_gestureTrailStartWidth,0.0f);
  mTrailEndWidth=mainKeyboardViewAttr.getDimension(R.styleable.MainKeyboardView_gestureTrailEndWidth,0.0f);
  final int PERCENTAGE_INT=100;
  mTrailBodyRatio=(float)mainKeyboardViewAttr.getInt(R.styleable.MainKeyboardView_gestureTrailBodyRatio,PERCENTAGE_INT) / (float)PERCENTAGE_INT;
  final int trailShadowRatioInt=mainKeyboardViewAttr.getInt(R.styleable.MainKeyboardView_gestureTrailShadowRatio,0);
  mTrailShadowEnabled=(trailShadowRatioInt > 0);
  mTrailShadowRatio=(float)trailShadowRatioInt / (float)PERCENTAGE_INT;
  mFadeoutStartDelay=DEBUG_SHOW_POINTS ? FADEOUT_START_DELAY_FOR_DEBUG : mainKeyboardViewAttr.getInt(R.styleable.MainKeyboardView_gestureTrailFadeoutStartDelay,0);
  mFadeoutDuration=DEBUG_SHOW_POINTS ? FADEOUT_DURATION_FOR_DEBUG : mainKeyboardViewAttr.getInt(R.styleable.MainKeyboardView_gestureTrailFadeoutDuration,0);
  mTrailLingerDuration=mFadeoutStartDelay + mFadeoutDuration;
  mUpdateInterval=mainKeyboardViewAttr.getInt(R.styleable.MainKeyboardView_gestureTrailUpdateInterval,0);
}
Program: 87672
Project: 87672
Buggy source:
private void addStrokeLocked(final GestureStrokeWithPreviewPoints stroke,final long downTime){
  final int trailSize=mEventTimes.getLength();
  stroke.appendPreviewStroke(mEventTimes,mXCoordinates,mYCoordinates);
  if (mEventTimes.getLength() == trailSize) {
    return;
  }
  final int[] eventTimes=mEventTimes.getPrimitiveArray();
  final int strokeId=stroke.getGestureStrokeId();
  final int lastInterpolatedIndex=(strokeId == mCurrentStrokeId) ? mLastInterpolatedDrawIndex : trailSize;
  mLastInterpolatedDrawIndex=stroke.interpolateStrokeAndReturnStartIndexOfLastSegment(lastInterpolatedIndex,mEventTimes,mXCoordinates,mYCoordinates,mPointTypes);
  if (strokeId != mCurrentStrokeId) {
    final int elapsedTime=(int)(downTime - mCurrentTimeBase);
    for (int i=mTrailStartIndex; i < trailSize; i++) {
      eventTimes[i]-=elapsedTime;
    }
    final int[] xCoords=mXCoordinates.getPrimitiveArray();
    final int downIndex=trailSize;
    xCoords[downIndex]=markAsDownEvent(xCoords[downIndex]);
    mCurrentTimeBase=downTime - eventTimes[downIndex];
    mCurrentStrokeId=strokeId;
  }
}

Fixed version (ground truth):
private void addStrokeLocked(final GestureStrokeWithPreviewPoints stroke,final long downTime){
  final int trailSize=mEventTimes.getLength();
  stroke.appendPreviewStroke(mEventTimes,mXCoordinates,mYCoordinates,mPointTypes);
  if (mEventTimes.getLength() == trailSize) {
    return;
  }
  final int[] eventTimes=mEventTimes.getPrimitiveArray();
  final int strokeId=stroke.getGestureStrokeId();
  final int lastInterpolatedIndex=(strokeId == mCurrentStrokeId) ? mLastInterpolatedDrawIndex : trailSize;
  mLastInterpolatedDrawIndex=stroke.interpolateStrokeAndReturnStartIndexOfLastSegment(lastInterpolatedIndex,mEventTimes,mXCoordinates,mYCoordinates,mPointTypes);
  if (strokeId != mCurrentStrokeId) {
    final int elapsedTime=(int)(downTime - mCurrentTimeBase);
    for (int i=mTrailStartIndex; i < trailSize; i++) {
      eventTimes[i]-=elapsedTime;
    }
    final int[] xCoords=mXCoordinates.getPrimitiveArray();
    final int downIndex=trailSize;
    xCoords[downIndex]=markAsDownEvent(xCoords[downIndex]);
    mCurrentTimeBase=downTime - eventTimes[downIndex];
    mCurrentStrokeId=strokeId;
  }
}
Program: 87673
Project: 87673
Buggy source:
@Override protected void onPause(){
  mWelcomeVideoView.stopPlayback();
  super.onPause();
}

Fixed version (ground truth):
@Override protected void onPause(){
  hideAndStopVideo(mWelcomeVideoView);
  super.onPause();
}
Program: 87674
Project: 87674
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: 87676
Project: 87676
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: 87677
Project: 87677
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: 87678
Project: 87678
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: 87679
Project: 87679
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: 87680
Project: 87680
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: 87681
Project: 87681
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: 87682
Project: 87682
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: 87683
Project: 87683
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: 87684
Project: 87684
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: 87685
Project: 87685
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: 87686
Project: 87686
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: 87687
Project: 87687
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: 87688
Project: 87688
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: 87689
Project: 87689
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: 87690
Project: 87690
Buggy source:
@Override protected void onPause(){
  mWelcomeVideoView.stopPlayback();
  super.onPause();
}

Fixed version (ground truth):
@Override protected void onPause(){
  hideAndStopVideo(mWelcomeVideoView);
  super.onPause();
}
Program: 87691
Project: 87691
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: 87693
Project: 87693
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: 87694
Project: 87694
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;
}