NIFI-11900 Catch RuntimeException in ResizeImage failures

This closes #7558

Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
Mike Thomsen 2023-08-02 09:21:08 -04:00 committed by exceptionfactory
parent 80e71068be
commit 49a350a765
No known key found for this signature in database
GPG Key ID: 29B6A52D2AAE8DBA
1 changed files with 5 additions and 5 deletions

View File

@ -169,8 +169,8 @@ public class ResizeImage extends AbstractProcessor {
reader.setInput(iis, true);
image = reader.read(0);
}
} catch (final IOException | IllegalArgumentException | ProcessException ex) {
getLogger().error("Failed to read {} due to {}", new Object[] { flowFile, ex });
} catch (final IOException | RuntimeException ex) {
getLogger().error("Failed to read {} due to {}", flowFile, ex);
session.transfer(flowFile, REL_FAILURE);
return;
}
@ -182,14 +182,14 @@ public class ResizeImage extends AbstractProcessor {
width = context.getProperty(IMAGE_WIDTH).evaluateAttributeExpressions(flowFile).asInteger();
height = context.getProperty(IMAGE_HEIGHT).evaluateAttributeExpressions(flowFile).asInteger();
if(keepRatio) {
if (keepRatio) {
Dimension finalDimension = getScaledDimension(image.getWidth(), image.getHeight(), width, height);
width = finalDimension.width;
height = finalDimension.height;
}
} catch (final NumberFormatException nfe) {
getLogger().error("Failed to resize {} due to {}", new Object[] { flowFile, nfe });
getLogger().error("Failed to resize {} due to {}", flowFile, nfe);
session.transfer(flowFile, REL_FAILURE);
return;
}
@ -217,7 +217,7 @@ public class ResizeImage extends AbstractProcessor {
ImageIO.write(scaledBufferedImg, formatName, out);
} catch (final IOException | NegativeArraySizeException ex) {
getLogger().error("Failed to write {} due to {}", new Object[] { flowFile, ex });
getLogger().error("Failed to write {} due to {}", flowFile, ex);
session.transfer(flowFile, REL_FAILURE);
return;
}