nus-yam/ex-repair huggingface dataset:
Program: 38655
Project: 38655
Buggy source:
public int next() throws IOException {
  int offset=mTiffStream.getReadByteCount();
  if (offset < mEndOfTagOffset) {
    skipTo(mNextOffset);
    if (mNextOffset < mEndOfTagOffset) {
      mNextOffset+=TAG_SIZE;
      return TYPE_NEW_TAG;
    }
  }
  if (offset == mEndOfTagOffset) {
    mOffsetToNextIfd=mTiffStream.readInt();
  }
  if (!mCorrespondingTag.isEmpty()) {
    mCurrTag=mCorrespondingTag.pollFirst();
    skipTo(mCurrTag.getOffset());
    if (isSubIfdTag(mCurrTag.getTagId())) {
      return TYPE_SUB_IFD;
    }
 else {
      return TYPE_VALUE_OF_PREV_TAG;
    }
  }
 else {
    if (offset <= mOffsetToNextIfd) {
      skipTo(mOffsetToNextIfd);
      return TYPE_NEXT_IFD;
    }
 else {
      return TYPE_END;
    }
  }
}

Fixed version (ground truth):
public int next() throws IOException {
  int offset=mTiffStream.getReadByteCount();
  if (offset < mEndOfTagOffset) {
    skipTo(mNextOffset);
    if (mNextOffset < mEndOfTagOffset) {
      mNextOffset+=TAG_SIZE;
      return TYPE_NEW_TAG;
    }
  }
  if (offset == mEndOfTagOffset) {
    mOffsetToNextIfd=mTiffStream.readInt();
  }
  if (!mCorrespondingTag.isEmpty()) {
    mCurrTag=mCorrespondingTag.pollFirst();
    skipTo(mCurrTag.getOffset());
    if (isSubIfdTag(mCurrTag.getTagId())) {
      return TYPE_SUB_IFD;
    }
 else {
      return TYPE_VALUE_OF_PREV_TAG;
    }
  }
 else {
    if (offset <= mOffsetToNextIfd) {
      skipTo(mOffsetToNextIfd);
      mOffsetToNextIfd=0;
      return TYPE_NEXT_IFD;
    }
 else {
      return TYPE_END;
    }
  }
}
Program: 38656
Project: 38656
Buggy source:
@Override public Void call() throws Exception {
  UpdateInfo info=mUpdateInfo;
  mSourceVersion=info.version;
  if (info.size != mSize) {
    mSize=info.size;
    if (mContentEnd > mSize)     mContentEnd=mSize;
    if (mActiveEnd > mSize)     mActiveEnd=mSize;
  }
  mCurrentIndex=info.indexHint;
  updateSlidingWindow();
  if (info.items != null) {
    int start=Math.max(info.contentStart,mContentStart);
    int end=Math.min(info.contentStart + info.items.size(),mContentEnd);
    int dataIndex=start % DATA_CACHE_SIZE;
    for (int i=start; i < end; ++i) {
      mData[dataIndex]=info.items.get(i - info.contentStart);
      if (++dataIndex == DATA_CACHE_SIZE)       dataIndex=0;
    }
  }
  MediaItem current=mData[mCurrentIndex % DATA_CACHE_SIZE];
  mItemPath=current == null ? null : current.getPath();
  updateImageCache();
  updateTileProvider();
  updateImageRequests();
  fireDataChange();
  return null;
}

Fixed version (ground truth):
@Override public Void call() throws Exception {
  UpdateInfo info=mUpdateInfo;
  mSourceVersion=info.version;
  if (info.size != mSize) {
    mSize=info.size;
    if (mContentEnd > mSize)     mContentEnd=mSize;
    if (mActiveEnd > mSize)     mActiveEnd=mSize;
  }
  mCurrentIndex=info.indexHint;
  updateSlidingWindow();
  if (info.items != null) {
    int start=Math.max(info.contentStart,mContentStart);
    int end=Math.min(info.contentStart + info.items.size(),mContentEnd);
    int dataIndex=start % DATA_CACHE_SIZE;
    for (int i=start; i < end; ++i) {
      mData[dataIndex]=info.items.get(i - info.contentStart);
      if (++dataIndex == DATA_CACHE_SIZE)       dataIndex=0;
    }
  }
  MediaItem current=mData[mCurrentIndex % DATA_CACHE_SIZE];
  mItemPath=current == null ? null : current.getPath();
  updateImageCache();
  updateTileProvider();
  updateImageRequests();
  if (mDataListener != null) {
    mDataListener.onPhotoChanged(mCurrentIndex,mItemPath);
  }
  fireDataChange();
  return null;
}
Program: 38657
Project: 38657
Buggy source:
@Override public Void call() throws Exception {
  UpdateInfo info=mUpdateInfo;
  mSourceVersion=info.version;
  if (info.size != mSize) {
    mSize=info.size;
    if (mContentEnd > mSize)     mContentEnd=mSize;
    if (mActiveEnd > mSize)     mActiveEnd=mSize;
  }
  mCurrentIndex=info.indexHint;
  updateSlidingWindow();
  if (info.items != null) {
    int start=Math.max(info.contentStart,mContentStart);
    int end=Math.min(info.contentStart + info.items.size(),mContentEnd);
    int dataIndex=start % DATA_CACHE_SIZE;
    for (int i=start; i < end; ++i) {
      mData[dataIndex]=info.items.get(i - info.contentStart);
      if (++dataIndex == DATA_CACHE_SIZE)       dataIndex=0;
    }
  }
  MediaItem current=mData[mCurrentIndex % DATA_CACHE_SIZE];
  mItemPath=current == null ? null : current.getPath();
  updateImageCache();
  updateTileProvider();
  updateImageRequests();
  fireDataChange();
  return null;
}

Fixed version (ground truth):
@Override public Void call() throws Exception {
  UpdateInfo info=mUpdateInfo;
  mSourceVersion=info.version;
  if (info.size != mSize) {
    mSize=info.size;
    if (mContentEnd > mSize)     mContentEnd=mSize;
    if (mActiveEnd > mSize)     mActiveEnd=mSize;
  }
  mCurrentIndex=info.indexHint;
  updateSlidingWindow();
  if (info.items != null) {
    int start=Math.max(info.contentStart,mContentStart);
    int end=Math.min(info.contentStart + info.items.size(),mContentEnd);
    int dataIndex=start % DATA_CACHE_SIZE;
    for (int i=start; i < end; ++i) {
      mData[dataIndex]=info.items.get(i - info.contentStart);
      if (++dataIndex == DATA_CACHE_SIZE)       dataIndex=0;
    }
  }
  MediaItem current=mData[mCurrentIndex % DATA_CACHE_SIZE];
  mItemPath=current == null ? null : current.getPath();
  updateImageCache();
  updateTileProvider();
  updateImageRequests();
  if (mDataListener != null) {
    mDataListener.onPhotoChanged(mCurrentIndex,mItemPath);
  }
  fireDataChange();
  return null;
}
Program: 38658
Project: 38658
Buggy source:
public boolean switchWithCaptureAnimation(int offset){
  GLRoot root=getGLRoot();
  root.lockRenderThread();
  try {
    return switchWithCaptureAnimationLocked(offset);
  }
  finally {
    root.unlockRenderThread();
  }
}

