Program: 72189
Project: 72189
Buggy source:
/** 
 * get intrinsic dimension of image in pixels. Now only support png, bmp, jpg, gif.
 * @param in
 * @return
 * @throws IOException
 * @throws MalformedURLException
 * @throws BadElementException
 */
protected Dimension getIntrinsicDimension(IImageContent content) throws BadElementException, MalformedURLException, IOException {
  Image image=null;
switch (content.getImageSource()) {
case IImageContent.IMAGE_FILE:
    ReportDesignHandle design=content.getReportContent().getDesign().getReportDesign();
  URL url=design.findResource(content.getURI(),IResourceLocator.IMAGE);
InputStream in=url.openStream();
try {
byte[] buffer=new byte[in.available()];
in.read(buffer);
image=Image.getInstance(buffer);
}
 catch (Exception ex) {
logger.log(Level.WARNING,ex.getMessage(),ex);
}
 finally {
in.close();
}
break;
case IImageContent.IMAGE_NAME:
case IImageContent.IMAGE_EXPRESSION:
image=Image.getInstance(content.getData());
break;
case IImageContent.IMAGE_URL:
image=Image.getInstance(new URL(content.getURI()));
break;
default :
assert(false);
}
if (image != null) {
int resolution=96;
int contentResolution=content.getResolution();
if (contentResolution != 0) {
resolution=contentResolution;
}
return new Dimension((int)(image.plainWidth() * 1000 / resolution * 72),(int)(image.plainHeight() * 1000 / resolution * 72));
}
return null;
}

Fixed version (ground truth):
/** 
 * get intrinsic dimension of image in pixels. Now only support png, bmp, jpg, gif.
 * @param in
 * @return
 * @throws IOException
 * @throws MalformedURLException
 * @throws BadElementException
 */
protected Dimension getIntrinsicDimension(IImageContent content) throws BadElementException, MalformedURLException, IOException {
  Image image=null;
  String uri=content.getURI();
  String mimeType=content.getMIMEType();
  String extension=content.getExtension();
switch (content.getImageSource()) {
case IImageContent.IMAGE_FILE:
    ReportDesignHandle design=content.getReportContent().getDesign().getReportDesign();
  URL url=design.findResource(uri,IResourceLocator.IMAGE);
InputStream in=url.openStream();
try {
byte[] buffer;
if (SvgFile.isSvg(content.getURI())) {
  buffer=SvgFile.transSvgToArray(in);
}
 else {
  ArrayList<Byte> bytes=new ArrayList<Byte>();
  int data=in.read();
  while (data != -1) {
    bytes.add((byte)data);
    data=in.read();
  }
  buffer=new byte[bytes.size()];
  for (int i=0; i < buffer.length; i++) {
    buffer[i]=bytes.get(i);
  }
}
image=Image.getInstance(buffer);
}
 catch (Exception ex) {
logger.log(Level.WARNING,ex.getMessage(),ex);
}
 finally {
in.close();
}
break;
case IImageContent.IMAGE_NAME:
case IImageContent.IMAGE_EXPRESSION:
byte[] data=content.getData();
in=new ByteArrayInputStream(data);
if (SvgFile.isSvg(mimeType,uri,extension)) data=SvgFile.transSvgToArray(in);
image=Image.getInstance(data);
break;
case IImageContent.IMAGE_URL:
if (SvgFile.isSvg(uri)) {
image=Image.getInstance(SvgFile.transSvgToArray(uri));
}
 else {
image=Image.getInstance(new URL(content.getURI()));
}
break;
default :
assert(false);
}
if (image != null) {
int resolution=96;
int contentResolution=content.getResolution();
if (contentResolution != 0) {
resolution=contentResolution;
}
return new Dimension((int)(image.plainWidth() * 1000 / resolution * 72),(int)(image.plainHeight() * 1000 / resolution * 72));
}
return null;
}