nus-yam/ex-repair huggingface dataset:
Program: 199660
Project: 199660
Buggy source:
public boolean performItemAction(MenuItem item,int flags){
  MenuItemImpl itemImpl=(MenuItemImpl)item;
  if (itemImpl == null || !itemImpl.isEnabled()) {
    return false;
  }
  boolean invoked=itemImpl.invoke();
  final ActionProvider provider=item.getActionProvider();
  final boolean providerHasSubMenu=provider != null && provider.hasSubMenu();
  if (itemImpl.hasCollapsibleActionView()) {
    invoked|=itemImpl.expandActionView();
    if (invoked)     close(true);
  }
 else   if (itemImpl.hasSubMenu() || providerHasSubMenu) {
    close(false);
    if (!itemImpl.hasSubMenu()) {
      itemImpl.setSubMenu(new SubMenuBuilder(getContext(),this,itemImpl));
    }
    final SubMenuBuilder subMenu=(SubMenuBuilder)itemImpl.getSubMenu();
    if (providerHasSubMenu) {
      provider.onPrepareSubMenu(subMenu);
    }
    invoked|=dispatchSubMenuSelected(subMenu);
    if (!invoked)     close(true);
  }
 else {
    if ((flags & FLAG_PERFORM_NO_CLOSE) == 0) {
      close(true);
    }
  }
  return invoked;
}

Fixed version (ground truth):
public boolean performItemAction(MenuItem item,MenuPresenter preferredPresenter,int flags){
  MenuItemImpl itemImpl=(MenuItemImpl)item;
  if (itemImpl == null || !itemImpl.isEnabled()) {
    return false;
  }
  boolean invoked=itemImpl.invoke();
  final ActionProvider provider=item.getActionProvider();
  final boolean providerHasSubMenu=provider != null && provider.hasSubMenu();
  if (itemImpl.hasCollapsibleActionView()) {
    invoked|=itemImpl.expandActionView();
    if (invoked)     close(true);
  }
 else   if (itemImpl.hasSubMenu() || providerHasSubMenu) {
    close(false);
    if (!itemImpl.hasSubMenu()) {
      itemImpl.setSubMenu(new SubMenuBuilder(getContext(),this,itemImpl));
    }
    final SubMenuBuilder subMenu=(SubMenuBuilder)itemImpl.getSubMenu();
    if (providerHasSubMenu) {
      provider.onPrepareSubMenu(subMenu);
    }
    invoked|=dispatchSubMenuSelected(subMenu,preferredPresenter);
    if (!invoked)     close(true);
  }
 else {
    if ((flags & FLAG_PERFORM_NO_CLOSE) == 0) {
      close(true);
    }
  }
  return invoked;
}
Program: 199662
Project: 199662
Buggy source:
private void helpDestroy(){
  boolean shouldDestroy=false;
synchronized (this) {
    if (!mDestroyed) {
      shouldDestroy=true;
      mDestroyed=true;
    }
  }
  if (shouldDestroy) {
    ReentrantReadWriteLock.ReadLock rlock=mRS.mRWLock.readLock();
    rlock.lock();
    if (mRS.isAlive() && mID != 0) {
      mRS.nObjDestroy(mID);
    }
    mRS=null;
    mID=0;
    mDestroyed=true;
  }
  super.finalize();
}

Fixed version (ground truth):
private void helpDestroy(){
  boolean shouldDestroy=false;
synchronized (this) {
    if (!mDestroyed) {
      shouldDestroy=true;
      mDestroyed=true;
    }
  }
  if (shouldDestroy) {
    ReentrantReadWriteLock.ReadLock rlock=mRS.mRWLock.readLock();
    rlock.lock();
    if (mRS.isAlive() && mID != 0) {
      mRS.nObjDestroy(mID);
    }
    rlock.unlock();
    mRS=null;
    mID=0;
  }
}
Program: 199663
Project: 199663
Buggy source:
/** 
 * Frees any native resources associated with this object.  The primary use is to force immediate cleanup of resources when it is believed the GC will not respond quickly enough.
 */
synchronized public void destroy(){
  if (mDestroyed) {
    throw new RSInvalidStateException("String_Node_Str");
  }
  mDestroyed=true;
  mRS.nObjDestroy(mID);
}

Fixed version (ground truth):
/** 
 * Frees any native resources associated with this object.  The primary use is to force immediate cleanup of resources when it is believed the GC will not respond quickly enough.
 */
public void destroy(){
  if (mDestroyed) {
    throw new RSInvalidStateException("String_Node_Str");
  }
  helpDestroy();
}
Program: 199664
Project: 199664
Buggy source:
/** 
 * Implement this to handle requests to delete one or more rows. The implementation should apply the selection clause when performing deletion, allowing the operation to affect multiple rows in a directory. As a courtesy, call   {@link ContentResolver#notifyChange(android.net.Uri,android.database.ContentObserver) notifyDelete()}after deleting. This method can be called from multiple threads, as described in <a href="  {@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes and Threads</a>. <p>The implementation is responsible for parsing out a row ID at the end of the URI, if a specific row is being deleted. That is, the client would pass in <code>content://contacts/people/22</code> and the implementation is responsible for parsing the record number (22) when creating a SQL statement.
 * @param uri The full URI to query, including a row ID (if a specific record is requested).
 * @param selection An optional restriction to apply to rows when deleting.
 * @return The number of rows affected.
 * @throws SQLException
 */
public abstract int delete(Uri uri,String selection,String[] selectionArgs);

Fixed version (ground truth):
/** 
 * Implement this to handle requests to delete one or more rows. The implementation should apply the selection clause when performing deletion, allowing the operation to affect multiple rows in a directory. As a courtesy, call   {@link ContentResolver#notifyChange(android.net.Uri,android.database.ContentObserver) notifyChange()}after deleting. This method can be called from multiple threads, as described in <a href="  {@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes and Threads</a>. <p>The implementation is responsible for parsing out a row ID at the end of the URI, if a specific row is being deleted. That is, the client would pass in <code>content://contacts/people/22</code> and the implementation is responsible for parsing the record number (22) when creating a SQL statement.
 * @param uri The full URI to query, including a row ID (if a specific record is requested).
 * @param selection An optional restriction to apply to rows when deleting.
 * @return The number of rows affected.
 * @throws SQLException
 */
public abstract int delete(Uri uri,String selection,String[] selectionArgs);
Program: 199665
Project: 199665
Buggy source:
/** 
 * Sets the right position of this view relative to its parent. This method is meant to be called by the layout system and should not generally be called otherwise, because the property may be changed at any time by the layout.
 * @param right The bottom of this view, in pixels.
 */
