Skip to content

Commit dbc8501

Browse files
committedJun 30, 2020
434: Adding a contributor without a full name gives a NPE
Reviewed-by: ehelin
1 parent 95d655d commit dbc8501

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed
 

‎bots/pr/src/main/java/org/openjdk/skara/bots/pr/ContributorCommand.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ private Optional<EmailAddress> parseUser(String user, PullRequest pr, CensusInst
6565
}
6666
} else {
6767
try {
68-
return Optional.of(EmailAddress.parse(user));
68+
var email = EmailAddress.parse(user);
69+
if (email.fullName().isPresent()) {
70+
return Optional.of(email);
71+
} else {
72+
return Optional.empty();
73+
}
6974
} catch (RuntimeException e) {
7075
return Optional.empty();
7176
}
@@ -74,7 +79,7 @@ private Optional<EmailAddress> parseUser(String user, PullRequest pr, CensusInst
7479
if (contributor.fullName().isPresent()) {
7580
return Optional.of(EmailAddress.from(contributor.fullName().get(), contributor.username() + "@openjdk.org"));
7681
} else {
77-
return Optional.of(EmailAddress.from(contributor.username() + "@openjdk.org"));
82+
return Optional.empty();
7883
}
7984
}
8085

‎bots/pr/src/test/java/org/openjdk/skara/bots/pr/ContributorTests.java

+5
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,11 @@ void invalidContributor(TestInfo testInfo) throws IOException {
227227
pr.addComment("/contributor add someone");
228228
TestBotRunner.runPeriodicItems(prBot);
229229
assertLastCommentContains(pr, "Could not parse `someone` as a valid contributor");
230+
231+
// No full name
232+
pr.addComment("/contributor add some@one");
233+
TestBotRunner.runPeriodicItems(prBot);
234+
assertLastCommentContains(pr, "Could not parse `some@one` as a valid contributor");
230235
}
231236
}
232237

1 commit comments

Comments
 (1)

bridgekeeper[bot] commented on Jun 30, 2020

@bridgekeeper[bot]
Please sign in to comment.