]> source.dussan.org Git - gitblit.git/commitdiff
[findbugs] Fix potential NPE in DiffStat generation
authorJames Moger <james.moger@gitblit.com>
Fri, 18 Apr 2014 02:20:32 +0000 (22:20 -0400)
committerJames Moger <james.moger@gitblit.com>
Fri, 18 Apr 2014 03:08:07 +0000 (23:08 -0400)
src/main/java/com/gitblit/utils/DiffUtils.java

index b49497e7b6af1fff1e5aa0866ba1ef0d6ed35633..dd2a7807864045958db7bd485d321f33f2f56d09 100644 (file)
@@ -363,19 +363,19 @@ public class DiffUtils {
        public static DiffStat getDiffStat(Repository repository, String base, String tip) {\r
                RevCommit baseCommit = null;\r
                RevCommit tipCommit = null;\r
-               RevWalk revWalk = null;\r
+               RevWalk revWalk = new RevWalk(repository);\r
                try {\r
-                       revWalk = new RevWalk(repository);\r
                        tipCommit = revWalk.parseCommit(repository.resolve(tip));\r
                        if (!StringUtils.isEmpty(base)) {\r
                                baseCommit = revWalk.parseCommit(repository.resolve(base));\r
                        }\r
+                       return getDiffStat(repository, baseCommit, tipCommit, null);\r
                } catch (Exception e) {\r
                        LOGGER.error("failed to generate diffstat!", e);\r
                } finally {\r
                        revWalk.dispose();\r
                }\r
-               return getDiffStat(repository, baseCommit, tipCommit, null);\r
+               return null;\r
        }\r
 \r
        public static DiffStat getDiffStat(Repository repository, RevCommit commit) {\r