public final void setRight(int right){
  if (right != mRight) {
    updateMatrix();
    final boolean matrixIsIdentity=mTransformationInfo == null || mTransformationInfo.mMatrixIsIdentity;
    if (matrixIsIdentity) {
      if (mAttachInfo != null) {
        int maxRight;
        if (right < mRight) {
          maxRight=mRight;
        }
 else {
          maxRight=right;
        }
        invalidate(0,0,maxRight - mLeft,mBottom - mTop);
      }
    }
 else {
      invalidate(true);
    }
    int oldWidth=mRight - mLeft;
    int height=mBottom - mTop;
    mRight=right;
    if (mDisplayList != null) {
      mDisplayList.setRight(mRight);
    }
    sizeChange(mRight - mLeft,height,oldWidth,height);
    if (!matrixIsIdentity) {
      if ((mPrivateFlags & PFLAG_PIVOT_EXPLICITLY_SET) == 0) {
        mTransformationInfo.mMatrixDirty=true;
      }
      mPrivateFlags|=PFLAG_DRAWN;
      invalidate(true);
    }
    mBackgroundSizeChanged=true;
    invalidateParentIfNeeded();
    if ((mPrivateFlags2 & PFLAG2_VIEW_QUICK_REJECTED) == PFLAG2_VIEW_QUICK_REJECTED) {
      invalidateParentIfNeeded();
    }
  }
}

Fixed version (ground truth):
/** 
 * Sets the right position of this view relative to its parent. This method is meant to be called by the layout system and should not generally be called otherwise, because the property may be changed at any time by the layout.
 * @param right The right of this view, in pixels.
 */
public final void setRight(int right){
  if (right != mRight) {
    updateMatrix();
    final boolean matrixIsIdentity=mTransformationInfo == null || mTransformationInfo.mMatrixIsIdentity;
    if (matrixIsIdentity) {
      if (mAttachInfo != null) {
        int maxRight;
        if (right < mRight) {
          maxRight=mRight;
        }
 else {
          maxRight=right;
        }
        invalidate(0,0,maxRight - mLeft,mBottom - mTop);
      }
    }
 else {
      invalidate(true);
    }
    int oldWidth=mRight - mLeft;
    int height=mBottom - mTop;
    mRight=right;
    if (mDisplayList != null) {
      mDisplayList.setRight(mRight);
    }
    sizeChange(mRight - mLeft,height,oldWidth,height);
    if (!matrixIsIdentity) {
      if ((mPrivateFlags & PFLAG_PIVOT_EXPLICITLY_SET) == 0) {
        mTransformationInfo.mMatrixDirty=true;
      }
      mPrivateFlags|=PFLAG_DRAWN;
      invalidate(true);
    }
    mBackgroundSizeChanged=true;
    invalidateParentIfNeeded();
    if ((mPrivateFlags2 & PFLAG2_VIEW_QUICK_REJECTED) == PFLAG2_VIEW_QUICK_REJECTED) {
      invalidateParentIfNeeded();
    }
  }
}
Program: 199666
Project: 199666
Buggy source:
/** 
 * Sets the left position of this view relative to its parent. This method is meant to be called by the layout system and should not generally be called otherwise, because the property may be changed at any time by the layout.
 * @param left The bottom of this view, in pixels.
 */
public final void setLeft(int left){
  if (left != mLeft) {
    updateMatrix();
    final boolean matrixIsIdentity=mTransformationInfo == null || mTransformationInfo.mMatrixIsIdentity;
    if (matrixIsIdentity) {
      if (mAttachInfo != null) {
        int minLeft;
        int xLoc;
        if (left < mLeft) {
          minLeft=left;
          xLoc=left - mLeft;
        }
 else {
          minLeft=mLeft;
          xLoc=0;
        }
        invalidate(xLoc,0,mRight - minLeft,mBottom - mTop);
      }
    }
 else {
      invalidate(true);
    }
    int oldWidth=mRight - mLeft;
    int height=mBottom - mTop;
    mLeft=left;
    if (mDisplayList != null) {
      mDisplayList.setLeft(left);
    }
    sizeChange(mRight - mLeft,height,oldWidth,height);
    if (!matrixIsIdentity) {
      if ((mPrivateFlags & PFLAG_PIVOT_EXPLICITLY_SET) == 0) {
        mTransformationInfo.mMatrixDirty=true;
      }
      mPrivateFlags|=PFLAG_DRAWN;
      invalidate(true);
    }
    mBackgroundSizeChanged=true;
    invalidateParentIfNeeded();
    if ((mPrivateFlags2 & PFLAG2_VIEW_QUICK_REJECTED) == PFLAG2_VIEW_QUICK_REJECTED) {
      invalidateParentIfNeeded();
    }
  }
}

Fixed version (ground truth):
/** 
 * Sets the left position of this view relative to its parent. This method is meant to be called by the layout system and should not generally be called otherwise, because the property may be changed at any time by the layout.
 * @param left The left of this view, in pixels.
 */
public final void setLeft(int left){
  if (left != mLeft) {
    updateMatrix();
    final boolean matrixIsIdentity=mTransformationInfo == null || mTransformationInfo.mMatrixIsIdentity;
    if (matrixIsIdentity) {
      if (mAttachInfo != null) {
        int minLeft;
        int xLoc;
        if (left < mLeft) {
          minLeft=left;
          xLoc=left - mLeft;
        }
 else {
          minLeft=mLeft;
          xLoc=0;
        }
        invalidate(xLoc,0,mRight - minLeft,mBottom - mTop);
      }
    }
 else {
      invalidate(true);
    }
    int oldWidth=mRight - mLeft;
    int height=mBottom - mTop;
    mLeft=left;
    if (mDisplayList != null) {
      mDisplayList.setLeft(left);
    }
    sizeChange(mRight - mLeft,height,oldWidth,height);
    if (!matrixIsIdentity) {
      if ((mPrivateFlags & PFLAG_PIVOT_EXPLICITLY_SET) == 0) {
        mTransformationInfo.mMatrixDirty=true;
      }
      mPrivateFlags|=PFLAG_DRAWN;
      invalidate(true);
    }
    mBackgroundSizeChanged=true;
    invalidateParentIfNeeded();
    if ((mPrivateFlags2 & PFLAG2_VIEW_QUICK_REJECTED) == PFLAG2_VIEW_QUICK_REJECTED) {
      invalidateParentIfNeeded();
    }
  }
}
Program: 199668
Project: 199668
Buggy source:
@Override public void cleanUp(){
  int count=mAppWidgetContainer.getChildCount();
  for (int i=0; i < count; i++) {
    KeyguardWidgetFrame frame=mAppWidgetContainer.getWidgetPageAt(i);
    frame.removeAllViews();
  }
}

