Program: 184398
Project: 184398
Buggy source:
private static boolean onDetailsClicked(MenuInvoker onInvoke,final Handler handler,final Activity activity){
  onInvoke.run(new MenuCallback(){
    public void run(    Uri u,    IImage image){
      if (image == null) {
        return;
      }
      final AlertDialog.Builder builder=new AlertDialog.Builder(activity);
      final View d=View.inflate(activity,R.layout.detailsview,null);
      ImageView imageView=(ImageView)d.findViewById(R.id.details_thumbnail_image);
      imageView.setImageBitmap(image.miniThumbBitmap());
      TextView textView=(TextView)d.findViewById(R.id.details_image_title);
      textView.setText(image.getTitle());
      long length=getImageFileSize(image);
      String lengthString=length < 0 ? EMPTY_STRING : Formatter.formatFileSize(activity,length);
      ((TextView)d.findViewById(R.id.details_file_size_value)).setText(lengthString);
      int dimensionWidth=0;
      int dimensionHeight=0;
      if (ImageManager.isImage(image)) {
        dimensionWidth=image.getWidth();
        dimensionHeight=image.getHeight();
        d.findViewById(R.id.details_duration_row).setVisibility(View.GONE);
        d.findViewById(R.id.details_frame_rate_row).setVisibility(View.GONE);
        d.findViewById(R.id.details_bit_rate_row).setVisibility(View.GONE);
        d.findViewById(R.id.details_format_row).setVisibility(View.GONE);
        d.findViewById(R.id.details_codec_row).setVisibility(View.GONE);
      }
 else {
        MediaMetadataRetriever retriever=new MediaMetadataRetriever();
        try {
          retriever.setMode(MediaMetadataRetriever.MODE_GET_METADATA_ONLY);
          retriever.setDataSource(image.getDataPath());
          try {
            dimensionWidth=Integer.parseInt(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH));
            dimensionHeight=Integer.parseInt(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT));
          }
 catch (          NumberFormatException e) {
            dimensionWidth=0;
            dimensionHeight=0;
          }
          try {
            int durationMs=Integer.parseInt(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION));
            String durationValue=formatDuration(activity,durationMs);
            ((TextView)d.findViewById(R.id.details_duration_value)).setText(durationValue);
          }
 catch (          NumberFormatException e) {
            d.findViewById(R.id.details_frame_rate_row).setVisibility(View.GONE);
          }
          try {
            String frameRate=String.format(activity.getString(R.string.details_fps),Integer.parseInt(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_FRAME_RATE)));
            ((TextView)d.findViewById(R.id.details_frame_rate_value)).setText(frameRate);
          }
 catch (          NumberFormatException e) {
            d.findViewById(R.id.details_frame_rate_row).setVisibility(View.GONE);
          }
          try {
            long bitRate=Long.parseLong(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_BIT_RATE));
            String bps;
            if (bitRate < 1000000) {
              bps=String.format(activity.getString(R.string.details_kbps),bitRate / 1000);
            }
 else {
              bps=String.format(activity.getString(R.string.details_mbps),(bitRate) / 1000000.0);
            }
            ((TextView)d.findViewById(R.id.details_bit_rate_value)).setText(bps);
          }
 catch (          NumberFormatException e) {
            d.findViewById(R.id.details_bit_rate_row).setVisibility(View.GONE);
          }
          String format=retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_FORMAT);
          ((TextView)d.findViewById(R.id.details_format_value)).setText(format);
          String codec=retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_CODEC);
          if (codec != null) {
            setDetailsValue(d,codec,R.id.details_codec_value);
          }
 else {
            hideDetailsRow(d,R.id.details_codec_row);
          }
        }
 catch (        RuntimeException ex) {
        }
 finally {
          try {
            retriever.release();
          }
 catch (          RuntimeException ex) {
          }
        }
      }
      String value=null;
      if (dimensionWidth > 0 && dimensionHeight > 0) {
        value=String.format(activity.getString(R.string.details_dimension_x),dimensionWidth,dimensionHeight);
      }
      if (value != null) {
        setDetailsValue(d,value,R.id.details_resolution_value);
      }
 else {
        hideDetailsRow(d,R.id.details_resolution_row);
      }
      value=EMPTY_STRING;
      long dateTaken=image.getDateTaken();
      if (dateTaken != 0) {
        Date date=new Date(image.getDateTaken());
        SimpleDateFormat dateFormat=new SimpleDateFormat();
        value=dateFormat.format(date);
      }
      if (value != EMPTY_STRING) {
        setDetailsValue(d,value,R.id.details_date_taken_value);
      }
 else {
        hideDetailsRow(d,R.id.details_date_taken_row);
      }
      if (JPEG_MIME_TYPE.equals(image.getMimeType())) {
        showExifInformation(image,d,activity);
      }
 else {
        hideExifInformation(d);
      }
      builder.setNeutralButton(R.string.details_ok,new DialogInterface.OnClickListener(){
        public void onClick(        DialogInterface dialog,        int which){
          dialog.dismiss();
        }
      }
);
      handler.post(new Runnable(){
        public void run(){
          builder.setIcon(android.R.drawable.ic_dialog_info).setTitle(R.string.details_panel_title).setView(d).show();
        }
      }
);
    }
  }
);
  return true;
}

