From 9884fceb5b51effd58fedbefd8664703af85afde Mon Sep 17 00:00:00 2001 From: Thomas Gutmann Date: Thu, 14 Mar 2024 00:38:11 +0100 Subject: [PATCH] Fix issue with unchecked iterator-element (#1595) --- .../nLayout/area/style/BackgroundImageInfo.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/nLayout/area/style/BackgroundImageInfo.java b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/nLayout/area/style/BackgroundImageInfo.java index 4dedb0e9fd..67ca68ace3 100644 --- a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/nLayout/area/style/BackgroundImageInfo.java +++ b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/nLayout/area/style/BackgroundImageInfo.java @@ -733,11 +733,14 @@ private int[] getImageResolution(InputStream imageStream) { try { ImageInputStream iis = ImageIO.createImageInputStream(imageStream); Iterator i = ImageIO.getImageReaders(iis); - ImageReader r = i.next(); - r.setInput(iis); - r.read(0); - - IIOMetadata meta = r.getImageMetadata(0); + ImageReader r = null; + IIOMetadata meta = null; + if (i != null && i.hasNext()) { + r = i.next(); + r.setInput(iis); + r.read(0); + meta = r.getImageMetadata(0); + } if (meta != null) { double mm2inch = 25.4; @@ -873,7 +876,7 @@ public void setImageSize(IStyle style) { this.width = this.widthMetricPt; } } - // auto scaling of percentage if one percentage is set and the image size is unset + // auto scaling of percentage if one percentage is set and the image size is unset if (percentageHeight != 1.0 && percentageWidth == 1.0 && pxBackgroundWidth == 0) { percentageWidth = percentageHeight; } else if (percentageWidth != 1.0 && percentageHeight == 1.0 && pxBackgroundHeight == 0) {