Fixed version (ground truth):
@Override public void cleanUp(){
  int count=mAppWidgetContainer.getChildCount();
  for (int i=0; i < count; i++) {
    KeyguardWidgetFrame frame=mAppWidgetContainer.getWidgetPageAt(i);
    frame.removeAllViews();
  }
  getSecurityContainer().onPause();
}
Program: 199670
Project: 199670
Buggy source:
private void unblockScreenOn(){
  if (mScreenOnWasBlocked) {
    mScreenOnWasBlocked=false;
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + (SystemClock.elapsedRealtime() - mScreenOnBlockStartRealTime) + "String_Node_Str");
    }
  }
}

Fixed version (ground truth):
private void unblockScreenOn(){
  if (mScreenOnWasBlocked) {
    mScreenOnWasBlocked=false;
    long delay=SystemClock.elapsedRealtime() - mScreenOnBlockStartRealTime;
    if (delay > 1000 || DEBUG) {
      Slog.d(TAG,"String_Node_Str" + delay + "String_Node_Str");
    }
  }
}
Program: 199671
Project: 199671
Buggy source:
private void setScreenOn(boolean on){
  if (!mPowerState.isScreenOn() == on) {
    mPowerState.setScreenOn(on);
    if (on) {
      mNotifier.onScreenOn();
    }
 else {
      mNotifier.onScreenOff();
    }
  }
}

Fixed version (ground truth):
private void setScreenOn(boolean on){
  if (mPowerState.isScreenOn() != on) {
    mPowerState.setScreenOn(on);
    if (on) {
      mNotifier.onScreenOn();
    }
 else {
      mNotifier.onScreenOff();
    }
  }
}
Program: 199672
Project: 199672
Buggy source:
public boolean setState(boolean on,int backlight){
synchronized (mLock) {
    if (on != mPendingOn || backlight != mPendingBacklight) {
      if (DEBUG) {
        Slog.d(TAG,"String_Node_Str" + on + "String_Node_Str"+ backlight);
      }
      mPendingOn=on;
      mPendingBacklight=backlight;
      if (!mChangeInProgress) {
        mChangeInProgress=true;
        AsyncTask.THREAD_POOL_EXECUTOR.execute(mTask);
      }
    }
    return mChangeInProgress;
  }
}

Fixed version (ground truth):
public boolean setState(boolean on,int backlight){
synchronized (mLock) {
    if (on != mPendingOn || backlight != mPendingBacklight) {
      if (DEBUG) {
        Slog.d(TAG,"String_Node_Str" + on + "String_Node_Str"+ backlight);
      }
      mPendingOn=on;
      mPendingBacklight=backlight;
      if (!mChangeInProgress) {
        mChangeInProgress=true;
        AsyncTask.THREAD_POOL_EXECUTOR.execute(mTask);
      }
    }
    return !mChangeInProgress;
  }
}
Program: 199673
Project: 199673
Buggy source:
/** 
 * Updates the global power state based on dirty bits recorded in mDirty. This is the main function that performs power state transitions. We centralize them here so that we can recompute the power state completely each time something important changes, and ensure that we do it the same way each time.  The point is to gather all of the transition logic here.
 */
private void updatePowerStateLocked(){
  if (!mSystemReady || mDirty == 0) {
    return;
  }
  updateIsPoweredLocked(mDirty);
  updateStayOnLocked(mDirty);
  final long now=SystemClock.uptimeMillis();
  int dirtyPhase2=0;
  for (; ; ) {
    int dirtyPhase1=mDirty;
    dirtyPhase2|=dirtyPhase1;
    mDirty=0;
    updateWakeLockSummaryLocked(dirtyPhase1);
    updateUserActivitySummaryLocked(now,dirtyPhase1);
    if (!updateWakefulnessLocked(dirtyPhase1)) {
      break;
    }
  }
  updateDreamLocked(dirtyPhase2);
  updateDisplayPowerStateLocked(dirtyPhase2);
  if (mDisplayReady) {
    sendPendingNotificationsLocked();
  }
  updateSuspendBlockerLocked();
}

Fixed version (ground truth):
/** 
 * Updates the global power state based on dirty bits recorded in mDirty. This is the main function that performs power state transitions. We centralize them here so that we can recompute the power state completely each time something important changes, and ensure that we do it the same way each time.  The point is to gather all of the transition logic here.
 */
private void updatePowerStateLocked(){
  if (!mSystemReady || mDirty == 0) {
    return;
  }
  if (!Thread.holdsLock(mLock)) {
    Slog.wtf(TAG,"String_Node_Str");
  }
  updateIsPoweredLocked(mDirty);
  updateStayOnLocked(mDirty);
  final long now=SystemClock.uptimeMillis();
  int dirtyPhase2=0;
  for (; ; ) {
    int dirtyPhase1=mDirty;
    dirtyPhase2|=dirtyPhase1;
    mDirty=0;
    updateWakeLockSummaryLocked(dirtyPhase1);
    updateUserActivitySummaryLocked(now,dirtyPhase1);
    if (!updateWakefulnessLocked(dirtyPhase1)) {
      break;
    }
  }
  updateDreamLocked(dirtyPhase2);
  updateDisplayPowerStateLocked(dirtyPhase2);
  if (mDisplayReady) {
    sendPendingNotificationsLocked();
  }
  updateSuspendBlockerLocked();
}
Program: 199676
Project: 199676
Buggy source:
private void unblockScreenOn(){
  if (mScreenOnWasBlocked) {
    mScreenOnWasBlocked=false;
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + (SystemClock.elapsedRealtime() - mScreenOnBlockStartRealTime) + "String_Node_Str");
    }
  }
}

Fixed version (ground truth):
private void unblockScreenOn(){
  if (mScreenOnWasBlocked) {
    mScreenOnWasBlocked=false;
    long delay=SystemClock.elapsedRealtime() - mScreenOnBlockStartRealTime;
    if (delay > 1000 || DEBUG) {
      Slog.d(TAG,"String_Node_Str" + delay + "String_Node_Str");
    }
  }
}
Program: 199677
Project: 199677
Buggy source:
private void setScreenOn(boolean on){
  if (!mPowerState.isScreenOn() == on) {
    mPowerState.setScreenOn(on);
    if (on) {
      mNotifier.onScreenOn();
    }
 else {
      mNotifier.onScreenOff();
    }
  }
}