Fixed version (ground truth):
private static boolean onDetailsClicked(MenuInvoker onInvoke,final Handler handler,final Activity activity){
  onInvoke.run(new MenuCallback(){
    public void run(    Uri u,    IImage image){
      if (image == null) {
        return;
      }
      final AlertDialog.Builder builder=new AlertDialog.Builder(activity);
      final View d=View.inflate(activity,R.layout.detailsview,null);
      ImageView imageView=(ImageView)d.findViewById(R.id.details_thumbnail_image);
      imageView.setImageBitmap(image.miniThumbBitmap());
      TextView textView=(TextView)d.findViewById(R.id.details_image_title);
      textView.setText(image.getTitle());
      long length=getImageFileSize(image);
      String lengthString=length < 0 ? EMPTY_STRING : Formatter.formatFileSize(activity,length);
      ((TextView)d.findViewById(R.id.details_file_size_value)).setText(lengthString);
      int dimensionWidth=0;
      int dimensionHeight=0;
      if (ImageManager.isImage(image)) {
        dimensionWidth=image.getWidth();
        dimensionHeight=image.getHeight();
        d.findViewById(R.id.details_duration_row).setVisibility(View.GONE);
        d.findViewById(R.id.details_frame_rate_row).setVisibility(View.GONE);
        d.findViewById(R.id.details_bit_rate_row).setVisibility(View.GONE);
        d.findViewById(R.id.details_format_row).setVisibility(View.GONE);
        d.findViewById(R.id.details_codec_row).setVisibility(View.GONE);
      }
 else {
        MediaMetadataRetriever retriever=new MediaMetadataRetriever();
        try {
          retriever.setMode(MediaMetadataRetriever.MODE_GET_METADATA_ONLY);
          retriever.setDataSource(image.getDataPath());
          try {
            dimensionWidth=Integer.parseInt(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH));
            dimensionHeight=Integer.parseInt(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT));
          }
 catch (          NumberFormatException e) {
            dimensionWidth=0;
            dimensionHeight=0;
          }
          try {
            int durationMs=Integer.parseInt(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION));
            String durationValue=formatDuration(activity,durationMs);
            ((TextView)d.findViewById(R.id.details_duration_value)).setText(durationValue);
          }
 catch (          NumberFormatException e) {
            d.findViewById(R.id.details_frame_rate_row).setVisibility(View.GONE);
          }
          try {
            String frameRate=String.format(activity.getString(R.string.details_fps),Integer.parseInt(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_FRAME_RATE)));
            ((TextView)d.findViewById(R.id.details_frame_rate_value)).setText(frameRate);
          }
 catch (          NumberFormatException e) {
            d.findViewById(R.id.details_frame_rate_row).setVisibility(View.GONE);
          }
          try {
            long bitRate=Long.parseLong(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_BIT_RATE));
            String bps;
            if (bitRate < 1000000) {
              bps=String.format(activity.getString(R.string.details_kbps),bitRate / 1000);
            }
 else {
              bps=String.format(activity.getString(R.string.details_mbps),(bitRate) / 1000000.0);
            }
            ((TextView)d.findViewById(R.id.details_bit_rate_value)).setText(bps);
          }
 catch (          NumberFormatException e) {
            d.findViewById(R.id.details_bit_rate_row).setVisibility(View.GONE);
          }
          String format=retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_FORMAT);
          ((TextView)d.findViewById(R.id.details_format_value)).setText(format);
          String codec=retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_CODEC);
          if (codec != null) {
            setDetailsValue(d,codec,R.id.details_codec_value);
          }
 else {
            hideDetailsRow(d,R.id.details_codec_row);
          }
        }
 catch (        RuntimeException ex) {
        }
 finally {
          try {
            retriever.release();
          }
 catch (          RuntimeException ex) {
          }
        }
      }
      String value=null;
      if (dimensionWidth > 0 && dimensionHeight > 0) {
        value=String.format(activity.getString(R.string.details_dimension_x),dimensionWidth,dimensionHeight);
      }
      if (value != null) {
        setDetailsValue(d,value,R.id.details_resolution_value);
      }
 else {
        hideDetailsRow(d,R.id.details_resolution_row);
      }
      value=EMPTY_STRING;
      long dateTaken=image.getDateTaken();
      if (dateTaken != 0) {
        Date date=new Date(image.getDateTaken());
        DateFormat dateFormat=android.text.format.DateFormat.getDateFormat(activity);
        DateFormat timeFormat=android.text.format.DateFormat.getTimeFormat(activity);
        value=dateFormat.format(date) + ' ' + timeFormat.format(date);
      }
      if (value != EMPTY_STRING) {
        setDetailsValue(d,value,R.id.details_date_taken_value);
      }
 else {
        hideDetailsRow(d,R.id.details_date_taken_row);
      }
      if (JPEG_MIME_TYPE.equals(image.getMimeType())) {
        showExifInformation(image,d,activity);
      }
 else {
        hideExifInformation(d);
      }
      builder.setNeutralButton(R.string.details_ok,new DialogInterface.OnClickListener(){
        public void onClick(        DialogInterface dialog,        int which){
          dialog.dismiss();
        }
      }
);
      handler.post(new Runnable(){
        public void run(){
          builder.setIcon(android.R.drawable.ic_dialog_info).setTitle(R.string.details_panel_title).setView(d).show();
        }
      }
);
    }
  }
);
  return true;
}