You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by ijokarumawak <gi...@git.apache.org> on 2018/12/07 07:04:42 UTC
[GitHub] nifi issue #3200: NIFI-5826 Fix back-slash escaping at Lexers
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.
---