Fixed version (ground truth):
private void setScreenOn(boolean on){
  if (mPowerState.isScreenOn() != on) {
    mPowerState.setScreenOn(on);
    if (on) {
      mNotifier.onScreenOn();
    }
 else {
      mNotifier.onScreenOff();
    }
  }
}
Program: 199678
Project: 199678
Buggy source:
public boolean setState(boolean on,int backlight){
synchronized (mLock) {
    if (on != mPendingOn || backlight != mPendingBacklight) {
      if (DEBUG) {
        Slog.d(TAG,"String_Node_Str" + on + "String_Node_Str"+ backlight);
      }
      mPendingOn=on;
      mPendingBacklight=backlight;
      if (!mChangeInProgress) {
        mChangeInProgress=true;
        AsyncTask.THREAD_POOL_EXECUTOR.execute(mTask);
      }
    }
    return mChangeInProgress;
  }
}

Fixed version (ground truth):
public boolean setState(boolean on,int backlight){
synchronized (mLock) {
    if (on != mPendingOn || backlight != mPendingBacklight) {
      if (DEBUG) {
        Slog.d(TAG,"String_Node_Str" + on + "String_Node_Str"+ backlight);
      }
      mPendingOn=on;
      mPendingBacklight=backlight;
      if (!mChangeInProgress) {
        mChangeInProgress=true;
        AsyncTask.THREAD_POOL_EXECUTOR.execute(mTask);
      }
    }
    return !mChangeInProgress;
  }
}
Program: 199679
Project: 199679
Buggy source:
/** 
 * Updates the global power state based on dirty bits recorded in mDirty. This is the main function that performs power state transitions. We centralize them here so that we can recompute the power state completely each time something important changes, and ensure that we do it the same way each time.  The point is to gather all of the transition logic here.
 */
private void updatePowerStateLocked(){
  if (!mSystemReady || mDirty == 0) {
    return;
  }
  updateIsPoweredLocked(mDirty);
  updateStayOnLocked(mDirty);
  final long now=SystemClock.uptimeMillis();
  int dirtyPhase2=0;
  for (; ; ) {
    int dirtyPhase1=mDirty;
    dirtyPhase2|=dirtyPhase1;
    mDirty=0;
    updateWakeLockSummaryLocked(dirtyPhase1);
    updateUserActivitySummaryLocked(now,dirtyPhase1);
    if (!updateWakefulnessLocked(dirtyPhase1)) {
      break;
    }
  }
  updateDreamLocked(dirtyPhase2);
  updateDisplayPowerStateLocked(dirtyPhase2);
  if (mDisplayReady) {
    sendPendingNotificationsLocked();
  }
  updateSuspendBlockerLocked();
}

Fixed version (ground truth):
/** 
 * Updates the global power state based on dirty bits recorded in mDirty. This is the main function that performs power state transitions. We centralize them here so that we can recompute the power state completely each time something important changes, and ensure that we do it the same way each time.  The point is to gather all of the transition logic here.
 */
private void updatePowerStateLocked(){
  if (!mSystemReady || mDirty == 0) {
    return;
  }
  if (!Thread.holdsLock(mLock)) {
    Slog.wtf(TAG,"String_Node_Str");
  }
  updateIsPoweredLocked(mDirty);
  updateStayOnLocked(mDirty);
  final long now=SystemClock.uptimeMillis();
  int dirtyPhase2=0;
  for (; ; ) {
    int dirtyPhase1=mDirty;
    dirtyPhase2|=dirtyPhase1;
    mDirty=0;
    updateWakeLockSummaryLocked(dirtyPhase1);
    updateUserActivitySummaryLocked(now,dirtyPhase1);
    if (!updateWakefulnessLocked(dirtyPhase1)) {
      break;
    }
  }
  updateDreamLocked(dirtyPhase2);
  updateDisplayPowerStateLocked(dirtyPhase2);
  if (mDisplayReady) {
    sendPendingNotificationsLocked();
  }
  updateSuspendBlockerLocked();
}
Program: 199681
Project: 199681
Buggy source:
private void unblockScreenOn(){
  if (mScreenOnWasBlocked) {
    mScreenOnWasBlocked=false;
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + (SystemClock.elapsedRealtime() - mScreenOnBlockStartRealTime) + "String_Node_Str");
    }
  }
}

Fixed version (ground truth):
private void unblockScreenOn(){
  if (mScreenOnWasBlocked) {
    mScreenOnWasBlocked=false;
    long delay=SystemClock.elapsedRealtime() - mScreenOnBlockStartRealTime;
    if (delay > 1000 || DEBUG) {
      Slog.d(TAG,"String_Node_Str" + delay + "String_Node_Str");
    }
  }
}
Program: 199682
Project: 199682
Buggy source:
private void setScreenOn(boolean on){
  if (!mPowerState.isScreenOn() == on) {
    mPowerState.setScreenOn(on);
    if (on) {
      mNotifier.onScreenOn();
    }
 else {
      mNotifier.onScreenOff();
    }
  }
}

Fixed version (ground truth):
private void setScreenOn(boolean on){
  if (mPowerState.isScreenOn() != on) {
    mPowerState.setScreenOn(on);
    if (on) {
      mNotifier.onScreenOn();
    }
 else {
      mNotifier.onScreenOff();
    }
  }
}
Program: 199683
Project: 199683
Buggy source:
public boolean setState(boolean on,int backlight){
synchronized (mLock) {
    if (on != mPendingOn || backlight != mPendingBacklight) {
      if (DEBUG) {
        Slog.d(TAG,"String_Node_Str" + on + "String_Node_Str"+ backlight);
      }
      mPendingOn=on;
      mPendingBacklight=backlight;
      if (!mChangeInProgress) {
        mChangeInProgress=true;
        AsyncTask.THREAD_POOL_EXECUTOR.execute(mTask);
      }
    }
    return mChangeInProgress;
  }
}

Fixed version (ground truth):
public boolean setState(boolean on,int backlight){
synchronized (mLock) {
    if (on != mPendingOn || backlight != mPendingBacklight) {
      if (DEBUG) {
        Slog.d(TAG,"String_Node_Str" + on + "String_Node_Str"+ backlight);
      }
      mPendingOn=on;
      mPendingBacklight=backlight;
      if (!mChangeInProgress) {
        mChangeInProgress=true;
        AsyncTask.THREAD_POOL_EXECUTOR.execute(mTask);
      }
    }
    return !mChangeInProgress;
  }
}
Program: 199684
Project: 199684
Buggy source:
/** 
 * Updates the global power state based on dirty bits recorded in mDirty. This is the main function that performs power state transitions. We centralize them here so that we can recompute the power state completely each time something important changes, and ensure that we do it the same way each time.  The point is to gather all of the transition logic here.
 */
