diff options
author | Kevin Walter <kevin.walter.private@googlemail.com> | 2014-04-15 02:00:42 +0200 |
---|---|---|
committer | Kevin Walter <kevin.walter.private@googlemail.com> | 2014-04-15 02:07:02 +0200 |
commit | 4868740ed7f40ce0cf162f17a8224856ae10a4b0 (patch) | |
tree | 9c0e0694aaef47ab06562753b5434b552baaacf3 /src/main/java/com/gitblit/tickets | |
parent | d3b1e34c7428fbe4ef3abeee9eaef0f885c3f19b (diff) | |
download | gitblit-4868740ed7f40ce0cf162f17a8224856ae10a4b0.tar.gz gitblit-4868740ed7f40ce0cf162f17a8224856ae10a4b0.zip |
fix NullPointerException in ITicketService and add TestCase
Diffstat (limited to 'src/main/java/com/gitblit/tickets')
-rw-r--r-- | src/main/java/com/gitblit/tickets/ITicketService.java | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/src/main/java/com/gitblit/tickets/ITicketService.java b/src/main/java/com/gitblit/tickets/ITicketService.java index 9522e420..7d699757 100644 --- a/src/main/java/com/gitblit/tickets/ITicketService.java +++ b/src/main/java/com/gitblit/tickets/ITicketService.java @@ -713,27 +713,30 @@ public abstract class ITicketService { public final TicketModel getTicket(RepositoryModel repository, long ticketId) { TicketKey key = new TicketKey(repository, ticketId); TicketModel ticket = ticketsCache.getIfPresent(key); - + + // if ticket not cached if (ticket == null) { - // load & cache ticket + //load ticket ticket = getTicketImpl(repository, ticketId); - if (ticket.hasPatchsets()) { - Repository r = repositoryManager.getRepository(repository.name); - try { - Patchset patchset = ticket.getCurrentPatchset(); - DiffStat diffStat = DiffUtils.getDiffStat(r, patchset.base, patchset.tip); - // diffstat could be null if we have ticket data without the - // commit objects. e.g. ticket replication without repo - // mirroring - if (diffStat != null) { - ticket.insertions = diffStat.getInsertions(); - ticket.deletions = diffStat.getDeletions(); + // if ticket exists + if (ticket != null) { + if (ticket.hasPatchsets()) { + Repository r = repositoryManager.getRepository(repository.name); + try { + Patchset patchset = ticket.getCurrentPatchset(); + DiffStat diffStat = DiffUtils.getDiffStat(r, patchset.base, patchset.tip); + // diffstat could be null if we have ticket data without the + // commit objects. e.g. ticket replication without repo + // mirroring + if (diffStat != null) { + ticket.insertions = diffStat.getInsertions(); + ticket.deletions = diffStat.getDeletions(); + } + } finally { + r.close(); } - } finally { - r.close(); } - } - if (ticket != null) { + //cache ticket ticketsCache.put(key, ticket); } } |