This is an automated email from the ASF dual-hosted git repository.

exceptionfactory pushed a commit to branch support/nifi-1.x
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/support/nifi-1.x by this push:
     new 0987009733 NIFI-13692 Catch All Exceptions in ResizeImage (#9216)
0987009733 is described below

commit 09870097331b0a1386eaa263d63fc476a447c94a
Author: Mike <[email protected]>
AuthorDate: Thu Aug 29 10:29:58 2024 -0400

    NIFI-13692 Catch All Exceptions in ResizeImage (#9216)
    
    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 <[email protected]>
---
 .../main/java/org/apache/nifi/processors/image/ResizeImage.java  | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git 
a/nifi-nar-bundles/nifi-media-bundle/nifi-media-processors/src/main/java/org/apache/nifi/processors/image/ResizeImage.java
 
b/nifi-nar-bundles/nifi-media-bundle/nifi-media-processors/src/main/java/org/apache/nifi/processors/image/ResizeImage.java
index ca860b4758..8d7076bffb 100644
--- 
a/nifi-nar-bundles/nifi-media-bundle/nifi-media-processors/src/main/java/org/apache/nifi/processors/image/ResizeImage.java
+++ 
b/nifi-nar-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;
@@ -171,7 +170,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;
@@ -190,8 +189,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 ex) {
+            getLogger().error("Failed to resize {} due to {}", flowFile, ex);
             session.transfer(flowFile, REL_FAILURE);
             return;
         }
@@ -218,7 +217,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;

Reply via email to