Program: 184635
Project: 184635
Buggy source:
private static boolean onDetailsClicked(MenuInvoker onInvoke,final Handler handler,final Activity activity,final boolean isImage){
  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.getDisplayName());
      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 (isImage) {
        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) {
          }
        }
      }
      Image img=(Image)image;
      String value=null;
      if (dimensionWidth > 0 && dimensionHeight > 0) {
        value=String.format(activity.getString(R.string.details_dimension_x),dimensionWidth,dimensionHeight);
      }
 else {
        String width=img.getExifTag(ExifInterface.TAG_IMAGE_WIDTH);
        String height=img.getExifTag(ExifInterface.TAG_IMAGE_LENGTH);
        if (width != null && height != null) {
          value=EMPTY_STRING + width + "String_Node_Str"+ height;
        }
      }
      if (value != null) {
        setDetailsValue(d,value,R.id.details_resolution_value);
      }
 else {
        hideDetailsRow(d,R.id.details_resolution_row);
      }
      value=img.getExifTag(ExifInterface.TAG_MAKE);
      if (value != null) {
        setDetailsValue(d,value,R.id.details_make_value);
      }
 else {
        hideDetailsRow(d,R.id.details_make_row);
      }
      value=img.getExifTag(ExifInterface.TAG_MODEL);
      if (value != null) {
        setDetailsValue(d,value,R.id.details_model_value);
      }
 else {
        hideDetailsRow(d,R.id.details_model_row);
      }
      value=img.getExifTag(ExifInterface.TAG_WHITE_BALANCE);
      if (value != null) {
        value=ExifInterface.whiteBalanceToString(Integer.parseInt(value));
      }
      if (value != null) {
        setDetailsValue(d,value,R.id.details_whitebalance_value);
      }
 else {
        hideDetailsRow(d,R.id.details_whitebalance_row);
      }
      float lat=setLatLngDetails(d,img,ExifInterface.TAG_GPS_LATITUDE,ExifInterface.TAG_GPS_LATITUDE_REF);
      float lng=setLatLngDetails(d,img,ExifInterface.TAG_GPS_LONGITUDE,ExifInterface.TAG_GPS_LONGITUDE_REF);
      setReverseGeocodingDetails(d,activity,lat,lng);
      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);
      }
      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,final boolean isImage){
  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.getDisplayName());
      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 (isImage) {
        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;
}