private void updatePowerStateLocked(){
  if (!mSystemReady || mDirty == 0) {
    return;
  }
  updateIsPoweredLocked(mDirty);
  updateStayOnLocked(mDirty);
  final long now=SystemClock.uptimeMillis();
  int dirtyPhase2=0;
  for (; ; ) {
    int dirtyPhase1=mDirty;
    dirtyPhase2|=dirtyPhase1;
    mDirty=0;
    updateWakeLockSummaryLocked(dirtyPhase1);
    updateUserActivitySummaryLocked(now,dirtyPhase1);
    if (!updateWakefulnessLocked(dirtyPhase1)) {
      break;
    }
  }
  updateDreamLocked(dirtyPhase2);
  updateDisplayPowerStateLocked(dirtyPhase2);
  if (mDisplayReady) {
    sendPendingNotificationsLocked();
  }
  updateSuspendBlockerLocked();
}

Fixed version (ground truth):
/** 
 * Updates the global power state based on dirty bits recorded in mDirty. This is the main function that performs power state transitions. We centralize them here so that we can recompute the power state completely each time something important changes, and ensure that we do it the same way each time.  The point is to gather all of the transition logic here.
 */
private void updatePowerStateLocked(){
  if (!mSystemReady || mDirty == 0) {
    return;
  }
  if (!Thread.holdsLock(mLock)) {
    Slog.wtf(TAG,"String_Node_Str");
  }
  updateIsPoweredLocked(mDirty);
  updateStayOnLocked(mDirty);
  final long now=SystemClock.uptimeMillis();
  int dirtyPhase2=0;
  for (; ; ) {
    int dirtyPhase1=mDirty;
    dirtyPhase2|=dirtyPhase1;
    mDirty=0;
    updateWakeLockSummaryLocked(dirtyPhase1);
    updateUserActivitySummaryLocked(now,dirtyPhase1);
    if (!updateWakefulnessLocked(dirtyPhase1)) {
      break;
    }
  }
  updateDreamLocked(dirtyPhase2);
  updateDisplayPowerStateLocked(dirtyPhase2);
  if (mDisplayReady) {
    sendPendingNotificationsLocked();
  }
  updateSuspendBlockerLocked();
}
Program: 199686
Project: 199686
Buggy source:
private void unblockScreenOn(){
  if (mScreenOnWasBlocked) {
    mScreenOnWasBlocked=false;
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + (SystemClock.elapsedRealtime() - mScreenOnBlockStartRealTime) + "String_Node_Str");
    }
  }
}

Fixed version (ground truth):
private void unblockScreenOn(){
  if (mScreenOnWasBlocked) {
    mScreenOnWasBlocked=false;
    long delay=SystemClock.elapsedRealtime() - mScreenOnBlockStartRealTime;
    if (delay > 1000 || DEBUG) {
      Slog.d(TAG,"String_Node_Str" + delay + "String_Node_Str");
    }
  }
}
Program: 199687
Project: 199687
Buggy source:
private void setScreenOn(boolean on){
  if (!mPowerState.isScreenOn() == on) {
    mPowerState.setScreenOn(on);
    if (on) {
      mNotifier.onScreenOn();
    }
 else {
      mNotifier.onScreenOff();
    }
  }
}

Fixed version (ground truth):
private void setScreenOn(boolean on){
  if (mPowerState.isScreenOn() != on) {
    mPowerState.setScreenOn(on);
    if (on) {
      mNotifier.onScreenOn();
    }
 else {
      mNotifier.onScreenOff();
    }
  }
}
Program: 199688
Project: 199688
Buggy source:
public boolean setState(boolean on,int backlight){
synchronized (mLock) {
    if (on != mPendingOn || backlight != mPendingBacklight) {
      if (DEBUG) {
        Slog.d(TAG,"String_Node_Str" + on + "String_Node_Str"+ backlight);
      }
      mPendingOn=on;
      mPendingBacklight=backlight;
      if (!mChangeInProgress) {
        mChangeInProgress=true;
        AsyncTask.THREAD_POOL_EXECUTOR.execute(mTask);
      }
    }
    return mChangeInProgress;
  }
}

Fixed version (ground truth):
public boolean setState(boolean on,int backlight){
synchronized (mLock) {
    if (on != mPendingOn || backlight != mPendingBacklight) {
      if (DEBUG) {
        Slog.d(TAG,"String_Node_Str" + on + "String_Node_Str"+ backlight);
      }
      mPendingOn=on;
      mPendingBacklight=backlight;
      if (!mChangeInProgress) {
        mChangeInProgress=true;
        AsyncTask.THREAD_POOL_EXECUTOR.execute(mTask);
      }
    }
    return !mChangeInProgress;
  }
}
Program: 199689
Project: 199689
Buggy source:
/** 
 * Updates the global power state based on dirty bits recorded in mDirty. This is the main function that performs power state transitions. We centralize them here so that we can recompute the power state completely each time something important changes, and ensure that we do it the same way each time.  The point is to gather all of the transition logic here.
 */
private void updatePowerStateLocked(){
  if (!mSystemReady || mDirty == 0) {
    return;
  }
  updateIsPoweredLocked(mDirty);
  updateStayOnLocked(mDirty);
  final long now=SystemClock.uptimeMillis();
  int dirtyPhase2=0;
  for (; ; ) {
    int dirtyPhase1=mDirty;
    dirtyPhase2|=dirtyPhase1;
    mDirty=0;
    updateWakeLockSummaryLocked(dirtyPhase1);
    updateUserActivitySummaryLocked(now,dirtyPhase1);
    if (!updateWakefulnessLocked(dirtyPhase1)) {
      break;
    }
  }
  updateDreamLocked(dirtyPhase2);
  updateDisplayPowerStateLocked(dirtyPhase2);
  if (mDisplayReady) {
    sendPendingNotificationsLocked();
  }
  updateSuspendBlockerLocked();
}

Fixed version (ground truth):
/** 
 * Updates the global power state based on dirty bits recorded in mDirty. This is the main function that performs power state transitions. We centralize them here so that we can recompute the power state completely each time something important changes, and ensure that we do it the same way each time.  The point is to gather all of the transition logic here.
 */
private void updatePowerStateLocked(){
  if (!mSystemReady || mDirty == 0) {
    return;
  }
  if (!Thread.holdsLock(mLock)) {
    Slog.wtf(TAG,"String_Node_Str");
  }
  updateIsPoweredLocked(mDirty);
  updateStayOnLocked(mDirty);
  final long now=SystemClock.uptimeMillis();
  int dirtyPhase2=0;
  for (; ; ) {
    int dirtyPhase1=mDirty;
    dirtyPhase2|=dirtyPhase1;
    mDirty=0;
    updateWakeLockSummaryLocked(dirtyPhase1);
    updateUserActivitySummaryLocked(now,dirtyPhase1);
    if (!updateWakefulnessLocked(dirtyPhase1)) {
      break;
    }
  }
  updateDreamLocked(dirtyPhase2);
  updateDisplayPowerStateLocked(dirtyPhase2);
  if (mDisplayReady) {
    sendPendingNotificationsLocked();
  }
  updateSuspendBlockerLocked();
}
Program: 199691
Project: 199691
Buggy source:
private void unblockScreenOn(){
  if (mScreenOnWasBlocked) {
    mScreenOnWasBlocked=false;
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + (SystemClock.elapsedRealtime() - mScreenOnBlockStartRealTime) + "String_Node_Str");
    }
  }
}

