Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE on RegexRowRule when a row field is empty #24

Open
michelemilesi opened this issue Apr 11, 2018 · 0 comments
Open

NPE on RegexRowRule when a row field is empty #24

michelemilesi opened this issue Apr 11, 2018 · 0 comments

Comments

@michelemilesi
Copy link

Regex rule fails with an NPE if a row contains an empty field and the field must be checked.

18/04/11 17:57:52 WARN scheduler.TaskSetManager: Lost task 1.0 in stage 1.0 (TID 3, ****.****.**, executor 4): java.lang.NullPointerException
        at java.util.regex.Matcher.getTextLength(Matcher.java:1283)
        at java.util.regex.Matcher.reset(Matcher.java:309)
        at java.util.regex.Matcher.<init>(Matcher.java:229)
        at java.util.regex.Pattern.matcher(Pattern.java:1093)
        at com.cloudera.labs.envelope.derive.dq.RegexRowRule.check(RegexRowRule.java:55)

The class com.cloudera.labs.envelope.derive.dq.RegexRowRule need a null check in the method check(Row row): boolean:

  @Override
  public boolean check(Row row) {
    boolean check = true;
    for (String field : fields) {
      String value = row.getAs(field);
      Matcher matcher = pattern.matcher(value);
      check = check && matcher.matches();
      if (!check) {
        // No point continuing if failed
        break;
      }
    }
    return check;
  }
michelemilesi added a commit to icteam-spa/envelope that referenced this issue Apr 11, 2018
Fixed the issue cloudera-labs#24 "NPE on RegexRowRule when a row field is empty"
adding a null check and test case
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant