nus-yam/ex-repair huggingface dataset:
Program: 184586
Project: 184586
Buggy source:
@Override protected void onActivityResult(int requestCode,int resultCode,Intent data){
  if ((requestCode == PHOTO_PICKED || requestCode == CROP_DONE) && (resultCode == RESULT_OK) && (data != null)) {
    try {
      File tempFile=new File(mTempFilePath);
      InputStream s=new FileInputStream(tempFile);
      Bitmap bitmap=BitmapFactory.decodeStream(s);
      if (bitmap == null) {
        Log.e(LOG_TAG,"String_Node_Str" + "String_Node_Str" + mTempFilePath);
      }
 else {
        mHandler.sendEmptyMessage(SHOW_PROGRESS);
        new SetWallpaperThread(bitmap,mHandler,this,tempFile).start();
      }
      mDoLaunch=false;
    }
 catch (    FileNotFoundException ex) {
    }
  }
 else {
    setResult(RESULT_CANCELED);
    finish();
  }
}

Fixed version (ground truth):
@Override protected void onActivityResult(int requestCode,int resultCode,Intent data){
  if ((requestCode == PHOTO_PICKED || requestCode == CROP_DONE) && (resultCode == RESULT_OK) && (data != null)) {
    try {
      InputStream s=new FileInputStream(mTempFile);
      try {
        Bitmap bitmap=BitmapFactory.decodeStream(s);
        if (bitmap == null) {
          Log.e(LOG_TAG,"String_Node_Str" + "String_Node_Str" + mTempFile);
        }
 else {
          mHandler.sendEmptyMessage(SHOW_PROGRESS);
          new SetWallpaperThread(bitmap,mHandler,this,mTempFile).start();
        }
        mDoLaunch=false;
      }
  finally {
        Util.closeSilently(s);
      }
    }
 catch (    FileNotFoundException ex) {
      Log.e(LOG_TAG,"String_Node_Str" + mTempFile,ex);
    }
  }
 else {
    setResult(RESULT_CANCELED);
    finish();
  }
}
Program: 184587
Project: 184587
Buggy source:
private void showAlert(){
  int[] pickIds={R.id.attach,R.id.cancel};
  int[] normalIds={R.id.gallery,R.id.share,R.id.discard};
  int[] alwaysOnIds={R.id.play};
  int[] hideIds=pickIds;
  int[] connectIds=normalIds;
  if (mIsVideoCaptureIntent) {
    hideIds=normalIds;
    connectIds=pickIds;
  }
  for (  int id : hideIds) {
    mPostPictureAlert.findViewById(id).setVisibility(View.GONE);
  }
  ActionMenuButton shareButton=(ActionMenuButton)mPostPictureAlert.findViewById(R.id.share);
  shareButton.setRestricted(mCurrentVideoFileLength > SHARE_FILE_LENGTH_LIMIT);
  connectAndFadeIn(connectIds);
  connectAndFadeIn(alwaysOnIds);
  hideLastPictureButton();
  mPostPictureAlert.setVisibility(View.VISIBLE);
  if (!mIsVideoCaptureIntent) {
    mCurrentVideoUri=mThumbController.getUri();
    mCurrentVideoFilename=getDataPath(mCurrentVideoUri);
  }
  String path=mCurrentVideoFilename;
  if (path != null) {
    Bitmap videoFrame=Util.createVideoThumbnail(path);
    mVideoFrame.setImageBitmap(videoFrame);
    mVideoFrame.setVisibility(View.VISIBLE);
  }
}

Fixed version (ground truth):
private void showAlert(){
  int[] pickIds={R.id.attach,R.id.cancel};
  int[] normalIds={R.id.gallery,R.id.share,R.id.discard};
  int[] alwaysOnIds={R.id.play};
  int[] hideIds=pickIds;
  int[] connectIds=normalIds;
  if (mIsVideoCaptureIntent) {
    hideIds=normalIds;
    connectIds=pickIds;
  }
  for (  int id : hideIds) {
    mPostPictureAlert.findViewById(id).setVisibility(View.GONE);
  }
  ActionMenuButton shareButton=(ActionMenuButton)mPostPictureAlert.findViewById(R.id.share);
  shareButton.setRestricted(mCurrentVideoFileLength > SHARE_FILE_LENGTH_LIMIT);
  connectAndFadeIn(connectIds);
  connectAndFadeIn(alwaysOnIds);
  hideLastPictureButton();
  mPostPictureAlert.setVisibility(View.VISIBLE);
  if (!mIsVideoCaptureIntent) {
    if (mThumbController.isUriValid()) {
      mCurrentVideoUri=mThumbController.getUri();
      mCurrentVideoFilename=getDataPath(mCurrentVideoUri);
    }
 else {
      return;
    }
  }
  String path=mCurrentVideoFilename;
  if (path != null) {
    Bitmap videoFrame=Util.createVideoThumbnail(path);
    mVideoFrame.setImageBitmap(videoFrame);
    mVideoFrame.setVisibility(View.VISIBLE);
  }
}
Program: 184588
Project: 184588
Buggy source:
public void onZoom(boolean zoomIn){
  if (zoomIn) {
    mImageView.zoomIn();
  }
 else {
    mImageView.zoomOut();
  }
}

Fixed version (ground truth):
public void onZoom(boolean zoomIn){
  if (zoomIn) {
    mImageView.zoomIn();
  }
 else {
    mImageView.zoomOut();
  }
  updateZoomButtonsEnabled();
}
Program: 184589
Project: 184589
Buggy source:
private void setupZoomButtonController(View rootView){
  mGestureDetector=new GestureDetector(this,new MyGestureListener());
  mZoomButtonsController=new ZoomButtonsController(rootView);
  mZoomButtonsController.setAutoDismissed(false);
  mZoomButtonsController.setOnZoomListener(new ZoomButtonsController.OnZoomListener(){
    public void onVisibilityChanged(    boolean visible){
      if (visible) {
        updateZoomButtonsEnabled();
      }
    }
    public void onZoom(    boolean zoomIn){
      if (zoomIn) {
        mImageView.zoomIn();
      }
 else {
        mImageView.zoomOut();
      }
    }
  }
);
}

Fixed version (ground truth):
private void setupZoomButtonController(View rootView){
  mGestureDetector=new GestureDetector(this,new MyGestureListener());
  mZoomButtonsController=new ZoomButtonsController(rootView);
  mZoomButtonsController.setAutoDismissed(false);
  mZoomButtonsController.setOnZoomListener(new ZoomButtonsController.OnZoomListener(){
    public void onVisibilityChanged(    boolean visible){
      if (visible) {
        updateZoomButtonsEnabled();
      }
    }
    public void onZoom(    boolean zoomIn){
      if (zoomIn) {
        mImageView.zoomIn();
      }
 else {
        mImageView.zoomOut();
      }
      updateZoomButtonsEnabled();
    }
  }
);
}
Program: 184590
Project: 184590
Buggy source:
public void run(){
  int nextWarning=1;
  while (true) {
    try {
synchronized (watchDogSync) {
        watchDogSync.wait(1000);
      }
    }
 catch (    InterruptedException ex) {
    }
    if (mPreviewing)     break;
    int delay=(int)(SystemClock.elapsedRealtime() - wallTimeStart) / 1000;
    if (delay >= nextWarning) {
      Log.e(TAG,"String_Node_Str" + delay + "String_Node_Str");
      if (nextWarning < 60) {
        nextWarning<<=1;
        if (nextWarning == 16) {
          nextWarning=15;
        }
      }
 else {
        nextWarning+=60;
      }
    }
  }
}