Fixed version (ground truth):
private void unblockScreenOn(){
  if (mScreenOnWasBlocked) {
    mScreenOnWasBlocked=false;
    long delay=SystemClock.elapsedRealtime() - mScreenOnBlockStartRealTime;
    if (delay > 1000 || DEBUG) {
      Slog.d(TAG,"String_Node_Str" + delay + "String_Node_Str");
    }
  }
}
Program: 199692
Project: 199692
Buggy source:
private void setScreenOn(boolean on){
  if (!mPowerState.isScreenOn() == on) {
    mPowerState.setScreenOn(on);
    if (on) {
      mNotifier.onScreenOn();
    }
 else {
      mNotifier.onScreenOff();
    }
  }
}

Fixed version (ground truth):
private void setScreenOn(boolean on){
  if (mPowerState.isScreenOn() != on) {
    mPowerState.setScreenOn(on);
    if (on) {
      mNotifier.onScreenOn();
    }
 else {
      mNotifier.onScreenOff();
    }
  }
}
Program: 199693
Project: 199693
Buggy source:
public boolean setState(boolean on,int backlight){
synchronized (mLock) {
    if (on != mPendingOn || backlight != mPendingBacklight) {
      if (DEBUG) {
        Slog.d(TAG,"String_Node_Str" + on + "String_Node_Str"+ backlight);
      }
      mPendingOn=on;
      mPendingBacklight=backlight;
      if (!mChangeInProgress) {
        mChangeInProgress=true;
        AsyncTask.THREAD_POOL_EXECUTOR.execute(mTask);
      }
    }
    return mChangeInProgress;
  }
}

Fixed version (ground truth):
public boolean setState(boolean on,int backlight){
synchronized (mLock) {
    if (on != mPendingOn || backlight != mPendingBacklight) {
      if (DEBUG) {
        Slog.d(TAG,"String_Node_Str" + on + "String_Node_Str"+ backlight);
      }
      mPendingOn=on;
      mPendingBacklight=backlight;
      if (!mChangeInProgress) {
        mChangeInProgress=true;
        AsyncTask.THREAD_POOL_EXECUTOR.execute(mTask);
      }
    }
    return !mChangeInProgress;
  }
}
Program: 199694
Project: 199694
Buggy source:
/** 
 * Updates the global power state based on dirty bits recorded in mDirty. This is the main function that performs power state transitions. We centralize them here so that we can recompute the power state completely each time something important changes, and ensure that we do it the same way each time.  The point is to gather all of the transition logic here.
 */
private void updatePowerStateLocked(){
  if (!mSystemReady || mDirty == 0) {
    return;
  }
  updateIsPoweredLocked(mDirty);
  updateStayOnLocked(mDirty);
  final long now=SystemClock.uptimeMillis();
  int dirtyPhase2=0;
  for (; ; ) {
    int dirtyPhase1=mDirty;
    dirtyPhase2|=dirtyPhase1;
    mDirty=0;
    updateWakeLockSummaryLocked(dirtyPhase1);
    updateUserActivitySummaryLocked(now,dirtyPhase1);
    if (!updateWakefulnessLocked(dirtyPhase1)) {
      break;
    }
  }
  updateDreamLocked(dirtyPhase2);
  updateDisplayPowerStateLocked(dirtyPhase2);
  if (mDisplayReady) {
    sendPendingNotificationsLocked();
  }
  updateSuspendBlockerLocked();
}

Fixed version (ground truth):
/** 
 * Updates the global power state based on dirty bits recorded in mDirty. This is the main function that performs power state transitions. We centralize them here so that we can recompute the power state completely each time something important changes, and ensure that we do it the same way each time.  The point is to gather all of the transition logic here.
 */
private void updatePowerStateLocked(){
  if (!mSystemReady || mDirty == 0) {
    return;
  }
  if (!Thread.holdsLock(mLock)) {
    Slog.wtf(TAG,"String_Node_Str");
  }
  updateIsPoweredLocked(mDirty);
  updateStayOnLocked(mDirty);
  final long now=SystemClock.uptimeMillis();
  int dirtyPhase2=0;
  for (; ; ) {
    int dirtyPhase1=mDirty;
    dirtyPhase2|=dirtyPhase1;
    mDirty=0;
    updateWakeLockSummaryLocked(dirtyPhase1);
    updateUserActivitySummaryLocked(now,dirtyPhase1);
    if (!updateWakefulnessLocked(dirtyPhase1)) {
      break;
    }
  }
  updateDreamLocked(dirtyPhase2);
  updateDisplayPowerStateLocked(dirtyPhase2);
  if (mDisplayReady) {
    sendPendingNotificationsLocked();
  }
  updateSuspendBlockerLocked();
}
Program: 199695
Project: 199695
Buggy source:
@Override public void onItemClick(AdapterView<?> parent,View view,int position,long id){
  mMenu.performItemAction(mAdapter.getItem(position),0);
}

Fixed version (ground truth):
@Override public void onItemClick(AdapterView<?> parent,View view,int position,long id){
  mMenu.performItemAction(mAdapter.getItem(position),this,0);
}
Program: 199696
Project: 199696
Buggy source:
private boolean dispatchSubMenuSelected(SubMenuBuilder subMenu){
  if (mPresenters.isEmpty())   return false;
  boolean result=false;
  for (  WeakReference<MenuPresenter> ref : mPresenters) {
    final MenuPresenter presenter=ref.get();
    if (presenter == null) {
      mPresenters.remove(ref);
    }
 else     if (!result) {
      result=presenter.onSubMenuSelected(subMenu);
    }
  }
  return result;
}