Fixed version (ground truth):
public boolean switchWithCaptureAnimation(int offset){
  GLRoot root=getGLRoot();
  if (root == null)   return false;
  root.lockRenderThread();
  try {
    return switchWithCaptureAnimationLocked(offset);
  }
  finally {
    root.unlockRenderThread();
  }
}
Program: 38659
Project: 38659
Buggy source:
private boolean canShowBars(){
  boolean atCamera=mAppBridge != null && mCurrentIndex == 0;
  return mActionBarAllowed && !atCamera;
}

Fixed version (ground truth):
private boolean canShowBars(){
  if (mAppBridge != null && mCurrentIndex == 0)   return false;
  if (!mActionBarAllowed)   return false;
  if (mOrientationManager.isOrientationLocked())   return false;
  return true;
}
Program: 38660
Project: 38660
Buggy source:
private void toggleBars(){
  if (mShowBars) {
    hideBars();
  }
 else   if (canShowBars()) {
    showBars();
  }
}

Fixed version (ground truth):
private void toggleBars(){
  mCanShowBars=canShowBars();
  if (mShowBars) {
    hideBars();
  }
 else {
    if (mCanShowBars)     showBars();
  }
}
Program: 38662
Project: 38662
Buggy source:
@Override protected void onDestroy(){
  if (mAppBridge != null) {
    SnailSource.unregisterScreenNail(mScreenNail);
    mAppBridge.detachScreenNail();
    mAppBridge=null;
    mScreenNail=null;
  }
  mOrientationManager.removeListener(this);
  super.onDestroy();
}

