[ 
https://issues.apache.org/jira/browse/NIFI-5761?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16668061#comment-16668061
 ] 

ASF GitHub Bot commented on NIFI-5761:
--------------------------------------

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.


> ReplaceText processor can stop processing data if it evaluates invalid 
> expressions
> ----------------------------------------------------------------------------------
>
>                 Key: NIFI-5761
>                 URL: https://issues.apache.org/jira/browse/NIFI-5761
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Extensions
>    Affects Versions: 1.5.0, 1.7.1
>         Environment: ALL
>            Reporter: Gardella Juan Pablo
>            Assignee: Gardella Juan Pablo
>            Priority: Major
>   Original Estimate: 3h
>  Remaining Estimate: 3h
>
> Given a flowfile body with nifi expression, when _ReplaceText_ processor 
> evaluates it and the expression throws an exception, the processor will 
> rollback the flowfile and keep trying to evaluate instead of send the 
> flowfile to _failure_ relationshipt.
> Discussion Thread: 
> http://apache-nifi-users-list.2361937.n4.nabble.com/ReplaceText-cannot-consume-messages-if-Regex-does-not-match-td5986.html



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to