Skip to content
Permalink
Browse files
434: Adding a contributor without a full name gives a NPE
Reviewed-by: ehelin
  • Loading branch information
rwestberg committed Jun 30, 2020
1 parent 95d655d commit dbc85017a5391730baf2711fa6bdc9980841fcf4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
@@ -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();
}
@@ -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();
}
}

@@ -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");
}
}

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.