Github user ijokarumawak commented on a diff in the pull request:
https://github.com/apache/nifi/pull/3112#discussion_r229163268
--- Diff:
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ReplaceText.java
---
@@ -297,16 +299,22 @@ public void onTrigger(final ProcessContext context,
final ProcessSession session
} catch (StackOverflowError e) {
// Some regular expressions can produce many matches on large
input data size using recursive code
// do not log the StackOverflowError stack trace
- logger.info("Transferred {} to 'failure' due to {}", new
Object[] {flowFile, e.toString()});
- session.transfer(flowFile, REL_FAILURE);
+ sendToFailure(session, flowFile, logger, e);
+ return;
+ } catch (IllegalAttributeException |
AttributeExpressionLanguageException e) {
+ sendToFailure(session, flowFile, logger, e);
return;
}
-
logger.info("Transferred {} to 'success'", new Object[]
{flowFile});
session.getProvenanceReporter().modifyContent(flowFile,
stopWatch.getElapsed(TimeUnit.MILLISECONDS));
session.transfer(flowFile, REL_SUCCESS);
}
+ private static void sendToFailure(final ProcessSession session,
FlowFile flowFile, final ComponentLog logger,
+ Throwable e) {
+ logger.info("Transferred {} to 'failure' due to {}", new Object[]
{ flowFile, e.toString() });
--- End diff --
The existing logging code for `StackOverflowError` does not log exception
stack trace intentionally it seems. But for the added EL related exceptions, we
would like to see stack traces when it happens for further debugging. It can be
done by passing the caught `e` as well to logger method.
Also, log level for EL related exceptions should be ERROR or at least WARN,
instead of INFO.
Avoiding duplicated lines is generally a good idea, but because of these
differences, each catch block should have logging and transfer code.
---