Skip to content

Commit

Permalink
434: Adding a contributor without a full name gives a NPE
Browse files Browse the repository at this point in the history
Reviewed-by: ehelin
  • Loading branch information
rwestberg committed Jun 30, 2020
1 parent 95d655d commit dbc8501
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Expand Up @@ -65,7 +65,12 @@ private Optional<EmailAddress> parseUser(String user, PullRequest pr, CensusInst
}
} else {
try {
return Optional.of(EmailAddress.parse(user));
var email = EmailAddress.parse(user);
if (email.fullName().isPresent()) {
return Optional.of(email);
} else {
return Optional.empty();
}
} catch (RuntimeException e) {
return Optional.empty();
}
Expand All @@ -74,7 +79,7 @@ private Optional<EmailAddress> parseUser(String user, PullRequest pr, CensusInst
if (contributor.fullName().isPresent()) {
return Optional.of(EmailAddress.from(contributor.fullName().get(), contributor.username() + "@openjdk.org"));
} else {
return Optional.of(EmailAddress.from(contributor.username() + "@openjdk.org"));
return Optional.empty();
}
}

Expand Down
Expand Up @@ -227,6 +227,11 @@ void invalidContributor(TestInfo testInfo) throws IOException {
pr.addComment("/contributor add someone");
TestBotRunner.runPeriodicItems(prBot);
assertLastCommentContains(pr, "Could not parse `someone` as a valid contributor");

// No full name
pr.addComment("/contributor add some@one");
TestBotRunner.runPeriodicItems(prBot);
assertLastCommentContains(pr, "Could not parse `some@one` as a valid contributor");
}
}

Expand Down

1 comment on commit dbc8501

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on dbc8501 Jun 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.