Fixed version (ground truth):
public void run(){
  updateStorageHint(mPicturesRemaining);
}
Program: 184591
Project: 184591
Buggy source:
/** 
 * Initiate the capture of an image.
 */
public void initiate(){
  if (mCameraDevice == null) {
    return;
  }
  mCancel=false;
  mCapturing=true;
  capture();
}

Fixed version (ground truth):
/** 
 * Initiate the capture of an image.
 */
public void initiate(){
  if (mCameraDevice == null) {
    return;
  }
  mCancel=false;
  capture();
}
Program: 184593
Project: 184593
Buggy source:
public void storeImage(byte[] data,android.hardware.Camera camera,Location loc){
  boolean captureOnly=mIsImageCaptureIntent;
  if (!captureOnly) {
    storeImage(data,loc);
    sendBroadcast(new Intent("String_Node_Str",mLastContentUri));
    setLastPictureThumb(data,mCaptureObject.getLastCaptureUri());
    dismissFreezeFrame();
  }
 else {
    BitmapFactory.Options options=new BitmapFactory.Options();
    options.inSampleSize=4;
    if (DEBUG_TIME_OPERATIONS) {
      startTiming();
    }
    mCaptureOnlyBitmap=BitmapFactory.decodeByteArray(data,0,data.length,options);
    if (DEBUG_TIME_OPERATIONS) {
      stopTiming();
      Log.d(TAG,"String_Node_Str" + mCaptureOnlyBitmap.getWidth() + "String_Node_Str"+ mCaptureOnlyBitmap.getHeight()+ "String_Node_Str"+ (mWallTimeEnd - mWallTimeStart)+ "String_Node_Str"+ ((mThreadTimeEnd - mThreadTimeStart) / 1000000)+ "String_Node_Str");
    }
    showPostCaptureAlert();
    cancelAutomaticPreviewRestart();
  }
  mCapturing=false;
}

Fixed version (ground truth):
public void storeImage(byte[] data,android.hardware.Camera camera,Location loc){
  boolean captureOnly=mIsImageCaptureIntent;
  if (!captureOnly) {
    storeImage(data,loc);
    sendBroadcast(new Intent("String_Node_Str",mLastContentUri));
    setLastPictureThumb(data,mCaptureObject.getLastCaptureUri());
    dismissFreezeFrame();
  }
 else {
    BitmapFactory.Options options=new BitmapFactory.Options();
    options.inSampleSize=4;
    mCaptureOnlyBitmap=BitmapFactory.decodeByteArray(data,0,data.length,options);
    showPostCaptureAlert();
    cancelAutomaticPreviewRestart();
  }
}
Program: 184594
Project: 184594
Buggy source:
/** 
 * Given a HashMap of Exif tags and associated values, an Exif section in the JPG file is created and loaded with the tag data. saveAttributes() is expensive because it involves copying all the JPG data from one file to another and deleting the old file and renaming the other. It's best to collect all the attributes to write and make a single call rather than multiple calls for each attribute. You must call "commitChanges()" at some point to commit the changes.
 */
public void saveAttributes(HashMap<String,String> attributes){
  StringBuilder sb=new StringBuilder();
  int size=attributes.size();
  if (attributes.containsKey("String_Node_Str")) {
    --size;
  }
  sb.append(size + "String_Node_Str");
  Iterator<String> keyIterator=attributes.keySet().iterator();
  while (keyIterator.hasNext()) {
    String key=keyIterator.next();
    if (key.equals("String_Node_Str")) {
      continue;
    }
    String val=attributes.get(key);
    sb.append(key + "String_Node_Str");
    sb.append(val.length() + "String_Node_Str");
    sb.append(val);
  }
  String s=sb.toString();
  saveAttributesNative(mFilename,s);
  commitChangesNative(mFilename);
  mSavedAttributes=true;
}

Fixed version (ground truth):
/** 
 * Given a HashMap of Exif tags and associated values, an Exif section in the JPG file is created and loaded with the tag data. saveAttributes() is expensive because it involves copying all the JPG data from one file to another and deleting the old file and renaming the other. It's best to collect all the attributes to write and make a single call rather than multiple calls for each attribute. You must call "commitChanges()" at some point to commit the changes.
 */
public void saveAttributes(HashMap<String,String> attributes){
  StringBuilder sb=new StringBuilder();
  int size=attributes.size();
  if (attributes.containsKey("String_Node_Str")) {
    --size;
  }
  sb.append(size + "String_Node_Str");
  for (  Map.Entry<String,String> iter : attributes.entrySet()) {
    String key=iter.getKey();
    if (key.equals("String_Node_Str")) {
      continue;
    }
    String val=iter.getValue();
    sb.append(key + "String_Node_Str");
    sb.append(val.length() + "String_Node_Str");
    sb.append(val);
  }
  String s=sb.toString();
  saveAttributesNative(mFilename,s);
  commitChangesNative(mFilename);
  mSavedAttributes=true;
}
Program: 184595
Project: 184595
Buggy source:
LayoutSpec(int w,int h,int leftEdgePadding,int rightEdgePadding,int intercellSpacing){
  mCellWidth=w;
  mCellHeight=h;
  mLeftEdgePadding=leftEdgePadding;
  mRightEdgePadding=rightEdgePadding;
  mCellSpacing=intercellSpacing;
}

Fixed version (ground truth):
LayoutSpec(int w,int h,int intercellSpacing,int leftEdgePadding){
  mCellWidth=w;
  mCellHeight=h;
  mCellSpacing=intercellSpacing;
  mLeftEdgePadding=leftEdgePadding;
}
Program: 184596
Project: 184596
Buggy source:
private void paintSelection(Canvas canvas){
  if (mCurrentSelection == SELECT_NONE)   return;
  int row=mCurrentSelection / mColumns;
  int col=mCurrentSelection - (row * mColumns);
  int spacing=mSpec.mCellSpacing;
  int leftSpacing=mSpec.mLeftEdgePadding;
  int xPos=leftSpacing + (col * (mSpec.mCellWidth + spacing));
  int yTop=spacing + (row * mBlockHeight);
  int yBottom=yTop + mSpec.mCellHeight;
  int type=OUTLINE_SELECTED;
  if (mCurrentSelectionPressed) {
    type=OUTLINE_PRESSED;
  }
  canvas.drawBitmap(mOutline[type],xPos,yTop,null);
}

