Skip to content

Commit

Permalink
NIFI-13692 Catch All Exceptions in ResizeImage (#9213)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
MikeThomsen authored Aug 29, 2024
1 parent 71face8 commit 2fc0ca1
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
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;
Expand Down Expand Up @@ -169,7 +168,7 @@ public void onTrigger(final ProcessContext context, final ProcessSession session
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;
Expand All @@ -188,8 +187,8 @@ public void onTrigger(final ProcessContext context, final ProcessSession session
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;
}
Expand All @@ -216,7 +215,7 @@ public void onTrigger(final ProcessContext context, final ProcessSession session
}

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;
Expand Down

0 comments on commit 2fc0ca1

Please sign in to comment.