]> source.dussan.org Git - gitblit.git/commitdiff
Fix intermittent NPE in getting commit date in RefModel 40/40/1
authorJames Moger <james.moger@gitblit.com>
Tue, 8 Apr 2014 04:07:45 +0000 (00:07 -0400)
committerJames Moger <james.moger@gitblit.com>
Tue, 8 Apr 2014 04:07:45 +0000 (00:07 -0400)
releases.moxie
src/main/java/com/gitblit/models/RefModel.java

index ee125355c9736a34544168cb8ee289877f0e4d5e..34e64887478cb96c68cb3021f0edb8ef8e513f85 100644 (file)
@@ -11,6 +11,7 @@ r22: {
     security: ~
     fixes:
     - Repository mailing lists could not be reset from the Edit Repository page (issue-399)
+    - Fix intermittent NPE in determining commit date in RefModel (issue-401)
     - Fix closing ticket on push by parsing commit messages for closes|fixes (issue-404)
     - Ensure the Lucene ticket index is updated on repository deletion.
     changes:
index 6b031ed30b5cd8da8a86f4afa07c4e5ea6e0b7c0..02ba1302b3ba79eaeff60cea0266ff13ccf55713 100644 (file)
@@ -25,6 +25,8 @@ import org.eclipse.jgit.revwalk.RevCommit;
 import org.eclipse.jgit.revwalk.RevObject;\r
 import org.eclipse.jgit.revwalk.RevTag;\r
 \r
+import com.gitblit.utils.JGitUtils;\r
+\r
 /**\r
  * RefModel is a serializable model class that represents a tag or branch and\r
  * includes the referenced object.\r
@@ -50,11 +52,18 @@ public class RefModel implements Serializable, Comparable<RefModel> {
                if (referencedObject != null) {\r
                        if (referencedObject instanceof RevTag) {\r
                                RevTag tag = (RevTag) referencedObject;\r
-                               if (tag.getTaggerIdent() != null) {\r
-                                       date = tag.getTaggerIdent().getWhen();\r
+                               PersonIdent tagger = tag.getTaggerIdent();\r
+                               if (tagger != null) {\r
+                                       date = tagger.getWhen();\r
                                }\r
                        } else if (referencedObject instanceof RevCommit) {\r
-                               date = ((RevCommit) referencedObject).getCommitterIdent().getWhen();\r
+                               RevCommit commit = (RevCommit) referencedObject;\r
+                               PersonIdent committer = commit.getCommitterIdent();\r
+                               if (committer != null) {\r
+                                       date = committer.getWhen();\r
+                               } else {\r
+                                       date = JGitUtils.getCommitDate(commit);\r
+                               }\r
                        }\r
                }\r
                return date;\r