Fixed version (ground truth):
private void paintSelection(Canvas canvas){
  if (mCurrentSelection == SELECT_NONE)   return;
  int row=mCurrentSelection / mColumns;
  int col=mCurrentSelection - (row * mColumns);
  int spacing=mSpec.mCellSpacing;
  int leftSpacing=mSpec.mLeftEdgePadding;
  int xPos=leftSpacing + (col * (mSpec.mCellWidth + spacing));
  int yTop=spacing + (row * mBlockHeight);
  int type=OUTLINE_SELECTED;
  if (mCurrentSelectionPressed) {
    type=OUTLINE_PRESSED;
  }
  canvas.drawBitmap(mOutline[type],xPos,yTop,null);
}
Program: 184597
Project: 184597
Buggy source:
@Override public void onLayout(boolean changed,int left,int top,int right,int bottom){
  super.onLayout(changed,left,top,right,bottom);
  if (!mRunning) {
    return;
  }
  mSpec=mCellSizeChoices[mSizeChoice];
  int width=right - left;
  mColumns=1 + (width - mSpec.mCellWidth) / (mSpec.mCellWidth + mSpec.mCellSpacing);
  mSpec.mLeftEdgePadding=(width - ((mColumns - 1) * mSpec.mCellSpacing) - (mColumns * mSpec.mCellWidth)) / 2;
  mSpec.mRightEdgePadding=mSpec.mLeftEdgePadding;
  mRows=(mCount + mColumns - 1) / mColumns;
  mBlockHeight=mSpec.mCellSpacing + mSpec.mCellHeight;
  mMaxScrollY=mSpec.mCellSpacing + (mRows * mBlockHeight) - (bottom - top);
  mScrollY=Math.max(0,Math.min(mMaxScrollY,mScrollY));
  generateOutlineBitmap();
  if (mImageBlockManager != null) {
    mImageBlockManager.recycle();
  }
  mImageBlockManager=new ImageBlockManager(mHandler,mRedrawCallback,mAllImages,mLoader,mDrawAdapter,mSpec,mColumns,width,mOutline[OUTLINE_EMPTY]);
  mListener.onLayoutComplete(changed);
  moveDataWindow();
  mLayoutComplete=true;
}

