Skip to content

Commit c3f6dff

Browse files
https://github.com/jenkinsci/pipeline-github-plugin/issues/46
CommitGroovyObject.java - added protections against the committer and author being null in a RepositoryCommit instance, this shouldn't be possible..
1 parent 1419327 commit c3f6dff

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/main/java/org/jenkinsci/plugins/pipeline/github/CommitGroovyObject.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.eclipse.egit.github.core.CommitStatus;
77
import org.eclipse.egit.github.core.RepositoryCommit;
88
import org.eclipse.egit.github.core.RepositoryId;
9+
import org.eclipse.egit.github.core.User;
910
import org.jenkinsci.plugins.pipeline.github.client.ExtendedCommitComment;
1011
import org.jenkinsci.plugins.pipeline.github.client.ExtendedCommitService;
1112
import org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.Whitelisted;
@@ -16,6 +17,7 @@
1617
import java.util.Collection;
1718
import java.util.Map;
1819
import java.util.Objects;
20+
import java.util.Optional;
1921
import java.util.stream.Stream;
2022
import java.util.stream.StreamSupport;
2123

@@ -68,12 +70,16 @@ public String getUrl() {
6870

6971
@Whitelisted
7072
public String getAuthor() {
71-
return commit.getAuthor().getLogin();
73+
return Optional.ofNullable(commit.getAuthor())
74+
.map(User::getLogin)
75+
.orElse(null);
7276
}
7377

7478
@Whitelisted
7579
public String getCommitter() {
76-
return commit.getCommitter().getLogin();
80+
return Optional.ofNullable(commit.getCommitter())
81+
.map(User::getLogin)
82+
.orElse(null);
7783
}
7884

7985
@Whitelisted

0 commit comments

Comments
 (0)