Fixed version (ground truth):
private boolean dispatchSubMenuSelected(SubMenuBuilder subMenu,MenuPresenter preferredPresenter){
  if (mPresenters.isEmpty())   return false;
  boolean result=false;
  if (preferredPresenter != null) {
    result=preferredPresenter.onSubMenuSelected(subMenu);
  }
  for (  WeakReference<MenuPresenter> ref : mPresenters) {
    final MenuPresenter presenter=ref.get();
    if (presenter == null) {
      mPresenters.remove(ref);
    }
 else     if (!result) {
      result=presenter.onSubMenuSelected(subMenu);
    }
  }
  return result;
}
Program: 199697
Project: 199697
Buggy source:
public boolean performItemAction(MenuItem item,int flags){
  MenuItemImpl itemImpl=(MenuItemImpl)item;
  if (itemImpl == null || !itemImpl.isEnabled()) {
    return false;
  }
  boolean invoked=itemImpl.invoke();
  final ActionProvider provider=item.getActionProvider();
  final boolean providerHasSubMenu=provider != null && provider.hasSubMenu();
  if (itemImpl.hasCollapsibleActionView()) {
    invoked|=itemImpl.expandActionView();
    if (invoked)     close(true);
  }
 else   if (itemImpl.hasSubMenu() || providerHasSubMenu) {
    close(false);
    if (!itemImpl.hasSubMenu()) {
      itemImpl.setSubMenu(new SubMenuBuilder(getContext(),this,itemImpl));
    }
    final SubMenuBuilder subMenu=(SubMenuBuilder)itemImpl.getSubMenu();
    if (providerHasSubMenu) {
      provider.onPrepareSubMenu(subMenu);
    }
    invoked|=dispatchSubMenuSelected(subMenu);
    if (!invoked)     close(true);
  }
 else {
    if ((flags & FLAG_PERFORM_NO_CLOSE) == 0) {
      close(true);
    }
  }
  return invoked;
}

Fixed version (ground truth):
public boolean performItemAction(MenuItem item,MenuPresenter preferredPresenter,int flags){
  MenuItemImpl itemImpl=(MenuItemImpl)item;
  if (itemImpl == null || !itemImpl.isEnabled()) {
    return false;
  }
  boolean invoked=itemImpl.invoke();
  final ActionProvider provider=item.getActionProvider();
  final boolean providerHasSubMenu=provider != null && provider.hasSubMenu();
  if (itemImpl.hasCollapsibleActionView()) {
    invoked|=itemImpl.expandActionView();
    if (invoked)     close(true);
  }
 else   if (itemImpl.hasSubMenu() || providerHasSubMenu) {
    close(false);
    if (!itemImpl.hasSubMenu()) {
      itemImpl.setSubMenu(new SubMenuBuilder(getContext(),this,itemImpl));
    }
    final SubMenuBuilder subMenu=(SubMenuBuilder)itemImpl.getSubMenu();
    if (providerHasSubMenu) {
      provider.onPrepareSubMenu(subMenu);
    }
    invoked|=dispatchSubMenuSelected(subMenu,preferredPresenter);
    if (!invoked)     close(true);
  }
 else {
    if ((flags & FLAG_PERFORM_NO_CLOSE) == 0) {
      close(true);
    }
  }
  return invoked;
}
Program: 199698
Project: 199698
Buggy source:
public long getCurrentTimeUs(boolean refreshTime,boolean monotonic) throws IllegalStateException {
synchronized (this) {
    if (mPaused && !refreshTime) {
      return mLastReportedTime;
    }
    long nanoTime=System.nanoTime();
    if (refreshTime || nanoTime >= mLastNanoTime + MAX_NS_WITHOUT_POSITION_CHECK) {
      try {
        mLastTimeUs=mPlayer.getCurrentPosition() * 1000;
        mPaused=!mPlayer.isPlaying();
        if (DEBUG)         Log.v(TAG,(mPaused ? "String_Node_Str" : "String_Node_Str") + "String_Node_Str" + mLastTimeUs);
      }
 catch (      IllegalStateException e) {
        if (mPausing) {
          mPausing=false;
          getEstimatedTime(nanoTime,monotonic);
          mPaused=true;
          if (DEBUG)           Log.d(TAG,"String_Node_Str" + mLastReportedTime);
          return mLastReportedTime;
        }
        throw e;
      }
      mLastNanoTime=nanoTime;
      if (monotonic && mLastTimeUs < mLastReportedTime) {
        mTimeAdjustment=mLastReportedTime - mLastTimeUs;
        if (mTimeAdjustment > 1000000) {
          mStopped=false;
          mSeeking=true;
          scheduleNotification(NOTIFY_SEEK,0);
        }
      }
 else {
        mTimeAdjustment=0;
      }
    }
    return getEstimatedTime(nanoTime,monotonic);
  }
}

Fixed version (ground truth):
public long getCurrentTimeUs(boolean refreshTime,boolean monotonic) throws IllegalStateException {
synchronized (this) {
    if (mPaused && !refreshTime) {
      return mLastReportedTime;
    }
    long nanoTime=System.nanoTime();
    if (refreshTime || nanoTime >= mLastNanoTime + MAX_NS_WITHOUT_POSITION_CHECK) {
      try {
        mLastTimeUs=mPlayer.getCurrentPosition() * 1000L;
        mPaused=!mPlayer.isPlaying();
        if (DEBUG)         Log.v(TAG,(mPaused ? "String_Node_Str" : "String_Node_Str") + "String_Node_Str" + mLastTimeUs);
      }
 catch (      IllegalStateException e) {
        if (mPausing) {
          mPausing=false;
          getEstimatedTime(nanoTime,monotonic);
          mPaused=true;
          if (DEBUG)           Log.d(TAG,"String_Node_Str" + mLastReportedTime);
          return mLastReportedTime;
        }
        throw e;
      }
      mLastNanoTime=nanoTime;
      if (monotonic && mLastTimeUs < mLastReportedTime) {
        mTimeAdjustment=mLastReportedTime - mLastTimeUs;
        if (mTimeAdjustment > 1000000) {
          mStopped=false;
          mSeeking=true;
          scheduleNotification(NOTIFY_SEEK,0);
        }
      }
 else {
        mTimeAdjustment=0;
      }
    }
    return getEstimatedTime(nanoTime,monotonic);
  }
}
Program: 199699
Project: 199699
Buggy source:
@Override public void onItemClick(AdapterView<?> parent,View view,int position,long id){
  mMenu.performItemAction(mAdapter.getItem(position),0);
}

Fixed version (ground truth):
@Override public void onItemClick(AdapterView<?> parent,View view,int position,long id){
  mMenu.performItemAction(mAdapter.getItem(position),this,0);
}
Program: 199700
Project: 199700
Buggy source:
private boolean dispatchSubMenuSelected(SubMenuBuilder subMenu){
  if (mPresenters.isEmpty())   return false;
  boolean result=false;
  for (  WeakReference<MenuPresenter> ref : mPresenters) {
    final MenuPresenter presenter=ref.get();
    if (presenter == null) {
      mPresenters.remove(ref);
    }
 else     if (!result) {
      result=presenter.onSubMenuSelected(subMenu);
    }
  }
  return result;
}

