From dfd6f5d75aebd7a0a41305831ec6d194ae092f5d Mon Sep 17 00:00:00 2001 From: James Moger Date: Thu, 17 Apr 2014 22:20:32 -0400 Subject: [PATCH] [findbugs] Fix potential NPE in DiffStat generation --- src/main/java/com/gitblit/utils/DiffUtils.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gitblit/utils/DiffUtils.java b/src/main/java/com/gitblit/utils/DiffUtils.java index b49497e7..dd2a7807 100644 --- a/src/main/java/com/gitblit/utils/DiffUtils.java +++ b/src/main/java/com/gitblit/utils/DiffUtils.java @@ -363,19 +363,19 @@ public class DiffUtils { public static DiffStat getDiffStat(Repository repository, String base, String tip) { RevCommit baseCommit = null; RevCommit tipCommit = null; - RevWalk revWalk = null; + RevWalk revWalk = new RevWalk(repository); try { - revWalk = new RevWalk(repository); tipCommit = revWalk.parseCommit(repository.resolve(tip)); if (!StringUtils.isEmpty(base)) { baseCommit = revWalk.parseCommit(repository.resolve(base)); } + return getDiffStat(repository, baseCommit, tipCommit, null); } catch (Exception e) { LOGGER.error("failed to generate diffstat!", e); } finally { revWalk.dispose(); } - return getDiffStat(repository, baseCommit, tipCommit, null); + return null; } public static DiffStat getDiffStat(Repository repository, RevCommit commit) { -- 2.39.5