Fixed version (ground truth):
@Override protected void onDestroy(){
  if (mAppBridge != null) {
    SnailSource.unregisterScreenNail(mScreenNail);
    mAppBridge.detachScreenNail();
    mAppBridge=null;
    mScreenNail=null;
  }
  mOrientationManager.removeListener(this);
  mHandler.removeCallbacksAndMessages(null);
  super.onDestroy();
}
Program: 38663
Project: 38663
Buggy source:
@Override public void handleMessage(Message message){
switch (message.what) {
case MSG_HIDE_BARS:
{
      hideBars();
      break;
    }
case MSG_LOCK_ORIENTATION:
{
    mOrientationManager.lockOrientation();
    break;
  }
case MSG_UNLOCK_ORIENTATION:
{
  mOrientationManager.unlockOrientation();
  break;
}
case MSG_ON_FULL_SCREEN_CHANGED:
{
mAppBridge.onFullScreenChanged(message.arg1 == 1);
break;
}
case MSG_UPDATE_ACTION_BAR:
{
updateBars();
break;
}
default :
throw new AssertionError(message.what);
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message message){
switch (message.what) {
case MSG_HIDE_BARS:
{
      hideBars();
      break;
    }
case MSG_LOCK_ORIENTATION:
{
    mOrientationManager.lockOrientation();
    updateBars();
    break;
  }
case MSG_UNLOCK_ORIENTATION:
{
  mOrientationManager.unlockOrientation();
  updateBars();
  break;
}
case MSG_ON_FULL_SCREEN_CHANGED:
{
mAppBridge.onFullScreenChanged(message.arg1 == 1);
break;
}
case MSG_UPDATE_ACTION_BAR:
{
updateBars();
break;
}
default :
throw new AssertionError(message.what);
}
}
Program: 38664
Project: 38664
Buggy source:
private void updateBars(){
  if (canShowBars()) {
    showBars();
  }
 else {
    hideBars();
  }
}

Fixed version (ground truth):
private void updateBars(){
  boolean v=canShowBars();
  if (mCanShowBars == v)   return;
  mCanShowBars=v;
  if (mCanShowBars) {
    showBars();
  }
 else {
    hideBars();
  }
}
Program: 38665
Project: 38665
Buggy source:
private void captureAnimationDone(int offset){
  mHolding&=~HOLD_CAPTURE_ANIMATION;
  if (offset == 1) {
    if (!mFilmMode) {
      mListener.unlockOrientation();
      mListener.onActionBarAllowed(true);
    }
  }
  snapback();
}

Fixed version (ground truth):
private void captureAnimationDone(int offset){
  mHolding&=~HOLD_CAPTURE_ANIMATION;
  if (offset == 1) {
    if (!mFilmMode) {
      mListener.onActionBarAllowed(true);
    }
  }
  snapback();
}
Program: 38666
Project: 38666
Buggy source:
@Override protected void onResume(){
  super.onResume();
  mIsActive=true;
  setContentPane(mRootPane);
  mModel.resume();
  mPhotoView.resume();
  if (mMenuVisibilityListener == null) {
    mMenuVisibilityListener=new MyMenuVisibilityListener();
  }
  mActionBar.setDisplayOptions(mSetPathString != null,true);
  mActionBar.addOnMenuVisibilityListener(mMenuVisibilityListener);
  onUserInteraction();
  if (mAppBridge != null) {
    mAppBridge.setServer(this);
    mModel.moveTo(0);
  }
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  mIsActive=true;
  setContentPane(mRootPane);
  mModel.resume();
  mPhotoView.resume();
  if (mMenuVisibilityListener == null) {
    mMenuVisibilityListener=new MyMenuVisibilityListener();
  }
  mActionBar.setDisplayOptions(mSetPathString != null,true);
  mActionBar.addOnMenuVisibilityListener(mMenuVisibilityListener);
  onUserInteraction();
  if (mAppBridge != null) {
    mAppBridge.setServer(this);
    mPhotoView.resetToFirstPicture();
  }
}
Program: 38667
Project: 38667
Buggy source:
@Override public boolean onScaleBegin(float focusX,float focusY){
  mPositionController.beginScale(focusX,focusY);
  mCanChangeMode=mFilmMode || mPositionController.isAtMinimalScale();
  mModeChanged=false;
  return true;
}

Fixed version (ground truth):
@Override public boolean onScaleBegin(float focusX,float focusY){
  mIgnoreScalingGesture=mPictures.get(0).isCamera();
  if (mIgnoreScalingGesture) {
    return true;
  }
  mPositionController.beginScale(focusX,focusY);
  mCanChangeMode=mFilmMode || mPositionController.isAtMinimalScale();
  mModeChanged=false;
  return true;
}
Program: 38668
Project: 38668
Buggy source:
@Override public void onScaleEnd(){
  if (mModeChanged)   return;
  mPositionController.endScale();
}

Fixed version (ground truth):
@Override public void onScaleEnd(){
  if (mIgnoreScalingGesture) {
    return;
  }
  if (mModeChanged)   return;
  mPositionController.endScale();
}
Program: 38669
Project: 38669
Buggy source:
@Override public boolean onScale(float focusX,float focusY,float scale){
  if (mModeChanged)   return true;
  if (Float.isNaN(scale) || Float.isInfinite(scale))   return false;
  if (scale > 0.99f && scale < 1.01f)   return false;
  int outOfRange=mPositionController.scaleBy(scale,focusX,focusY);
  if (mCanChangeMode) {
    if ((outOfRange < 0 && !mFilmMode) || (outOfRange > 0 && mFilmMode)) {
      stopExtraScalingIfNeeded();
      mHolding&=~HOLD_TOUCH_DOWN;
      setFilmMode(!mFilmMode);
      onScaleEnd();
      mModeChanged=true;
      return true;
    }
  }
  if (outOfRange != 0) {
    startExtraScalingIfNeeded();
  }
 else {
    stopExtraScalingIfNeeded();
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean onScale(float focusX,float focusY,float scale){
  if (mIgnoreScalingGesture) {
    return true;
  }
  if (mModeChanged)   return true;
  if (Float.isNaN(scale) || Float.isInfinite(scale))   return false;
  if (scale > 0.99f && scale < 1.01f)   return false;
  int outOfRange=mPositionController.scaleBy(scale,focusX,focusY);
  if (mCanChangeMode) {
    if ((outOfRange < 0 && !mFilmMode) || (outOfRange > 0 && mFilmMode)) {
      stopExtraScalingIfNeeded();
      mHolding&=~HOLD_TOUCH_DOWN;
      setFilmMode(!mFilmMode);
      onScaleEnd();
      mModeChanged=true;
      return true;
    }
  }
  if (outOfRange != 0) {
    startExtraScalingIfNeeded();
  }
 else {
    stopExtraScalingIfNeeded();
  }
  return true;
}
Program: 38673
Project: 38673
Buggy source:
private float getMinimalScale(Box b){
  float wFactor=1.0f;
  float hFactor=1.0f;
  int viewW, viewH;
  if (!mFilmMode && mConstrained && b == mBoxes.get(0)) {
    viewW=mConstrainedFrame.width();
    viewH=mConstrainedFrame.height();
  }
 else {
    viewW=mViewW;
    viewH=mViewH;
  }
  if (mFilmMode) {
    if (mViewH > mViewW) {
      wFactor=FILM_MODE_PORTRAIT_WIDTH;
      hFactor=FILM_MODE_PORTRAIT_HEIGHT;
    }
 else {
      wFactor=FILM_MODE_LANDSCAPE_WIDTH;
      hFactor=FILM_MODE_LANDSCAPE_HEIGHT;
    }
  }
  float s=Math.min(wFactor * viewW / b.mImageW,hFactor * viewH / b.mImageH);
  return Math.min(SCALE_LIMIT,s);
}

Fixed version (ground truth):
private float getMinimalScale(Box b){
  float wFactor=1.0f;
  float hFactor=1.0f;
  int viewW, viewH;
  if (!mFilmMode && mConstrained && !mConstrainedFrame.isEmpty()&& b == mBoxes.get(0)) {
    viewW=mConstrainedFrame.width();
    viewH=mConstrainedFrame.height();
  }
 else {
    viewW=mViewW;
    viewH=mViewH;
  }
  if (mFilmMode) {
    if (mViewH > mViewW) {
      wFactor=FILM_MODE_PORTRAIT_WIDTH;
      hFactor=FILM_MODE_PORTRAIT_HEIGHT;
    }
 else {
      wFactor=FILM_MODE_LANDSCAPE_WIDTH;
      hFactor=FILM_MODE_LANDSCAPE_HEIGHT;
    }
  }
  float s=Math.min(wFactor * viewW / b.mImageW,hFactor * viewH / b.mImageH);
  return Math.min(SCALE_LIMIT,s);
}
Program: 38674
Project: 38674
Buggy source:
protected void drawContent(GLCanvas canvas,Texture content,int width,int height,int rotation){
  canvas.save(GLCanvas.SAVE_FLAG_MATRIX);
  if (rotation != 0) {
    canvas.rotate(rotation,0,0,1);
    if (((rotation % 90) & 1) != 0) {
      int temp=height;
      height=width;
      width=height;
    }
  }
  float scale=Math.min((float)width / content.getWidth(),(float)height / content.getHeight());
  canvas.scale(scale,scale,1);
  content.draw(canvas,0,0);
  canvas.restore();
}

Fixed version (ground truth):
protected void drawContent(GLCanvas canvas,Texture content,int width,int height,int rotation){
  canvas.save(GLCanvas.SAVE_FLAG_MATRIX);
  if (rotation != 0) {
    canvas.translate(width / 2,height / 2);
    canvas.rotate(rotation,0,0,1);
    canvas.translate(-width / 2,-height / 2);
    if (((rotation % 90) & 1) != 0) {
      int temp=height;
      height=width;
      width=height;
    }
  }
  float scale=Math.min((float)width / content.getWidth(),(float)height / content.getHeight());
  canvas.scale(scale,scale,1);
  content.draw(canvas,0,0);
  canvas.restore();
}
Program: 38675
Project: 38675
Buggy source:
@Override @SuppressWarnings("String_Node_Str") public ArrayList<MediaSet> run(JobContext jc){
  BucketEntry[] entries=loadBucketEntries(jc);
  if (jc.isCancelled())   return null;
  int offset=0;
  int index=findBucket(entries,MediaSetUtils.CAMERA_BUCKET_ID);
  if (index != -1) {
    circularShiftRight(entries,offset++,index);
  }
  index=findBucket(entries,MediaSetUtils.DOWNLOAD_BUCKET_ID);
  if (index != -1) {
    circularShiftRight(entries,offset++,index);
  }
  ArrayList<MediaSet> albums=new ArrayList<MediaSet>();
  DataManager dataManager=mApplication.getDataManager();
  for (  BucketEntry entry : entries) {
    MediaSet album=getLocalAlbum(dataManager,mType,mPath,entry.bucketId,entry.bucketName);
    album.reload();
    albums.add(album);
  }
  return albums;
}

Fixed version (ground truth):
@Override @SuppressWarnings("String_Node_Str") public ArrayList<MediaSet> run(JobContext jc){
  BucketEntry[] entries=loadBucketEntries(jc);
  if (jc.isCancelled())   return null;
  int offset=0;
  int index=findBucket(entries,MediaSetUtils.CAMERA_BUCKET_ID);
  if (index != -1) {
    circularShiftRight(entries,offset++,index);
  }
  index=findBucket(entries,MediaSetUtils.DOWNLOAD_BUCKET_ID);
  if (index != -1) {
    circularShiftRight(entries,offset++,index);
  }
  ArrayList<MediaSet> albums=new ArrayList<MediaSet>();
  DataManager dataManager=mApplication.getDataManager();
  for (  BucketEntry entry : entries) {
    MediaSet album=getLocalAlbum(dataManager,mType,mPath,entry.bucketId,entry.bucketName);
    albums.add(album);
  }
  return albums;
}
Program: 38676
Project: 38676
Buggy source:
@Override public synchronized long reload(){
  if (mNotifierImage.isDirty() | mNotifierVideo.isDirty()) {
    if (mLoadTask != null)     mLoadTask.cancel();
    mLoadTask=mApplication.getThreadPool().submit(new AlbumsLoader(),this);
  }
  if (mLoadBuffer != null) {
    mAlbums=mLoadBuffer;
    mLoadBuffer=null;
    mDataVersion=nextVersionNumber();
  }
  return mDataVersion;
}

Fixed version (ground truth):
@Override public synchronized long reload(){
  if (mNotifierImage.isDirty() | mNotifierVideo.isDirty()) {
    if (mLoadTask != null)     mLoadTask.cancel();
    mLoadTask=mApplication.getThreadPool().submit(new AlbumsLoader(),this);
  }
  if (mLoadBuffer != null) {
    mAlbums=mLoadBuffer;
    mLoadBuffer=null;
    for (    MediaSet album : mAlbums) {
      album.reload();
    }
    mDataVersion=nextVersionNumber();
  }
  return mDataVersion;
}
Program: 38677
Project: 38677
Buggy source:
@Override public synchronized long reload(){
  if (mNotifier.isDirty()) {
    if (mLoadTask != null)     mLoadTask.cancel();
    mLoadTask=mApplication.getThreadPool().submit(new DevicesLoader(),this);
  }
  if (mLoadBuffer != null) {
    mDeviceSet=mLoadBuffer;
    mLoadBuffer=null;
    mDataVersion=nextVersionNumber();
  }
  return mDataVersion;
}

Fixed version (ground truth):
@Override public synchronized long reload(){
  if (mNotifier.isDirty()) {
    if (mLoadTask != null)     mLoadTask.cancel();
    mLoadTask=mApplication.getThreadPool().submit(new DevicesLoader(),this);
  }
  if (mLoadBuffer != null) {
    mDeviceSet=mLoadBuffer;
    mLoadBuffer=null;
    for (    MediaSet device : mDeviceSet) {
      device.reload();
    }
    mDataVersion=nextVersionNumber();
  }
  return mDataVersion;
}
Program: 38678
Project: 38678
Buggy source:
@Override public ArrayList<MediaSet> run(JobContext jc){
  DataManager dataManager=mApplication.getDataManager();
  ArrayList<MediaSet> result=new ArrayList<MediaSet>();
  List<android.mtp.MtpDevice> devices=mMtpContext.getMtpClient().getDeviceList();
  Log.v(TAG,"String_Node_Str" + devices + "String_Node_Str"+ devices.size());
  for (  android.mtp.MtpDevice mtpDevice : devices) {
synchronized (DataManager.LOCK) {
      int deviceId=mtpDevice.getDeviceId();
      Path childPath=mPath.getChild(deviceId);
      MtpDevice device=(MtpDevice)dataManager.peekMediaObject(childPath);
      if (device == null) {
        device=new MtpDevice(childPath,mApplication,deviceId,mMtpContext);
      }
      Log.d(TAG,"String_Node_Str" + device);
      result.add(device);
    }
  }
  Collections.sort(result,MediaSetUtils.NAME_COMPARATOR);
  for (int i=0, n=result.size(); i < n; ++i) {
    result.get(i).reload();
  }
  return result;
}

Fixed version (ground truth):
@Override public ArrayList<MediaSet> run(JobContext jc){
  DataManager dataManager=mApplication.getDataManager();
  ArrayList<MediaSet> result=new ArrayList<MediaSet>();
  List<android.mtp.MtpDevice> devices=mMtpContext.getMtpClient().getDeviceList();
  Log.v(TAG,"String_Node_Str" + devices + "String_Node_Str"+ devices.size());
  for (  android.mtp.MtpDevice mtpDevice : devices) {
synchronized (DataManager.LOCK) {
      int deviceId=mtpDevice.getDeviceId();
      Path childPath=mPath.getChild(deviceId);
      MtpDevice device=(MtpDevice)dataManager.peekMediaObject(childPath);
      if (device == null) {
        device=new MtpDevice(childPath,mApplication,deviceId,mMtpContext);
      }
      Log.d(TAG,"String_Node_Str" + device);
      result.add(device);
    }
  }
  Collections.sort(result,MediaSetUtils.NAME_COMPARATOR);
  return result;
}
Program: 38679
Project: 38679
Buggy source:
protected void drawContent(GLCanvas canvas,Texture content,int width,int height,int rotation){
  canvas.save(GLCanvas.SAVE_FLAG_MATRIX);
  if (rotation != 0) {
    canvas.rotate(rotation,0,0,1);
    if (((rotation % 90) & 1) != 0) {
      int temp=height;
      height=width;
      width=height;
    }
  }
  float scale=Math.min((float)width / content.getWidth(),(float)height / content.getHeight());
  canvas.scale(scale,scale,1);
  content.draw(canvas,0,0);
  canvas.restore();
}

Fixed version (ground truth):
protected void drawContent(GLCanvas canvas,Texture content,int width,int height,int rotation){
  canvas.save(GLCanvas.SAVE_FLAG_MATRIX);
  if (rotation != 0) {
    canvas.translate(width / 2,height / 2);
    canvas.rotate(rotation,0,0,1);
    canvas.translate(-width / 2,-height / 2);
    if (((rotation % 90) & 1) != 0) {
      int temp=height;
      height=width;
      width=height;
    }
  }
  float scale=Math.min((float)width / content.getWidth(),(float)height / content.getHeight());
  canvas.scale(scale,scale,1);
  content.draw(canvas,0,0);
  canvas.restore();
}
Program: 38680
Project: 38680
Buggy source:
@Override @SuppressWarnings("String_Node_Str") public ArrayList<MediaSet> run(JobContext jc){
  BucketEntry[] entries=loadBucketEntries(jc);
  if (jc.isCancelled())   return null;
  int offset=0;
  int index=findBucket(entries,MediaSetUtils.CAMERA_BUCKET_ID);
  if (index != -1) {
    circularShiftRight(entries,offset++,index);
  }
  index=findBucket(entries,MediaSetUtils.DOWNLOAD_BUCKET_ID);
  if (index != -1) {
    circularShiftRight(entries,offset++,index);
  }
  ArrayList<MediaSet> albums=new ArrayList<MediaSet>();
  DataManager dataManager=mApplication.getDataManager();
  for (  BucketEntry entry : entries) {
    MediaSet album=getLocalAlbum(dataManager,mType,mPath,entry.bucketId,entry.bucketName);
    album.reload();
    albums.add(album);
  }
  return albums;
}

Fixed version (ground truth):
@Override @SuppressWarnings("String_Node_Str") public ArrayList<MediaSet> run(JobContext jc){
  BucketEntry[] entries=loadBucketEntries(jc);
  if (jc.isCancelled())   return null;
  int offset=0;
  int index=findBucket(entries,MediaSetUtils.CAMERA_BUCKET_ID);
  if (index != -1) {
    circularShiftRight(entries,offset++,index);
  }
  index=findBucket(entries,MediaSetUtils.DOWNLOAD_BUCKET_ID);
  if (index != -1) {
    circularShiftRight(entries,offset++,index);
  }
  ArrayList<MediaSet> albums=new ArrayList<MediaSet>();
  DataManager dataManager=mApplication.getDataManager();
  for (  BucketEntry entry : entries) {
    MediaSet album=getLocalAlbum(dataManager,mType,mPath,entry.bucketId,entry.bucketName);
    albums.add(album);
  }
  return albums;
}
Program: 38681
Project: 38681
Buggy source:
@Override public synchronized long reload(){
  if (mNotifierImage.isDirty() | mNotifierVideo.isDirty()) {
    if (mLoadTask != null)     mLoadTask.cancel();
    mLoadTask=mApplication.getThreadPool().submit(new AlbumsLoader(),this);
  }
  if (mLoadBuffer != null) {
    mAlbums=mLoadBuffer;
    mLoadBuffer=null;
    mDataVersion=nextVersionNumber();
  }
  return mDataVersion;
}

Fixed version (ground truth):
@Override public synchronized long reload(){
  if (mNotifierImage.isDirty() | mNotifierVideo.isDirty()) {
    if (mLoadTask != null)     mLoadTask.cancel();
    mLoadTask=mApplication.getThreadPool().submit(new AlbumsLoader(),this);
  }
  if (mLoadBuffer != null) {
    mAlbums=mLoadBuffer;
    mLoadBuffer=null;
    for (    MediaSet album : mAlbums) {
      album.reload();
    }
    mDataVersion=nextVersionNumber();
  }
  return mDataVersion;
}
Program: 38682
Project: 38682
Buggy source:
@Override public synchronized long reload(){
  if (mNotifier.isDirty()) {
    if (mLoadTask != null)     mLoadTask.cancel();
    mLoadTask=mApplication.getThreadPool().submit(new DevicesLoader(),this);
  }
  if (mLoadBuffer != null) {
    mDeviceSet=mLoadBuffer;
    mLoadBuffer=null;
    mDataVersion=nextVersionNumber();
  }
  return mDataVersion;
}

Fixed version (ground truth):
@Override public synchronized long reload(){
  if (mNotifier.isDirty()) {
    if (mLoadTask != null)     mLoadTask.cancel();
    mLoadTask=mApplication.getThreadPool().submit(new DevicesLoader(),this);
  }
  if (mLoadBuffer != null) {
    mDeviceSet=mLoadBuffer;
    mLoadBuffer=null;
    for (    MediaSet device : mDeviceSet) {
      device.reload();
    }
    mDataVersion=nextVersionNumber();
  }
  return mDataVersion;
}
Program: 38683
Project: 38683
Buggy source:
@Override public ArrayList<MediaSet> run(JobContext jc){
  DataManager dataManager=mApplication.getDataManager();
  ArrayList<MediaSet> result=new ArrayList<MediaSet>();
  List<android.mtp.MtpDevice> devices=mMtpContext.getMtpClient().getDeviceList();
  Log.v(TAG,"String_Node_Str" + devices + "String_Node_Str"+ devices.size());
  for (  android.mtp.MtpDevice mtpDevice : devices) {
synchronized (DataManager.LOCK) {
      int deviceId=mtpDevice.getDeviceId();
      Path childPath=mPath.getChild(deviceId);
      MtpDevice device=(MtpDevice)dataManager.peekMediaObject(childPath);
      if (device == null) {
        device=new MtpDevice(childPath,mApplication,deviceId,mMtpContext);
      }
      Log.d(TAG,"String_Node_Str" + device);
      result.add(device);
    }
  }
  Collections.sort(result,MediaSetUtils.NAME_COMPARATOR);
  for (int i=0, n=result.size(); i < n; ++i) {
    result.get(i).reload();
  }
  return result;
}

Fixed version (ground truth):
@Override public ArrayList<MediaSet> run(JobContext jc){
  DataManager dataManager=mApplication.getDataManager();
  ArrayList<MediaSet> result=new ArrayList<MediaSet>();
  List<android.mtp.MtpDevice> devices=mMtpContext.getMtpClient().getDeviceList();
  Log.v(TAG,"String_Node_Str" + devices + "String_Node_Str"+ devices.size());
  for (  android.mtp.MtpDevice mtpDevice : devices) {
synchronized (DataManager.LOCK) {
      int deviceId=mtpDevice.getDeviceId();
      Path childPath=mPath.getChild(deviceId);
      MtpDevice device=(MtpDevice)dataManager.peekMediaObject(childPath);
      if (device == null) {
        device=new MtpDevice(childPath,mApplication,deviceId,mMtpContext);
      }
      Log.d(TAG,"String_Node_Str" + device);
      result.add(device);
    }
  }
  Collections.sort(result,MediaSetUtils.NAME_COMPARATOR);
  return result;
}
Program: 38684
Project: 38684
Buggy source:
void resume(){
  Activity activity=(Activity)mActivity;
  ActionBar actionBar=activity.getActionBar();
  if (actionBar != null) {
    if ((mFlags & FLAG_HIDE_ACTION_BAR) != 0) {
      actionBar.hide();
    }
 else {
      actionBar.show();
    }
    int stateCount=mActivity.getStateManager().getStateCount();
    actionBar.setDisplayOptions(stateCount == 1 ? 0 : ActionBar.DISPLAY_HOME_AS_UP,ActionBar.DISPLAY_HOME_AS_UP);
    actionBar.setHomeButtonEnabled((actionBar.getDisplayOptions() & ActionBar.DISPLAY_HOME_AS_UP) != 0);
    actionBar.setDisplayShowTitleEnabled(true);
  }
  activity.invalidateOptionsMenu();
  final Window win=activity.getWindow();
  final WindowManager.LayoutParams params=win.getAttributes();
  if ((mFlags & FLAG_HIDE_STATUS_BAR) != 0) {
    params.systemUiVisibility=View.SYSTEM_UI_FLAG_LOW_PROFILE;
  }
 else {
    params.systemUiVisibility=View.SYSTEM_UI_FLAG_VISIBLE;
  }
  setScreenOnFlags(params);
  win.setAttributes(params);
  ResultEntry entry=mReceivedResults;
  if (entry != null) {
    mReceivedResults=null;
    onStateResult(entry.requestCode,entry.resultCode,entry.resultData);
  }
  if (0 != (mFlags & FLAG_SCREEN_ON)) {
    final IntentFilter filter=new IntentFilter();
    filter.addAction(Intent.ACTION_BATTERY_CHANGED);
    activity.registerReceiver(mPowerIntentReceiver,filter);
  }
  onResume();
}

Fixed version (ground truth):
void resume(){
  Activity activity=(Activity)mActivity;
  ActionBar actionBar=activity.getActionBar();
  if (actionBar != null) {
    if ((mFlags & FLAG_HIDE_ACTION_BAR) != 0) {
      actionBar.hide();
    }
 else {
      actionBar.show();
    }
    int stateCount=mActivity.getStateManager().getStateCount();
    actionBar.setDisplayOptions(stateCount == 1 ? 0 : ActionBar.DISPLAY_HOME_AS_UP,ActionBar.DISPLAY_HOME_AS_UP);
    actionBar.setHomeButtonEnabled((actionBar.getDisplayOptions() & ActionBar.DISPLAY_HOME_AS_UP) != 0);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
  }
  activity.invalidateOptionsMenu();
  final Window win=activity.getWindow();
  final WindowManager.LayoutParams params=win.getAttributes();
  if ((mFlags & FLAG_HIDE_STATUS_BAR) != 0) {
    params.systemUiVisibility=View.SYSTEM_UI_FLAG_LOW_PROFILE;
  }
 else {
    params.systemUiVisibility=View.SYSTEM_UI_FLAG_VISIBLE;
  }
  setScreenOnFlags(params);
  win.setAttributes(params);
  ResultEntry entry=mReceivedResults;
  if (entry != null) {
    mReceivedResults=null;
    onStateResult(entry.requestCode,entry.resultCode,entry.resultData);
  }
  if (0 != (mFlags & FLAG_SCREEN_ON)) {
    final IntentFilter filter=new IntentFilter();
    filter.addAction(Intent.ACTION_BATTERY_CHANGED);
    activity.registerReceiver(mPowerIntentReceiver,filter);
  }
  onResume();
}
Program: 38685
Project: 38685
Buggy source:
@Override public void onPause(){
  super.onPause();
  mIsActive=false;
  mActionModeHandler.pause();
  mAlbumSetDataAdapter.pause();
  mAlbumSetView.pause();
  mEyePosition.pause();
  DetailsHelper.pause();
  GalleryActionBar actionBar=mActivity.getGalleryActionBar();
  if (actionBar != null)   actionBar.hideClusterMenu();
  if (mSyncTask != null) {
    mSyncTask.cancel();
    mSyncTask=null;
    clearLoadingBit(BIT_LOADING_SYNC);
  }
  GalleryUtils.setSpinnerVisibility((Activity)mActivity,false);
}

Fixed version (ground truth):
@Override public void onPause(){
  super.onPause();
  mIsActive=false;
  mActionModeHandler.pause();
  mAlbumSetDataAdapter.pause();
  mAlbumSetView.pause();
  mEyePosition.pause();
  DetailsHelper.pause();
  GalleryActionBar actionBar=mActivity.getGalleryActionBar();
  if (actionBar != null)   actionBar.disableClusterMenu(false);
  if (mSyncTask != null) {
    mSyncTask.cancel();
    mSyncTask=null;
    clearLoadingBit(BIT_LOADING_SYNC);
  }
  GalleryUtils.setSpinnerVisibility((Activity)mActivity,false);
}
Program: 38686
Project: 38686
Buggy source:
public void onSelectionModeChange(int mode){
switch (mode) {
case SelectionManager.ENTER_SELECTION_MODE:
{
      mActivity.getGalleryActionBar().hideClusterMenu();
      mActionMode=mActionModeHandler.startActionMode();
      mVibrator.vibrate(100);
      break;
    }
case SelectionManager.LEAVE_SELECTION_MODE:
{
    mActionMode.finish();
    if (mShowClusterMenu) {
      mActivity.getGalleryActionBar().showClusterMenu(mSelectedAction,this);
    }
    mRootPane.invalidate();
    break;
  }
case SelectionManager.SELECT_ALL_MODE:
{
  mActionModeHandler.setTitle(getSelectedString());
  mRootPane.invalidate();
  break;
}
}
}

Fixed version (ground truth):
public void onSelectionModeChange(int mode){
switch (mode) {
case SelectionManager.ENTER_SELECTION_MODE:
{
      mActivity.getGalleryActionBar().disableClusterMenu(true);
      mActionMode=mActionModeHandler.startActionMode();
      mVibrator.vibrate(100);
      break;
    }
case SelectionManager.LEAVE_SELECTION_MODE:
{
    mActionMode.finish();
    if (mShowClusterMenu) {
      mActivity.getGalleryActionBar().enableClusterMenu(mSelectedAction,this);
    }
    mRootPane.invalidate();
    break;
  }
case SelectionManager.SELECT_ALL_MODE:
{
  mActionModeHandler.setTitle(getSelectedString());
  mRootPane.invalidate();
  break;
}
}
}
Program: 38687
Project: 38687
Buggy source:
@Override public void onResume(){
  super.onResume();
  mIsActive=true;
  setContentPane(mRootPane);
  setLoadingBit(BIT_LOADING_RELOAD);
  mAlbumSetDataAdapter.resume();
  mAlbumSetView.resume();
  mEyePosition.resume();
  mActionModeHandler.resume();
  GalleryActionBar actionBar=mActivity.getGalleryActionBar();
  if (mShowClusterMenu && actionBar != null) {
    actionBar.showClusterMenu(mSelectedAction,this);
  }
  if (!mInitialSynced) {
    setLoadingBit(BIT_LOADING_SYNC);
    mSyncTask=mMediaSet.requestSync(AlbumSetPage.this);
  }
}

Fixed version (ground truth):
@Override public void onResume(){
  super.onResume();
  mIsActive=true;
  setContentPane(mRootPane);
  setLoadingBit(BIT_LOADING_RELOAD);
  mAlbumSetDataAdapter.resume();
  mAlbumSetView.resume();
  mEyePosition.resume();
  mActionModeHandler.resume();
  GalleryActionBar actionBar=mActivity.getGalleryActionBar();
  if (mShowClusterMenu && actionBar != null) {
    actionBar.enableClusterMenu(mSelectedAction,this);
  }
  if (!mInitialSynced) {
    setLoadingBit(BIT_LOADING_SYNC);
    mSyncTask=mMediaSet.requestSync(AlbumSetPage.this);
  }
}
Program: 38688
Project: 38688
Buggy source:
void resume(){
  Activity activity=(Activity)mActivity;
  ActionBar actionBar=activity.getActionBar();
  if (actionBar != null) {
    if ((mFlags & FLAG_HIDE_ACTION_BAR) != 0) {
      actionBar.hide();
    }
 else {
      actionBar.show();
    }
    int stateCount=mActivity.getStateManager().getStateCount();
    actionBar.setDisplayOptions(stateCount == 1 ? 0 : ActionBar.DISPLAY_HOME_AS_UP,ActionBar.DISPLAY_HOME_AS_UP);
    actionBar.setHomeButtonEnabled(true);
  }
  activity.invalidateOptionsMenu();
  final Window win=activity.getWindow();
  final WindowManager.LayoutParams params=win.getAttributes();
  if ((mFlags & FLAG_HIDE_STATUS_BAR) != 0) {
    params.systemUiVisibility=View.SYSTEM_UI_FLAG_LOW_PROFILE;
  }
 else {
    params.systemUiVisibility=View.SYSTEM_UI_FLAG_VISIBLE;
  }
  setScreenOnFlags(params);
  win.setAttributes(params);
  ResultEntry entry=mReceivedResults;
  if (entry != null) {
    mReceivedResults=null;
    onStateResult(entry.requestCode,entry.resultCode,entry.resultData);
  }
  if (0 != (mFlags & FLAG_SCREEN_ON)) {
    final IntentFilter filter=new IntentFilter();
    filter.addAction(Intent.ACTION_BATTERY_CHANGED);
    activity.registerReceiver(mPowerIntentReceiver,filter);
  }
  onResume();
}

Fixed version (ground truth):
void resume(){
  Activity activity=(Activity)mActivity;
  ActionBar actionBar=activity.getActionBar();
  if (actionBar != null) {
    if ((mFlags & FLAG_HIDE_ACTION_BAR) != 0) {
      actionBar.hide();
    }
 else {
      actionBar.show();
    }
    int stateCount=mActivity.getStateManager().getStateCount();
    actionBar.setDisplayOptions(stateCount == 1 ? 0 : ActionBar.DISPLAY_HOME_AS_UP,ActionBar.DISPLAY_HOME_AS_UP);
    actionBar.setHomeButtonEnabled((actionBar.getDisplayOptions() & ActionBar.DISPLAY_HOME_AS_UP) != 0);
  }
  activity.invalidateOptionsMenu();
  final Window win=activity.getWindow();
  final WindowManager.LayoutParams params=win.getAttributes();
  if ((mFlags & FLAG_HIDE_STATUS_BAR) != 0) {
    params.systemUiVisibility=View.SYSTEM_UI_FLAG_LOW_PROFILE;
  }
 else {
    params.systemUiVisibility=View.SYSTEM_UI_FLAG_VISIBLE;
  }
  setScreenOnFlags(params);
  win.setAttributes(params);
  ResultEntry entry=mReceivedResults;
  if (entry != null) {
    mReceivedResults=null;
    onStateResult(entry.requestCode,entry.resultCode,entry.resultData);
  }
  if (0 != (mFlags & FLAG_SCREEN_ON)) {
    final IntentFilter filter=new IntentFilter();
    filter.addAction(Intent.ACTION_BATTERY_CHANGED);
    activity.registerReceiver(mPowerIntentReceiver,filter);
  }
  onResume();
}
Program: 38689
Project: 38689
Buggy source:
private void onBitmapRegionDecoderAvailable(BitmapRegionDecoder regionDecoder){
  if (regionDecoder == null) {
    Toast.makeText(this,"String_Node_Str",Toast.LENGTH_SHORT).show();
    finish();
    return;
  }
  mRegionDecoder=regionDecoder;
  mUseRegionDecoder=true;
  mState=STATE_LOADED;
  BitmapFactory.Options options=new BitmapFactory.Options();
  int width=regionDecoder.getWidth();
  int height=regionDecoder.getHeight();
  options.inSampleSize=BitmapUtils.computeSampleSize(width,height,BitmapUtils.UNCONSTRAINED,BACKUP_PIXEL_COUNT);
  mBitmap=regionDecoder.decodeRegion(new Rect(0,0,width,height),options);
  mCropView.setDataModel(new TileImageViewAdapter(mBitmap,regionDecoder),mMediaItem.getRotation());
  if (mDoFaceDetection) {
    mCropView.detectFaces(mBitmap);
  }
 else {
    mCropView.initializeHighlightRectangle();
  }
}

Fixed version (ground truth):
private void onBitmapRegionDecoderAvailable(BitmapRegionDecoder regionDecoder){
  if (regionDecoder == null) {
    Toast.makeText(this,"String_Node_Str",Toast.LENGTH_SHORT).show();
    finish();
    return;
  }
  mRegionDecoder=regionDecoder;
  mUseRegionDecoder=true;
  mState=STATE_LOADED;
  BitmapFactory.Options options=new BitmapFactory.Options();
  int width=regionDecoder.getWidth();
  int height=regionDecoder.getHeight();
  options.inSampleSize=BitmapUtils.computeSampleSize(width,height,BitmapUtils.UNCONSTRAINED,BACKUP_PIXEL_COUNT);
  mBitmap=regionDecoder.decodeRegion(new Rect(0,0,width,height),options);
  mCropView.setDataModel(new TileImageViewAdapter(mBitmap,regionDecoder),mMediaItem.getFullImageRotation());
  if (mDoFaceDetection) {
    mCropView.detectFaces(mBitmap);
  }
 else {
    mCropView.initializeHighlightRectangle();
  }
}
Program: 38691
Project: 38691
Buggy source:
private void onBitmapRegionDecoderAvailable(BitmapRegionDecoder regionDecoder){
  if (regionDecoder == null) {
    Toast.makeText(this,"String_Node_Str",Toast.LENGTH_SHORT).show();
    finish();
    return;
  }
  mRegionDecoder=regionDecoder;
  mUseRegionDecoder=true;
  mState=STATE_LOADED;
  BitmapFactory.Options options=new BitmapFactory.Options();
  int width=regionDecoder.getWidth();
  int height=regionDecoder.getHeight();
  options.inSampleSize=BitmapUtils.computeSampleSize(width,height,BitmapUtils.UNCONSTRAINED,BACKUP_PIXEL_COUNT);
  mBitmap=regionDecoder.decodeRegion(new Rect(0,0,width,height),options);
  mCropView.setDataModel(new TileImageViewAdapter(mBitmap,regionDecoder),mMediaItem.getRotation());
  if (mDoFaceDetection) {
    mCropView.detectFaces(mBitmap);
  }
 else {
    mCropView.initializeHighlightRectangle();
  }
}

Fixed version (ground truth):
private void onBitmapRegionDecoderAvailable(BitmapRegionDecoder regionDecoder){
  if (regionDecoder == null) {
    Toast.makeText(this,"String_Node_Str",Toast.LENGTH_SHORT).show();
    finish();
    return;
  }
  mRegionDecoder=regionDecoder;
  mUseRegionDecoder=true;
  mState=STATE_LOADED;
  BitmapFactory.Options options=new BitmapFactory.Options();
  int width=regionDecoder.getWidth();
  int height=regionDecoder.getHeight();
  options.inSampleSize=BitmapUtils.computeSampleSize(width,height,BitmapUtils.UNCONSTRAINED,BACKUP_PIXEL_COUNT);
  mBitmap=regionDecoder.decodeRegion(new Rect(0,0,width,height),options);
  mCropView.setDataModel(new TileImageViewAdapter(mBitmap,regionDecoder),mMediaItem.getFullImageRotation());
  if (mDoFaceDetection) {
    mCropView.detectFaces(mBitmap);
  }
 else {
    mCropView.initializeHighlightRectangle();
  }
}
Program: 38693
Project: 38693
Buggy source:
public void onFutureDone(Future<Bitmap> future){
  mFuture=future;
  mMainHandler.sendMessage(mMainHandler.obtainMessage(MSG_RUN_OBJECT,this));
}

Fixed version (ground truth):
@Override public void onFutureDone(Future<Bitmap> future){
  mFuture=future;
  mMainHandler.sendMessage(mMainHandler.obtainMessage(MSG_RUN_OBJECT,this));
}
Program: 38694
Project: 38694
Buggy source:
private void updateScreenNail(long version,Future<Bitmap> future){
  ImageEntry entry=mImageCache.get(version);
  if (entry == null || entry.screenNailTask == null) {
    Bitmap screenNail=future.get();
    if (screenNail != null)     screenNail.recycle();
    return;
  }
  entry.screenNailTask=null;
  entry.screenNail=future.get();
  if (entry.screenNail == null) {
    entry.failToLoad=true;
  }
 else {
    if (mDataListener != null) {
      mDataListener.onPhotoAvailable(version,false);
    }
    for (int i=-1; i <= 1; ++i) {
      if (version == getVersion(mCurrentIndex + i)) {
        if (i == 0)         updateTileProvider(entry);
        mPhotoView.notifyImageInvalidated(i);
      }
    }
  }
  updateImageRequests();
}

Fixed version (ground truth):
private void updateScreenNail(long version,Future<Bitmap> future){
  ImageEntry entry=mImageCache.get(version);
  if (entry == null || entry.screenNailTask != future) {
    Bitmap screenNail=future.get();
    if (screenNail != null)     screenNail.recycle();
    return;
  }
  entry.screenNailTask=null;
  entry.screenNail=future.get();
  if (entry.screenNail == null) {
    entry.failToLoad=true;
  }
 else {
    if (mDataListener != null) {
      mDataListener.onPhotoAvailable(version,false);
    }
    for (int i=-1; i <= 1; ++i) {
      if (version == getVersion(mCurrentIndex + i)) {
        if (i == 0)         updateTileProvider(entry);
        mPhotoView.notifyImageInvalidated(i);
      }
    }
  }
  updateImageRequests();
}
Program: 38695
Project: 38695
Buggy source:
private void updateFullImage(long version,Future<BitmapRegionDecoder> future){
  ImageEntry entry=mImageCache.get(version);
  if (entry == null || entry.fullImageTask == null) {
    BitmapRegionDecoder fullImage=future.get();
    if (fullImage != null)     fullImage.recycle();
    return;
  }
  entry.fullImageTask=null;
  entry.fullImage=future.get();
  if (entry.fullImage != null) {
    if (mDataListener != null) {
      mDataListener.onPhotoAvailable(version,true);
    }
    if (version == getVersion(mCurrentIndex)) {
      updateTileProvider(entry);
      mPhotoView.notifyImageInvalidated(0);
    }
  }
  updateImageRequests();
}

Fixed version (ground truth):
private void updateFullImage(long version,Future<BitmapRegionDecoder> future){
  ImageEntry entry=mImageCache.get(version);
  if (entry == null || entry.fullImageTask != future) {
    BitmapRegionDecoder fullImage=future.get();
    if (fullImage != null)     fullImage.recycle();
    return;
  }
  entry.fullImageTask=null;
  entry.fullImage=future.get();
  if (entry.fullImage != null) {
    if (mDataListener != null) {
      mDataListener.onPhotoAvailable(version,true);
    }
    if (version == getVersion(mCurrentIndex)) {
      updateTileProvider(entry);
      mPhotoView.notifyImageInvalidated(0);
    }
  }
  updateImageRequests();
}
Program: 38696
Project: 38696
Buggy source:
public void startAction(int action,int title,ProgressListener listener){
  ArrayList<Path> ids=mSelectionManager.getSelected(false);
  Utils.assertTrue(mDialog == null);
  Activity activity=(Activity)mActivity;
  mDialog=showProgressDialog(activity,title,ids.size());
  MediaOperation operation=new MediaOperation(action,ids,listener);
  mTask=mActivity.getThreadPool().submit(operation,null);
}

Fixed version (ground truth):
public void startAction(int action,int title,ProgressListener listener){
  ArrayList<Path> ids=mSelectionManager.getSelected(false);
  stopTaskAndDismissDialog();
  Activity activity=(Activity)mActivity;
  mDialog=showProgressDialog(activity,title,ids.size());
  MediaOperation operation=new MediaOperation(action,ids,listener);
  mTask=mActivity.getThreadPool().submit(operation,null);
}
Program: 38697
Project: 38697
Buggy source:
@Override public void handleMessage(Message message){
switch (message.what) {
case MSG_TASK_COMPLETE:
{
      if (mDialog != null) {
        mDialog.dismiss();
        mDialog=null;
        mTask=null;
      }
      if (message.obj != null) {
        ProgressListener listener=(ProgressListener)message.obj;
        listener.onProgressComplete(message.arg1);
      }
      mSelectionManager.leaveSelectionMode();
      break;
    }
case MSG_TASK_UPDATE:
{
    if (mDialog != null)     mDialog.setProgress(message.arg1);
    if (message.obj != null) {
      ProgressListener listener=(ProgressListener)message.obj;
      listener.onProgressUpdate(message.arg1);
    }
    break;
  }
case MSG_DO_SHARE:
{
  ((Activity)mActivity).startActivity((Intent)message.obj);
  break;
}
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message message){
switch (message.what) {
case MSG_TASK_COMPLETE:
{
      stopTaskAndDismissDialog();
      if (message.obj != null) {
        ProgressListener listener=(ProgressListener)message.obj;
        listener.onProgressComplete(message.arg1);
      }
      mSelectionManager.leaveSelectionMode();
      break;
    }
case MSG_TASK_UPDATE:
{
    if (mDialog != null)     mDialog.setProgress(message.arg1);
    if (message.obj != null) {
      ProgressListener listener=(ProgressListener)message.obj;
      listener.onProgressUpdate(message.arg1);
    }
    break;
  }
case MSG_DO_SHARE:
{
  ((Activity)mActivity).startActivity((Intent)message.obj);
  break;
}
}
}
Program: 38698
Project: 38698
Buggy source:
public Void run(JobContext jc){
  int index=0;
  DataManager manager=mActivity.getDataManager();
  int result=EXECUTION_RESULT_SUCCESS;
  for (  Path id : mItems) {
    if (jc.isCancelled()) {
      result=EXECUTION_RESULT_CANCEL;
      break;
    }
    try {
      if (!execute(manager,jc,mOperation,id))       result=EXECUTION_RESULT_FAIL;
    }
 catch (    Throwable th) {
      Log.e(TAG,"String_Node_Str" + mOperation + "String_Node_Str"+ id,th);
    }
    onProgressUpdate(index++,mListener);
  }
  onProgressComplete(result,mListener);
  return null;
}

Fixed version (ground truth):
public Void run(JobContext jc){
  int index=0;
  DataManager manager=mActivity.getDataManager();
  int result=EXECUTION_RESULT_SUCCESS;
  try {
    for (    Path id : mItems) {
      if (jc.isCancelled()) {
        result=EXECUTION_RESULT_CANCEL;
        break;
      }
      if (!execute(manager,jc,mOperation,id)) {
        result=EXECUTION_RESULT_FAIL;
      }
      onProgressUpdate(index++,mListener);
    }
  }
 catch (  Throwable th) {
    Log.e(TAG,"String_Node_Str" + mOperation + "String_Node_Str"+ th);
  }
 finally {
    onProgressComplete(result,mListener);
  }
  return null;
}
Program: 38699
Project: 38699
Buggy source:
public MenuExecutor(GalleryActivity activity,SelectionManager selectionManager){
  mActivity=Utils.checkNotNull(activity);
  mSelectionManager=Utils.checkNotNull(selectionManager);
  mHandler=new SynchronizedHandler(mActivity.getGLRoot()){
    @Override public void handleMessage(    Message message){
switch (message.what) {
case MSG_TASK_COMPLETE:
{
          if (mDialog != null) {
            mDialog.dismiss();
            mDialog=null;
            mTask=null;
          }
          if (message.obj != null) {
            ProgressListener listener=(ProgressListener)message.obj;
            listener.onProgressComplete(message.arg1);
          }
          mSelectionManager.leaveSelectionMode();
          break;
        }
case MSG_TASK_UPDATE:
{
        if (mDialog != null)         mDialog.setProgress(message.arg1);
        if (message.obj != null) {
          ProgressListener listener=(ProgressListener)message.obj;
          listener.onProgressUpdate(message.arg1);
        }
        break;
      }
case MSG_DO_SHARE:
{
      ((Activity)mActivity).startActivity((Intent)message.obj);
      break;
    }
}
}
}
;
}

Fixed version (ground truth):
public MenuExecutor(GalleryActivity activity,SelectionManager selectionManager){
  mActivity=Utils.checkNotNull(activity);
  mSelectionManager=Utils.checkNotNull(selectionManager);
  mHandler=new SynchronizedHandler(mActivity.getGLRoot()){
    @Override public void handleMessage(    Message message){
switch (message.what) {
case MSG_TASK_COMPLETE:
{
          stopTaskAndDismissDialog();
          if (message.obj != null) {
            ProgressListener listener=(ProgressListener)message.obj;
            listener.onProgressComplete(message.arg1);
          }
          mSelectionManager.leaveSelectionMode();
          break;
        }
case MSG_TASK_UPDATE:
{
        if (mDialog != null)         mDialog.setProgress(message.arg1);
        if (message.obj != null) {
          ProgressListener listener=(ProgressListener)message.obj;
          listener.onProgressUpdate(message.arg1);
        }
        break;
      }
case MSG_DO_SHARE:
{
      ((Activity)mActivity).startActivity((Intent)message.obj);
      break;
    }
}
}
}
;
}