Fixed version (ground truth):
private boolean dispatchSubMenuSelected(SubMenuBuilder subMenu,MenuPresenter preferredPresenter){
  if (mPresenters.isEmpty())   return false;
  boolean result=false;
  if (preferredPresenter != null) {
    result=preferredPresenter.onSubMenuSelected(subMenu);
  }
  for (  WeakReference<MenuPresenter> ref : mPresenters) {
    final MenuPresenter presenter=ref.get();
    if (presenter == null) {
      mPresenters.remove(ref);
    }
 else     if (!result) {
      result=presenter.onSubMenuSelected(subMenu);
    }
  }
  return result;
}
Program: 199701
Project: 199701
Buggy source:
public boolean performItemAction(MenuItem item,int flags){
  MenuItemImpl itemImpl=(MenuItemImpl)item;
  if (itemImpl == null || !itemImpl.isEnabled()) {
    return false;
  }
  boolean invoked=itemImpl.invoke();
  final ActionProvider provider=item.getActionProvider();
  final boolean providerHasSubMenu=provider != null && provider.hasSubMenu();
  if (itemImpl.hasCollapsibleActionView()) {
    invoked|=itemImpl.expandActionView();
    if (invoked)     close(true);
  }
 else   if (itemImpl.hasSubMenu() || providerHasSubMenu) {
    close(false);
    if (!itemImpl.hasSubMenu()) {
      itemImpl.setSubMenu(new SubMenuBuilder(getContext(),this,itemImpl));
    }
    final SubMenuBuilder subMenu=(SubMenuBuilder)itemImpl.getSubMenu();
    if (providerHasSubMenu) {
      provider.onPrepareSubMenu(subMenu);
    }
    invoked|=dispatchSubMenuSelected(subMenu);
    if (!invoked)     close(true);
  }
 else {
    if ((flags & FLAG_PERFORM_NO_CLOSE) == 0) {
      close(true);
    }
  }
  return invoked;
}

Fixed version (ground truth):
public boolean performItemAction(MenuItem item,MenuPresenter preferredPresenter,int flags){
  MenuItemImpl itemImpl=(MenuItemImpl)item;
  if (itemImpl == null || !itemImpl.isEnabled()) {
    return false;
  }
  boolean invoked=itemImpl.invoke();
  final ActionProvider provider=item.getActionProvider();
  final boolean providerHasSubMenu=provider != null && provider.hasSubMenu();
  if (itemImpl.hasCollapsibleActionView()) {
    invoked|=itemImpl.expandActionView();
    if (invoked)     close(true);
  }
 else   if (itemImpl.hasSubMenu() || providerHasSubMenu) {
    close(false);
    if (!itemImpl.hasSubMenu()) {
      itemImpl.setSubMenu(new SubMenuBuilder(getContext(),this,itemImpl));
    }
    final SubMenuBuilder subMenu=(SubMenuBuilder)itemImpl.getSubMenu();
    if (providerHasSubMenu) {
      provider.onPrepareSubMenu(subMenu);
    }
    invoked|=dispatchSubMenuSelected(subMenu,preferredPresenter);
    if (!invoked)     close(true);
  }
 else {
    if ((flags & FLAG_PERFORM_NO_CLOSE) == 0) {
      close(true);
    }
  }
  return invoked;
}
Program: 199702
Project: 199702
Buggy source:
/** 
 * Frees any native resources associated with this object.  The primary use is to force immediate cleanup of resources when it is believed the GC will not respond quickly enough.
 */
synchronized public void destroy(){
  if (mDestroyed) {
    throw new RSInvalidStateException("String_Node_Str");
  }
  mDestroyed=true;
  mRS.nObjDestroy(mID);
}

Fixed version (ground truth):
/** 
 * Frees any native resources associated with this object.  The primary use is to force immediate cleanup of resources when it is believed the GC will not respond quickly enough.
 */
public void destroy(){
  if (mDestroyed) {
    throw new RSInvalidStateException("String_Node_Str");
  }
  helpDestroy();
}
Program: 199703
Project: 199703
Buggy source:
protected void finalize() throws Throwable {
  if (!mDestroyed) {
    if (mID != 0 && mRS.isAlive()) {
      mRS.nObjDestroy(mID);
    }
    mRS=null;
    mID=0;
    mDestroyed=true;
  }
  super.finalize();
}

Fixed version (ground truth):
protected void finalize() throws Throwable {
  helpDestroy();
  super.finalize();
}
Program: 199704
Project: 199704
Buggy source:
synchronized void nContextDestroy(){
  validate();
  rsnContextDestroy(mContext);
}

Fixed version (ground truth):
synchronized void nContextDestroy(){
  validate();
  ReentrantReadWriteLock.WriteLock wlock=mRWLock.writeLock();
  wlock.lock();
  int curCon=mContext;
  mContext=0;
  wlock.unlock();
  rsnContextDestroy(curCon);
}
Program: 199705
Project: 199705
Buggy source:
synchronized void nObjDestroy(int id){
  if (mContext != 0) {
    rsnObjDestroy(mContext,id);
  }
}

Fixed version (ground truth):
void nObjDestroy(int id){
  if (mContext != 0) {
    rsnObjDestroy(mContext,id);
  }
}
Program: 199706
Project: 199706
Buggy source:
/** 
 * Destroys this RenderScript context.  Once this function is called, using this context or any objects belonging to this context is illegal.
 */
public void destroy(){
  validate();
  nContextDeinitToClient(mContext);
  mMessageThread.mRun=false;
  try {
    mMessageThread.join();
  }
 catch (  InterruptedException e) {
  }
  nContextDestroy();
  mContext=0;
  nDeviceDestroy(mDev);
  mDev=0;
}

Fixed version (ground truth):
/** 
 * Destroys this RenderScript context.  Once this function is called, using this context or any objects belonging to this context is illegal.
 */
public void destroy(){
  validate();
  nContextFinish();
  nContextDeinitToClient(mContext);
  mMessageThread.mRun=false;
  try {
    mMessageThread.join();
  }
 catch (  InterruptedException e) {
  }
  nContextDestroy();
  nDeviceDestroy(mDev);
  mDev=0;
}
Program: 199707
Project: 199707
Buggy source:
RenderScript(Context ctx){
  mContextType=ContextType.NORMAL;
  if (ctx != null) {
    mApplicationContext=ctx.getApplicationContext();
  }
}

Fixed version (ground truth):
RenderScript(Context ctx){
  mContextType=ContextType.NORMAL;
  if (ctx != null) {
    mApplicationContext=ctx.getApplicationContext();
  }
  mRWLock=new ReentrantReadWriteLock();
}