diff options
author | James Moger <james.moger@gitblit.com> | 2014-04-08 00:07:45 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2014-04-08 00:07:45 -0400 |
commit | 4263c2da123d241a7d0fe11e777b7bc80dae4af7 (patch) | |
tree | 598d73d3ae22a9128a8a7a292e940220af30767f /src/main/java/com/gitblit | |
parent | 6f54fd22f1495c3e532048bd256b5fa9cc41da82 (diff) | |
download | gitblit-4263c2da123d241a7d0fe11e777b7bc80dae4af7.tar.gz gitblit-4263c2da123d241a7d0fe11e777b7bc80dae4af7.zip |
Fix intermittent NPE in getting commit date in RefModel
Diffstat (limited to 'src/main/java/com/gitblit')
-rw-r--r-- | src/main/java/com/gitblit/models/RefModel.java | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/main/java/com/gitblit/models/RefModel.java b/src/main/java/com/gitblit/models/RefModel.java index 6b031ed3..02ba1302 100644 --- a/src/main/java/com/gitblit/models/RefModel.java +++ b/src/main/java/com/gitblit/models/RefModel.java @@ -25,6 +25,8 @@ import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevObject;
import org.eclipse.jgit.revwalk.RevTag;
+import com.gitblit.utils.JGitUtils;
+
/**
* RefModel is a serializable model class that represents a tag or branch and
* includes the referenced object.
@@ -50,11 +52,18 @@ public class RefModel implements Serializable, Comparable<RefModel> { if (referencedObject != null) {
if (referencedObject instanceof RevTag) {
RevTag tag = (RevTag) referencedObject;
- if (tag.getTaggerIdent() != null) {
- date = tag.getTaggerIdent().getWhen();
+ PersonIdent tagger = tag.getTaggerIdent();
+ if (tagger != null) {
+ date = tagger.getWhen();
}
} else if (referencedObject instanceof RevCommit) {
- date = ((RevCommit) referencedObject).getCommitterIdent().getWhen();
+ RevCommit commit = (RevCommit) referencedObject;
+ PersonIdent committer = commit.getCommitterIdent();
+ if (committer != null) {
+ date = committer.getWhen();
+ } else {
+ date = JGitUtils.getCommitDate(commit);
+ }
}
}
return date;
|