Fixed version (ground truth):
@Override public void onLayout(boolean changed,int left,int top,int right,int bottom){
  super.onLayout(changed,left,top,right,bottom);
  if (!mRunning) {
    return;
  }
  mSpec=mCellSizeChoices[mSizeChoice];
  int width=right - left;
  mColumns=1 + (width - mSpec.mCellWidth) / (mSpec.mCellWidth + mSpec.mCellSpacing);
  mSpec.mLeftEdgePadding=(width - ((mColumns - 1) * mSpec.mCellSpacing) - (mColumns * mSpec.mCellWidth)) / 2;
  mRows=(mCount + mColumns - 1) / mColumns;
  mBlockHeight=mSpec.mCellSpacing + mSpec.mCellHeight;
  mMaxScrollY=mSpec.mCellSpacing + (mRows * mBlockHeight) - (bottom - top);
  mScrollY=Math.max(0,Math.min(mMaxScrollY,mScrollY));
  generateOutlineBitmap();
  if (mImageBlockManager != null) {
    mImageBlockManager.recycle();
  }
  mImageBlockManager=new ImageBlockManager(mHandler,mRedrawCallback,mAllImages,mLoader,mDrawAdapter,mSpec,mColumns,width,mOutline[OUTLINE_EMPTY]);
  mListener.onLayoutComplete(changed);
  moveDataWindow();
  mLayoutComplete=true;
}
Program: 184598
Project: 184598
Buggy source:
@Override public boolean onFling(MotionEvent e1,MotionEvent e2,float velocityX,float velocityY){
  final float maxVelocity=2500;
  if (velocityY > maxVelocity) {
    velocityY=maxVelocity;
  }
 else   if (velocityY < -maxVelocity) {
    velocityY=-maxVelocity;
  }
  select(SELECT_NONE,false);
  if (mFling) {
    mScroller=new Scroller(getContext());
    mScroller.fling(0,mScrollY,0,-(int)velocityY,0,0,0,mMaxScrollY);
    computeScroll();
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean onFling(MotionEvent e1,MotionEvent e2,float velocityX,float velocityY){
  final float maxVelocity=2500;
  if (velocityY > maxVelocity) {
    velocityY=maxVelocity;
  }
 else   if (velocityY < -maxVelocity) {
    velocityY=-maxVelocity;
  }
  select(SELECT_NONE,false);
  mScroller=new Scroller(getContext());
  mScroller.fling(0,mScrollY,0,-(int)velocityY,0,0,0,mMaxScrollY);
  computeScroll();
  return true;
}
Program: 184599
Project: 184599
Buggy source:
public void setImageBitmapResetBase(final Bitmap bitmap,final boolean resetSupp){
  final int viewWidth=getWidth();
  final int viewHeight=getHeight();
  if (viewWidth <= 0) {
    mOnLayoutRunnable=new Runnable(){
      public void run(){
        setImageBitmapResetBase(bitmap,resetSupp);
      }
    }
;
    return;
  }
  if (bitmap != null) {
    getProperBaseMatrix(bitmap,mBaseMatrix);
    setImageBitmap(bitmap);
  }
 else {
    mBaseMatrix.reset();
    setImageBitmap(null);
  }
  if (resetSupp) {
    mSuppMatrix.reset();
  }
  setImageMatrix(getImageViewMatrix());
  mMaxZoom=maxZoom();
}

Fixed version (ground truth):
public void setImageBitmapResetBase(final Bitmap bitmap,final boolean resetSupp){
  final int viewWidth=getWidth();
  if (viewWidth <= 0) {
    mOnLayoutRunnable=new Runnable(){
      public void run(){
        setImageBitmapResetBase(bitmap,resetSupp);
      }
    }
;
    return;
  }
  if (bitmap != null) {
    getProperBaseMatrix(bitmap,mBaseMatrix);
    setImageBitmap(bitmap);
  }
 else {
    mBaseMatrix.reset();
    setImageBitmap(null);
  }
  if (resetSupp) {
    mSuppMatrix.reset();
  }
  setImageMatrix(getImageViewMatrix());
  mMaxZoom=maxZoom();
}
Program: 184600
Project: 184600
Buggy source:
private Integer getBookmark(){
  if (!uriSupportsBookmarks(mUri)) {
    return null;
  }
  String[] projection=new String[]{Video.VideoColumns.DURATION,Video.VideoColumns.BOOKMARK};
  try {
    Cursor cursor=getContentResolver().query(mUri,projection,null,null,null);
    if (cursor != null) {
      try {
        if (cursor.moveToFirst()) {
          int duration=getCursorInteger(cursor,0);
          int bookmark=getCursorInteger(cursor,1);
          final int ONE_MINUTE=60 * 1000;
          final int TWO_MINUTES=2 * ONE_MINUTE;
          final int FIVE_MINUTES=5 * ONE_MINUTE;
          if ((bookmark < TWO_MINUTES) || (duration < FIVE_MINUTES) || (bookmark > (duration - ONE_MINUTE))) {
            return null;
          }
          return new Integer(bookmark);
        }
      }
  finally {
        cursor.close();
      }
    }
  }
 catch (  SQLiteException e) {
  }
  return null;
}

Fixed version (ground truth):
private Integer getBookmark(){
  if (!uriSupportsBookmarks(mUri)) {
    return null;
  }
  String[] projection=new String[]{Video.VideoColumns.DURATION,Video.VideoColumns.BOOKMARK};
  try {
    Cursor cursor=getContentResolver().query(mUri,projection,null,null,null);
    if (cursor != null) {
      try {
        if (cursor.moveToFirst()) {
          int duration=getCursorInteger(cursor,0);
          int bookmark=getCursorInteger(cursor,1);
          final int ONE_MINUTE=60 * 1000;
          final int TWO_MINUTES=2 * ONE_MINUTE;
          final int FIVE_MINUTES=5 * ONE_MINUTE;
          if ((bookmark < TWO_MINUTES) || (duration < FIVE_MINUTES) || (bookmark > (duration - ONE_MINUTE))) {
            return null;
          }
          return Integer.valueOf(bookmark);
        }
      }
  finally {
        cursor.close();
      }
    }
  }
 catch (  SQLiteException e) {
  }
  return null;
}
Program: 184601
Project: 184601
Buggy source:
public Bitmap thumbBitmap(){
  Bitmap bitmap=null;
  if (mContainer.mThumbUri != null) {
    Cursor c=mContentResolver.query(mContainer.mThumbUri,THUMB_PROJECTION,Thumbnails.IMAGE_ID + "String_Node_Str",new String[]{String.valueOf(fullSizeImageId())},null);
    try {
      if (c.moveToFirst()) {
        bitmap=decodeCurrentImage(c.getLong(0));
      }
    }
 catch (    RuntimeException ex) {
      return null;
    }
 finally {
      c.close();
    }
  }
  if (bitmap == null) {
    bitmap=fullSizeBitmap(THUMBNAIL_TARGET_SIZE,false);
    bitmap=mContainer.storeThumbnail(bitmap,fullSizeImageId());
  }
  if (bitmap != null) {
    bitmap=Util.rotate(bitmap,getDegreesRotated());
  }
  long elapsed=System.currentTimeMillis();
  return bitmap;
}

Fixed version (ground truth):
public Bitmap thumbBitmap(){
  Bitmap bitmap=null;
  if (mContainer.mThumbUri != null) {
    Cursor c=mContentResolver.query(mContainer.mThumbUri,THUMB_PROJECTION,Thumbnails.IMAGE_ID + "String_Node_Str",new String[]{String.valueOf(fullSizeImageId())},null);
    try {
      if (c.moveToFirst()) {
        bitmap=decodeCurrentImage(c.getLong(0));
      }
    }
 catch (    RuntimeException ex) {
      return null;
    }
 finally {
      c.close();
    }
  }
  if (bitmap == null) {
    bitmap=fullSizeBitmap(THUMBNAIL_TARGET_SIZE,false);
    bitmap=mContainer.storeThumbnail(bitmap,fullSizeImageId());
  }
  if (bitmap != null) {
    bitmap=Util.rotate(bitmap,getDegreesRotated());
  }
  return bitmap;
}
Program: 184602
Project: 184602
Buggy source:
private BitmapFactory.Options snifBitmapOptions(){
  ParcelFileDescriptor input=getPFD();
  if (input == null)   return null;
  try {
    Uri uri=fullSizeImageUri();
    BitmapFactory.Options options=new BitmapFactory.Options();
    options.inJustDecodeBounds=true;
    BitmapManager.instance().decodeFileDescriptor(input.getFileDescriptor(),options);
    return options;
  }
  finally {
    Util.closeSiliently(input);
  }
}

Fixed version (ground truth):
private BitmapFactory.Options snifBitmapOptions(){
  ParcelFileDescriptor input=getPFD();
  if (input == null)   return null;
  try {
    BitmapFactory.Options options=new BitmapFactory.Options();
    options.inJustDecodeBounds=true;
    BitmapManager.instance().decodeFileDescriptor(input.getFileDescriptor(),options);
    return options;
  }
  finally {
    Util.closeSiliently(input);
  }
}
Program: 184603
Project: 184603
Buggy source:
/** 
 * Make sure "acquire/release" are pairing correctly
 */
public synchronized void releaseResourceLock(){
  Thread t=Thread.currentThread();
  mLocked=false;
  notifyAll();
}

Fixed version (ground truth):
/** 
 * Make sure "acquire/release" are pairing correctly
 */
public synchronized void releaseResourceLock(){
  mLocked=false;
  notifyAll();
}
Program: 184605
Project: 184605
Buggy source:
private synchronized void start(){
  if (mDecodeThread != null) {
    return;
  }
  mDone=false;
  Thread t=new Thread(new WorkerThread());
  t.setName("String_Node_Str");
  mDecodeThread=t;
  t.start();
}

Fixed version (ground truth):
private void start(){
  if (mDecodeThread != null) {
    return;
  }
  mDone=false;
  Thread t=new Thread(new WorkerThread());
  t.setName("String_Node_Str");
  mDecodeThread=t;
  t.start();
}
Program: 184606
Project: 184606
Buggy source:
public void run(){
  while (!mDone) {
    WorkItem workItem=null;
synchronized (mQueue) {
      if (!mQueue.isEmpty()) {
        workItem=mQueue.remove(0);
      }
 else {
        if (!mThumbnailChecker.hasMoreThumbnailsToCheck()) {
          try {
            mQueue.wait();
          }
 catch (          InterruptedException ex) {
          }
          continue;
        }
      }
    }
    if (workItem == null) {
      mThumbnailChecker.checkNextThumbnail();
      continue;
    }
    final Bitmap b=workItem.mImage.miniThumbBitmap();
    if (workItem.mOnLoadedRunnable != null) {
      workItem.mOnLoadedRunnable.run(b);
    }
  }
}

Fixed version (ground truth):
public void run(){
  while (true) {
    WorkItem workItem=null;
synchronized (mQueue) {
      if (mDone) {
        break;
      }
      if (!mQueue.isEmpty()) {
        workItem=mQueue.remove(0);
      }
 else {
        if (!mThumbnailChecker.hasMoreThumbnailsToCheck()) {
          try {
            mQueue.wait();
          }
 catch (          InterruptedException ex) {
          }
          continue;
        }
      }
    }
    if (workItem == null) {
      mThumbnailChecker.checkNextThumbnail();
      continue;
    }
    final Bitmap b=workItem.mImage.miniThumbBitmap();
    if (workItem.mOnLoadedRunnable != null) {
      workItem.mOnLoadedRunnable.run(b);
    }
  }
}
Program: 184607
Project: 184607
Buggy source:
public synchronized void stop(){
  mDone=true;
synchronized (mQueue) {
    mQueue.notifyAll();
  }
  if (mDecodeThread != null) {
    try {
      Thread t=mDecodeThread;
      BitmapManager.instance().cancelThreadDecoding(t);
      t.join();
      mDecodeThread=null;
    }
 catch (    InterruptedException ex) {
    }
  }
  stopCheckingThumbnails();
}

Fixed version (ground truth):
public void stop(){
synchronized (mQueue) {
    mDone=true;
    mQueue.notifyAll();
  }
  if (mDecodeThread != null) {
    try {
      Thread t=mDecodeThread;
      BitmapManager.instance().cancelThreadDecoding(t);
      t.join();
      mDecodeThread=null;
    }
 catch (    InterruptedException ex) {
    }
  }
  stopCheckingThumbnails();
}
Program: 184608
Project: 184608
Buggy source:
public ImageLoader(Handler handler){
  mHandler=handler;
  mThumbnailChecker=new ThumbnailChecker();
  start();
}

Fixed version (ground truth):
public ImageLoader(Handler handler){
  mThumbnailChecker=new ThumbnailChecker();
  start();
}
Program: 184609
Project: 184609
Buggy source:
public static Uri addImage(ContentResolver cr,String title,long dateTaken,Location location,int orientation,String directory,String filename){
  ContentValues values=new ContentValues(7);
  values.put(Images.Media.TITLE,title);
  values.put(Images.Media.DISPLAY_NAME,filename);
  values.put(Images.Media.DATE_TAKEN,dateTaken);
  values.put(Images.Media.MIME_TYPE,"String_Node_Str");
  values.put(Images.Media.ORIENTATION,orientation);
  File parentFile=new File(directory);
  String path=parentFile.toString().toLowerCase();
  String name=parentFile.getName();
  if (location != null) {
    values.put(Images.Media.LATITUDE,location.getLatitude());
    values.put(Images.Media.LONGITUDE,location.getLongitude());
  }
  if (directory != null && filename != null) {
    String value=directory + "String_Node_Str" + filename;
    values.put(Images.Media.DATA,value);
  }
  return cr.insert(STORAGE_URI,values);
}

Fixed version (ground truth):
public static Uri addImage(ContentResolver cr,String title,long dateTaken,Location location,int orientation,String directory,String filename){
  ContentValues values=new ContentValues(7);
  values.put(Images.Media.TITLE,title);
  values.put(Images.Media.DISPLAY_NAME,filename);
  values.put(Images.Media.DATE_TAKEN,dateTaken);
  values.put(Images.Media.MIME_TYPE,"String_Node_Str");
  values.put(Images.Media.ORIENTATION,orientation);
  if (location != null) {
    values.put(Images.Media.LATITUDE,location.getLatitude());
    values.put(Images.Media.LONGITUDE,location.getLongitude());
  }
  if (directory != null && filename != null) {
    String value=directory + "String_Node_Str" + filename;
    values.put(Images.Media.DATA,value);
  }
  return cr.insert(STORAGE_URI,values);
}
Program: 184611
Project: 184611
Buggy source:
private static void setReverseGeocodingDetails(View d,Activity context,float lat,float lng){
  String value=EMPTY_STRING;
  if (lat == INVALID_LATLNG || lng == INVALID_LATLNG) {
    hideDetailsRow(d,R.id.details_location_row);
    return;
  }
  try {
    Geocoder geocoder=new Geocoder(context);
    List<Address> address=geocoder.getFromLocation(lat,lng,1);
    Iterator<Address> iterator=address.iterator();
    while (iterator.hasNext()) {
      Address addr=iterator.next();
      value+=addr.getAddressLine(addr.getMaxAddressLineIndex());
      Log.v(TAG,addr.toString());
    }
  }
 catch (  IOException ex) {
    value=EMPTY_STRING;
    Log.e(TAG,"String_Node_Str",ex);
  }
catch (  RuntimeException ex) {
    value=EMPTY_STRING;
    Log.e(TAG,"String_Node_Str",ex);
  }
  if (value != EMPTY_STRING) {
    setDetailsValue(d,value,R.id.details_location_value);
  }
 else {
    hideDetailsRow(d,R.id.details_location_row);
  }
}

Fixed version (ground truth):
private static void setReverseGeocodingDetails(View d,Activity context,float lat,float lng){
  String value=EMPTY_STRING;
  if (lat == INVALID_LATLNG || lng == INVALID_LATLNG) {
    hideDetailsRow(d,R.id.details_location_row);
    return;
  }
  try {
    Geocoder geocoder=new Geocoder(context);
    List<Address> address=geocoder.getFromLocation(lat,lng,1);
    StringBuilder sb=new StringBuilder();
    for (    Address addr : address) {
      int index=addr.getMaxAddressLineIndex();
      sb.append(addr.getAddressLine(index));
    }
    value=sb.toString();
  }
 catch (  IOException ex) {
    value=EMPTY_STRING;
    Log.e(TAG,"String_Node_Str",ex);
  }
catch (  RuntimeException ex) {
    value=EMPTY_STRING;
    Log.e(TAG,"String_Node_Str",ex);
  }
  if (value != EMPTY_STRING) {
    setDetailsValue(d,value,R.id.details_location_value);
  }
 else {
    hideDetailsRow(d,R.id.details_location_row);
  }
}
Program: 184612
Project: 184612
Buggy source:
private void loadExifData(){
  Cursor c=getCursor();
  String filePath;
synchronized (c) {
    filePath=c.getString(mContainer.indexData());
  }
  ExifInterface mExif=new ExifInterface(filePath);
  if (mExifData == null) {
    mExifData=mExif.getAttributes();
  }
}

Fixed version (ground truth):
private void loadExifData(){
  Cursor c=getCursor();
  String filePath;
synchronized (c) {
    filePath=c.getString(mContainer.indexData());
  }
  mExif=new ExifInterface(filePath);
  if (mExifData == null) {
    mExifData=mExif.getAttributes();
  }
}
Program: 184614
Project: 184614
Buggy source:
byte[] getMiniThumbFromFile(long id,byte[] data,long magicCheck){
  RandomAccessFile r=miniThumbDataFile();
  if (r == null)   return null;
  long pos=id * BYTES_PER_MINTHUMB;
synchronized (r) {
    try {
      r.seek(pos);
      if (r.readByte() == 1) {
        long magic=r.readLong();
        if (magic != magicCheck) {
          return null;
        }
        int length=r.readInt();
        r.read(data,0,length);
        return data;
      }
 else {
        return null;
      }
    }
 catch (    IOException ex) {
      return null;
    }
  }
}

Fixed version (ground truth):
byte[] getMiniThumbFromFile(long id,byte[] data,long magicCheck){
  RandomAccessFile r=miniThumbDataFile();
  if (r == null)   return null;
  long pos=id * BYTES_PER_MINTHUMB;
synchronized (r) {
    try {
      r.seek(pos);
      if (r.readByte() == 1) {
        long magic=r.readLong();
        if (magic != magicCheck) {
          return null;
        }
        int length=r.readInt();
        int got=r.read(data,0,length);
        if (got != length)         return null;
        return data;
      }
 else {
        return null;
      }
    }
 catch (    IOException ex) {
      return null;
    }
  }
}
Program: 184615
Project: 184615
Buggy source:
public void stop(){
  mScroller=null;
  if (mImageBlockManager != null) {
    mImageBlockManager.recycle();
    mImageBlockManager=null;
  }
  mRunning=false;
}

Fixed version (ground truth):
public void stop(){
  mHandler.removeCallbacks(mLongPressCallback);
  mScroller=null;
  if (mImageBlockManager != null) {
    mImageBlockManager.recycle();
    mImageBlockManager=null;
  }
  mRunning=false;
}
Program: 184616
Project: 184616
Buggy source:
@Override public void onLongPress(MotionEvent e){
  performLongClick();
}

Fixed version (ground truth):
@Override public void onLongPress(MotionEvent e){
  if (GridViewSpecial.this.mRunning) {
    performLongClick();
  }
}
Program: 184617
Project: 184617
Buggy source:
public void stop(){
  mScroller=null;
  if (mImageBlockManager != null) {
    mImageBlockManager.recycle();
    mImageBlockManager=null;
  }
  mRunning=false;
}

Fixed version (ground truth):
public void stop(){
  mHandler.removeCallbacks(mLongPressCallback);
  mScroller=null;
  if (mImageBlockManager != null) {
    mImageBlockManager.recycle();
    mImageBlockManager=null;
  }
  mRunning=false;
}
Program: 184618
Project: 184618
Buggy source:
@Override public void onLongPress(MotionEvent e){
  performLongClick();
}

Fixed version (ground truth):
@Override public void onLongPress(MotionEvent e){
  if (GridViewSpecial.this.mRunning) {
    performLongClick();
  }
}
Program: 184619
Project: 184619
Buggy source:
public void run(){
  int nextWarning=1;
  while (true) {
    try {
synchronized (watchDogSync) {
        watchDogSync.wait(1000);
      }
    }
 catch (    InterruptedException ex) {
    }
    if (mPreviewing)     break;
    int delay=(int)(SystemClock.elapsedRealtime() - wallTimeStart) / 1000;
    if (delay >= nextWarning) {
      Log.e(TAG,"String_Node_Str" + delay + "String_Node_Str");
      if (nextWarning < 60) {
        nextWarning<<=1;
        if (nextWarning == 16) {
          nextWarning=15;
        }
      }
 else {
        nextWarning+=60;
      }
    }
  }
}

Fixed version (ground truth):
public void run(){
  updateStorageHint(mPicturesRemaining);
}
Program: 184620
Project: 184620
Buggy source:
/** 
 * Initiate the capture of an image.
 */
public void initiate(){
  if (mCameraDevice == null) {
    return;
  }
  mCancel=false;
  mCapturing=true;
  capture();
}

Fixed version (ground truth):
/** 
 * Initiate the capture of an image.
 */
public void initiate(){
  if (mCameraDevice == null) {
    return;
  }
  mCancel=false;
  capture();
}
Program: 184622
Project: 184622
Buggy source:
public void storeImage(byte[] data,android.hardware.Camera camera,Location loc){
  boolean captureOnly=mIsImageCaptureIntent;
  if (!captureOnly) {
    storeImage(data,loc);
    sendBroadcast(new Intent("String_Node_Str",mLastContentUri));
    setLastPictureThumb(data,mCaptureObject.getLastCaptureUri());
    dismissFreezeFrame();
  }
 else {
    BitmapFactory.Options options=new BitmapFactory.Options();
    options.inSampleSize=4;
    if (DEBUG_TIME_OPERATIONS) {
      startTiming();
    }
    mCaptureOnlyBitmap=BitmapFactory.decodeByteArray(data,0,data.length,options);
    if (DEBUG_TIME_OPERATIONS) {
      stopTiming();
      Log.d(TAG,"String_Node_Str" + mCaptureOnlyBitmap.getWidth() + "String_Node_Str"+ mCaptureOnlyBitmap.getHeight()+ "String_Node_Str"+ (mWallTimeEnd - mWallTimeStart)+ "String_Node_Str"+ ((mThreadTimeEnd - mThreadTimeStart) / 1000000)+ "String_Node_Str");
    }
    showPostCaptureAlert();
    cancelAutomaticPreviewRestart();
  }
  mCapturing=false;
}

Fixed version (ground truth):
public void storeImage(byte[] data,android.hardware.Camera camera,Location loc){
  boolean captureOnly=mIsImageCaptureIntent;
  if (!captureOnly) {
    storeImage(data,loc);
    sendBroadcast(new Intent("String_Node_Str",mLastContentUri));
    setLastPictureThumb(data,mCaptureObject.getLastCaptureUri());
    dismissFreezeFrame();
  }
 else {
    BitmapFactory.Options options=new BitmapFactory.Options();
    options.inSampleSize=4;
    mCaptureOnlyBitmap=BitmapFactory.decodeByteArray(data,0,data.length,options);
    showPostCaptureAlert();
    cancelAutomaticPreviewRestart();
  }
}
Program: 184623
Project: 184623
Buggy source:
/** 
 * Given a HashMap of Exif tags and associated values, an Exif section in the JPG file is created and loaded with the tag data. saveAttributes() is expensive because it involves copying all the JPG data from one file to another and deleting the old file and renaming the other. It's best to collect all the attributes to write and make a single call rather than multiple calls for each attribute. You must call "commitChanges()" at some point to commit the changes.
 */
public void saveAttributes(HashMap<String,String> attributes){
  StringBuilder sb=new StringBuilder();
  int size=attributes.size();
  if (attributes.containsKey("String_Node_Str")) {
    --size;
  }
  sb.append(size + "String_Node_Str");
  Iterator<String> keyIterator=attributes.keySet().iterator();
  while (keyIterator.hasNext()) {
    String key=keyIterator.next();
    if (key.equals("String_Node_Str")) {
      continue;
    }
    String val=attributes.get(key);
    sb.append(key + "String_Node_Str");
    sb.append(val.length() + "String_Node_Str");
    sb.append(val);
  }
  String s=sb.toString();
  saveAttributesNative(mFilename,s);
  commitChangesNative(mFilename);
  mSavedAttributes=true;
}

Fixed version (ground truth):
/** 
 * Given a HashMap of Exif tags and associated values, an Exif section in the JPG file is created and loaded with the tag data. saveAttributes() is expensive because it involves copying all the JPG data from one file to another and deleting the old file and renaming the other. It's best to collect all the attributes to write and make a single call rather than multiple calls for each attribute. You must call "commitChanges()" at some point to commit the changes.
 */
public void saveAttributes(HashMap<String,String> attributes){
  StringBuilder sb=new StringBuilder();
  int size=attributes.size();
  if (attributes.containsKey("String_Node_Str")) {
    --size;
  }
  sb.append(size + "String_Node_Str");
  for (  Map.Entry<String,String> iter : attributes.entrySet()) {
    String key=iter.getKey();
    if (key.equals("String_Node_Str")) {
      continue;
    }
    String val=iter.getValue();
    sb.append(key + "String_Node_Str");
    sb.append(val.length() + "String_Node_Str");
    sb.append(val);
  }
  String s=sb.toString();
  saveAttributesNative(mFilename,s);
  commitChangesNative(mFilename);
  mSavedAttributes=true;
}
Program: 184624
Project: 184624
Buggy source:
LayoutSpec(int w,int h,int leftEdgePadding,int rightEdgePadding,int intercellSpacing){
  mCellWidth=w;
  mCellHeight=h;
  mLeftEdgePadding=leftEdgePadding;
  mRightEdgePadding=rightEdgePadding;
  mCellSpacing=intercellSpacing;
}

Fixed version (ground truth):
LayoutSpec(int w,int h,int intercellSpacing,int leftEdgePadding){
  mCellWidth=w;
  mCellHeight=h;
  mCellSpacing=intercellSpacing;
  mLeftEdgePadding=leftEdgePadding;
}
Program: 184625
Project: 184625
Buggy source:
private void paintSelection(Canvas canvas){
  if (mCurrentSelection == SELECT_NONE)   return;
  int row=mCurrentSelection / mColumns;
  int col=mCurrentSelection - (row * mColumns);
  int spacing=mSpec.mCellSpacing;
  int leftSpacing=mSpec.mLeftEdgePadding;
  int xPos=leftSpacing + (col * (mSpec.mCellWidth + spacing));
  int yTop=spacing + (row * mBlockHeight);
  int yBottom=yTop + mSpec.mCellHeight;
  int type=OUTLINE_SELECTED;
  if (mCurrentSelectionPressed) {
    type=OUTLINE_PRESSED;
  }
  canvas.drawBitmap(mOutline[type],xPos,yTop,null);
}

Fixed version (ground truth):
private void paintSelection(Canvas canvas){
  if (mCurrentSelection == SELECT_NONE)   return;
  int row=mCurrentSelection / mColumns;
  int col=mCurrentSelection - (row * mColumns);
  int spacing=mSpec.mCellSpacing;
  int leftSpacing=mSpec.mLeftEdgePadding;
  int xPos=leftSpacing + (col * (mSpec.mCellWidth + spacing));
  int yTop=spacing + (row * mBlockHeight);
  int type=OUTLINE_SELECTED;
  if (mCurrentSelectionPressed) {
    type=OUTLINE_PRESSED;
  }
  canvas.drawBitmap(mOutline[type],xPos,yTop,null);
}
Program: 184626
Project: 184626
Buggy source:
@Override public void onLayout(boolean changed,int left,int top,int right,int bottom){
  super.onLayout(changed,left,top,right,bottom);
  if (!mRunning) {
    return;
  }
  mSpec=mCellSizeChoices[mSizeChoice];
  int width=right - left;
  mColumns=1 + (width - mSpec.mCellWidth) / (mSpec.mCellWidth + mSpec.mCellSpacing);
  mSpec.mLeftEdgePadding=(width - ((mColumns - 1) * mSpec.mCellSpacing) - (mColumns * mSpec.mCellWidth)) / 2;
  mSpec.mRightEdgePadding=mSpec.mLeftEdgePadding;
  mRows=(mCount + mColumns - 1) / mColumns;
  mBlockHeight=mSpec.mCellSpacing + mSpec.mCellHeight;
  mMaxScrollY=mSpec.mCellSpacing + (mRows * mBlockHeight) - (bottom - top);
  mScrollY=Math.max(0,Math.min(mMaxScrollY,mScrollY));
  generateOutlineBitmap();
  if (mImageBlockManager != null) {
    mImageBlockManager.recycle();
  }
  mImageBlockManager=new ImageBlockManager(mHandler,mRedrawCallback,mAllImages,mLoader,mDrawAdapter,mSpec,mColumns,width,mOutline[OUTLINE_EMPTY]);
  mListener.onLayoutComplete(changed);
  moveDataWindow();
  mLayoutComplete=true;
}

Fixed version (ground truth):
@Override public void onLayout(boolean changed,int left,int top,int right,int bottom){
  super.onLayout(changed,left,top,right,bottom);
  if (!mRunning) {
    return;
  }
  mSpec=mCellSizeChoices[mSizeChoice];
  int width=right - left;
  mColumns=1 + (width - mSpec.mCellWidth) / (mSpec.mCellWidth + mSpec.mCellSpacing);
  mSpec.mLeftEdgePadding=(width - ((mColumns - 1) * mSpec.mCellSpacing) - (mColumns * mSpec.mCellWidth)) / 2;
  mRows=(mCount + mColumns - 1) / mColumns;
  mBlockHeight=mSpec.mCellSpacing + mSpec.mCellHeight;
  mMaxScrollY=mSpec.mCellSpacing + (mRows * mBlockHeight) - (bottom - top);
  mScrollY=Math.max(0,Math.min(mMaxScrollY,mScrollY));
  generateOutlineBitmap();
  if (mImageBlockManager != null) {
    mImageBlockManager.recycle();
  }
  mImageBlockManager=new ImageBlockManager(mHandler,mRedrawCallback,mAllImages,mLoader,mDrawAdapter,mSpec,mColumns,width,mOutline[OUTLINE_EMPTY]);
  mListener.onLayoutComplete(changed);
  moveDataWindow();
  mLayoutComplete=true;
}
Program: 184627
Project: 184627
Buggy source:
@Override public boolean onFling(MotionEvent e1,MotionEvent e2,float velocityX,float velocityY){
  final float maxVelocity=2500;
  if (velocityY > maxVelocity) {
    velocityY=maxVelocity;
  }
 else   if (velocityY < -maxVelocity) {
    velocityY=-maxVelocity;
  }
  select(SELECT_NONE,false);
  if (mFling) {
    mScroller=new Scroller(getContext());
    mScroller.fling(0,mScrollY,0,-(int)velocityY,0,0,0,mMaxScrollY);
    computeScroll();
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean onFling(MotionEvent e1,MotionEvent e2,float velocityX,float velocityY){
  final float maxVelocity=2500;
  if (velocityY > maxVelocity) {
    velocityY=maxVelocity;
  }
 else   if (velocityY < -maxVelocity) {
    velocityY=-maxVelocity;
  }
  select(SELECT_NONE,false);
  mScroller=new Scroller(getContext());
  mScroller.fling(0,mScrollY,0,-(int)velocityY,0,0,0,mMaxScrollY);
  computeScroll();
  return true;
}
Program: 184628
Project: 184628
Buggy source:
public void setImageBitmapResetBase(final Bitmap bitmap,final boolean resetSupp){
  final int viewWidth=getWidth();
  final int viewHeight=getHeight();
  if (viewWidth <= 0) {
    mOnLayoutRunnable=new Runnable(){
      public void run(){
        setImageBitmapResetBase(bitmap,resetSupp);
      }
    }
;
    return;
  }
  if (bitmap != null) {
    getProperBaseMatrix(bitmap,mBaseMatrix);
    setImageBitmap(bitmap);
  }
 else {
    mBaseMatrix.reset();
    setImageBitmap(null);
  }
  if (resetSupp) {
    mSuppMatrix.reset();
  }
  setImageMatrix(getImageViewMatrix());
  mMaxZoom=maxZoom();
}

Fixed version (ground truth):
public void setImageBitmapResetBase(final Bitmap bitmap,final boolean resetSupp){
  final int viewWidth=getWidth();
  if (viewWidth <= 0) {
    mOnLayoutRunnable=new Runnable(){
      public void run(){
        setImageBitmapResetBase(bitmap,resetSupp);
      }
    }
;
    return;
  }
  if (bitmap != null) {
    getProperBaseMatrix(bitmap,mBaseMatrix);
    setImageBitmap(bitmap);
  }
 else {
    mBaseMatrix.reset();
    setImageBitmap(null);
  }
  if (resetSupp) {
    mSuppMatrix.reset();
  }
  setImageMatrix(getImageViewMatrix());
  mMaxZoom=maxZoom();
}
Program: 184629
Project: 184629
Buggy source:
private Integer getBookmark(){
  if (!uriSupportsBookmarks(mUri)) {
    return null;
  }
  String[] projection=new String[]{Video.VideoColumns.DURATION,Video.VideoColumns.BOOKMARK};
  try {
    Cursor cursor=getContentResolver().query(mUri,projection,null,null,null);
    if (cursor != null) {
      try {
        if (cursor.moveToFirst()) {
          int duration=getCursorInteger(cursor,0);
          int bookmark=getCursorInteger(cursor,1);
          final int ONE_MINUTE=60 * 1000;
          final int TWO_MINUTES=2 * ONE_MINUTE;
          final int FIVE_MINUTES=5 * ONE_MINUTE;
          if ((bookmark < TWO_MINUTES) || (duration < FIVE_MINUTES) || (bookmark > (duration - ONE_MINUTE))) {
            return null;
          }
          return new Integer(bookmark);
        }
      }
  finally {
        cursor.close();
      }
    }
  }
 catch (  SQLiteException e) {
  }
  return null;
}

Fixed version (ground truth):
private Integer getBookmark(){
  if (!uriSupportsBookmarks(mUri)) {
    return null;
  }
  String[] projection=new String[]{Video.VideoColumns.DURATION,Video.VideoColumns.BOOKMARK};
  try {
    Cursor cursor=getContentResolver().query(mUri,projection,null,null,null);
    if (cursor != null) {
      try {
        if (cursor.moveToFirst()) {
          int duration=getCursorInteger(cursor,0);
          int bookmark=getCursorInteger(cursor,1);
          final int ONE_MINUTE=60 * 1000;
          final int TWO_MINUTES=2 * ONE_MINUTE;
          final int FIVE_MINUTES=5 * ONE_MINUTE;
          if ((bookmark < TWO_MINUTES) || (duration < FIVE_MINUTES) || (bookmark > (duration - ONE_MINUTE))) {
            return null;
          }
          return Integer.valueOf(bookmark);
        }
      }
  finally {
        cursor.close();
      }
    }
  }
 catch (  SQLiteException e) {
  }
  return null;
}
Program: 184630
Project: 184630
Buggy source:
public Bitmap thumbBitmap(){
  Bitmap bitmap=null;
  if (mContainer.mThumbUri != null) {
    Cursor c=mContentResolver.query(mContainer.mThumbUri,THUMB_PROJECTION,Thumbnails.IMAGE_ID + "String_Node_Str",new String[]{String.valueOf(fullSizeImageId())},null);
    try {
      if (c.moveToFirst()) {
        bitmap=decodeCurrentImage(c.getLong(0));
      }
    }
 catch (    RuntimeException ex) {
      return null;
    }
 finally {
      c.close();
    }
  }
  if (bitmap == null) {
    bitmap=fullSizeBitmap(THUMBNAIL_TARGET_SIZE,false);
    bitmap=mContainer.storeThumbnail(bitmap,fullSizeImageId());
  }
  if (bitmap != null) {
    bitmap=Util.rotate(bitmap,getDegreesRotated());
  }
  long elapsed=System.currentTimeMillis();
  return bitmap;
}

Fixed version (ground truth):
public Bitmap thumbBitmap(){
  Bitmap bitmap=null;
  if (mContainer.mThumbUri != null) {
    Cursor c=mContentResolver.query(mContainer.mThumbUri,THUMB_PROJECTION,Thumbnails.IMAGE_ID + "String_Node_Str",new String[]{String.valueOf(fullSizeImageId())},null);
    try {
      if (c.moveToFirst()) {
        bitmap=decodeCurrentImage(c.getLong(0));
      }
    }
 catch (    RuntimeException ex) {
      return null;
    }
 finally {
      c.close();
    }
  }
  if (bitmap == null) {
    bitmap=fullSizeBitmap(THUMBNAIL_TARGET_SIZE,false);
    bitmap=mContainer.storeThumbnail(bitmap,fullSizeImageId());
  }
  if (bitmap != null) {
    bitmap=Util.rotate(bitmap,getDegreesRotated());
  }
  return bitmap;
}
Program: 184631
Project: 184631
Buggy source:
private BitmapFactory.Options snifBitmapOptions(){
  ParcelFileDescriptor input=getPFD();
  if (input == null)   return null;
  try {
    Uri uri=fullSizeImageUri();
    BitmapFactory.Options options=new BitmapFactory.Options();
    options.inJustDecodeBounds=true;
    BitmapManager.instance().decodeFileDescriptor(input.getFileDescriptor(),options);
    return options;
  }
  finally {
    Util.closeSiliently(input);
  }
}

Fixed version (ground truth):
private BitmapFactory.Options snifBitmapOptions(){
  ParcelFileDescriptor input=getPFD();
  if (input == null)   return null;
  try {
    BitmapFactory.Options options=new BitmapFactory.Options();
    options.inJustDecodeBounds=true;
    BitmapManager.instance().decodeFileDescriptor(input.getFileDescriptor(),options);
    return options;
  }
  finally {
    Util.closeSiliently(input);
  }
}
Program: 184632
Project: 184632
Buggy source:
private static boolean onShowMapClicked(MenuInvoker onInvoke,final Handler handler,final Activity activity){
  onInvoke.run(new MenuCallback(){
    public void run(    Uri u,    IImage image){
      if (image == null) {
        return;
      }
      float lat=getLatLng((Image)image,ExifInterface.TAG_GPS_LATITUDE);
      float lng=getLatLng((Image)image,ExifInterface.TAG_GPS_LONGITUDE);
      if (lat == INVALID_LATLNG || lng == INVALID_LATLNG) {
        handler.post(new Runnable(){
          public void run(){
            Toast.makeText(activity,R.string.no_location_image,Toast.LENGTH_SHORT).show();
          }
        }
);
        return;
      }
      String uri="String_Node_Str" + "String_Node_Str" + lat + "String_Node_Str"+ lng+ "String_Node_Str";
      activity.startActivity(new Intent(android.content.Intent.ACTION_VIEW,Uri.parse(uri)));
    }
  }
);
  return true;
}

Fixed version (ground truth):
private static boolean onShowMapClicked(MenuInvoker onInvoke,final Handler handler,final Activity activity){
  onInvoke.run(new MenuCallback(){
    public void run(    Uri u,    IImage image){
      if (image == null) {
        return;
      }
      float[] latlng=getLatLng(getExifData(image));
      if (latlng == null) {
        handler.post(new Runnable(){
          public void run(){
            Toast.makeText(activity,R.string.no_location_image,Toast.LENGTH_SHORT).show();
          }
        }
);
        return;
      }
      String uri="String_Node_Str" + "String_Node_Str" + latlng[0] + "String_Node_Str"+ latlng[1]+ "String_Node_Str";
      activity.startActivity(new Intent(android.content.Intent.ACTION_VIEW,Uri.parse(uri)));
    }
  }
);
  return true;
}