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

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

Github user ijokarumawak commented on the issue:

    https://github.com/apache/nifi/pull/3200
  
    @bdesert @ottobackwards Thanks for reviewing. I've added unit tests.
    
    As a reference, I run the added tests with Lexer before this PR. Following 
tests failed with current Lexer, but passes with the updated Lexer:
    
    This test failed with original Lexer because `[\s]` is converted to `[\\s]` 
by Lexer and didn't match.
    ```
    [ERROR] 
testReplaceRegexEscapedCharacters(org.apache.nifi.record.path.TestRecordPath)  
Time elapsed: 0.007 s  <<< FAILURE!
    org.junit.ComparisonFailure:
    Replacing whitespace to new line expected:<John[
    ]Doe> but was:<John[ ]Doe>
            at 
org.apache.nifi.record.path.TestRecordPath.testReplaceRegexEscapedCharacters(TestRecordPath.java:1046)
    ```
    
    This test failed with original Lexer because `\[` is converted to `\\[` by 
Lexer and produced RegEx syntax error.
    ```
    [ERROR] 
testReplaceRegexEscapedBrackets(org.apache.nifi.record.path.TestRecordPath)  
Time elapsed: 0.001 s  <<< ERROR!
    org.apache.nifi.record.path.exception.RecordPathException:
    java.util.regex.PatternSyntaxException: Unclosed character class near index 
2
    \\[
      ^
            at 
org.apache.nifi.record.path.TestRecordPath.testReplaceRegexEscapedBrackets(TestRecordPath.java:1149)
    ```
    
    Both tests failed with the same cause, and fixed by this PR.


> UpdateRecord processor throwing PatternSyntaxException
> ------------------------------------------------------
>
>                 Key: NIFI-5826
>                 URL: https://issues.apache.org/jira/browse/NIFI-5826
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Core Framework
>    Affects Versions: 1.5.0, 1.6.0, 1.7.0, 1.8.0, 1.7.1
>         Environment: Nifi in docker container
>            Reporter: ravi kargam
>            Assignee: Ed Berezitsky
>            Priority: Minor
>         Attachments: NIFI-5826_PR-3183.patch, 
> UpdateRecord_Config_Exception.JPG
>
>
> with replacement value strategy as Record Path Value,
> I am trying to replace square bracket symbol *[* with parenthesis symbol *(* 
> in my employeeName column in my csvReader structure with below syntax
> replaceRegex(/employeeName, "[\[]", "(")
> Processor is throwing following exception.
> RecordPathException: java.util.regex.PatternSyntaxException: Unclosed 
> character class near index 4 [\\[]
> It worked fine with other special characters such as \{, }, <, >, ;, _, "
> For double qoute ("), i had to use single escape character, for above listed 
> other characters, worked fine without any escape character. Other folks in 
> Nifi Slack tried \s, \d, \w, \. 
> looks like non of them worked.
> replace function worked for replacing [ and ]characters. didn't test any 
> other characters.
> Please address resolve the issue.
> Regards,
> Ravi
>  
>  
>  



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

Reply via email to