From 2fc0ca1b7bc468892c80cf28ccb650d682359ae4 Mon Sep 17 00:00:00 2001 From: Mike Date: Thu, 29 Aug 2024 10:29:15 -0400 Subject: [PATCH] NIFI-13692 Catch All Exceptions in ResizeImage (#9213) Widening the scope of caught Exceptions for routing to failure ensures that the Processor can catch pretty much everything a user could throw at this processor. Signed-off-by: David Handermann --- .../org/apache/nifi/processors/image/ResizeImage.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/nifi-extension-bundles/nifi-media-bundle/nifi-media-processors/src/main/java/org/apache/nifi/processors/image/ResizeImage.java b/nifi-extension-bundles/nifi-media-bundle/nifi-media-processors/src/main/java/org/apache/nifi/processors/image/ResizeImage.java index 1ad9e12502..3e24005398 100644 --- a/nifi-extension-bundles/nifi-media-bundle/nifi-media-processors/src/main/java/org/apache/nifi/processors/image/ResizeImage.java +++ b/nifi-extension-bundles/nifi-media-bundle/nifi-media-processors/src/main/java/org/apache/nifi/processors/image/ResizeImage.java @@ -23,7 +23,6 @@ import java.awt.Image; import java.awt.Transparency; import java.awt.image.BufferedImage; import java.io.BufferedInputStream; -import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; @@ -169,7 +168,7 @@ public class ResizeImage extends AbstractProcessor { reader.setInput(iis, true); image = reader.read(0); } - } catch (final IOException | RuntimeException ex) { + } catch (final Exception ex) { getLogger().error("Failed to read {} due to {}", flowFile, ex); session.transfer(flowFile, REL_FAILURE); return; @@ -188,8 +187,8 @@ public class ResizeImage extends AbstractProcessor { height = finalDimension.height; } - } catch (final NumberFormatException nfe) { - getLogger().error("Failed to resize {} due to {}", flowFile, nfe); + } catch (final Exception e) { + getLogger().error("Failed to resize {} due to {}", flowFile, e); session.transfer(flowFile, REL_FAILURE); return; } @@ -216,7 +215,7 @@ public class ResizeImage extends AbstractProcessor { } ImageIO.write(scaledBufferedImg, formatName, out); - } catch (final IOException | NegativeArraySizeException ex) { + } catch (final Exception ex) { getLogger().error("Failed to write {} due to {}", flowFile, ex); session.transfer(flowFile, REL_FAILURE); return;