summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2014-04-15 09:28:25 -0400
committerJames Moger <james.moger@gitblit.com>2014-04-15 09:53:10 -0400
commitbd7db1070e07cf1777a0c0ee6e770625f8734fb6 (patch)
tree386550ec9a4c4c08ad916b0d1b2cc8669f1c231c /src
parent84f43536d5474f2077cf3b9a07b13b21ad853c3b (diff)
parent4868740ed7f40ce0cf162f17a8224856ae10a4b0 (diff)
downloadgitblit-bd7db1070e07cf1777a0c0ee6e770625f8734fb6.tar.gz
gitblit-bd7db1070e07cf1777a0c0ee6e770625f8734fb6.zip
Merge pr-170 'ticket-fix' from https://github.com/lucidd/gitblit
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/gitblit/tickets/ITicketService.java37
-rw-r--r--src/test/java/com/gitblit/tests/TicketServiceTest.java4
2 files changed, 24 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);
}
}
diff --git a/src/test/java/com/gitblit/tests/TicketServiceTest.java b/src/test/java/com/gitblit/tests/TicketServiceTest.java
index 5f94a46e..d91ce533 100644
--- a/src/test/java/com/gitblit/tests/TicketServiceTest.java
+++ b/src/test/java/com/gitblit/tests/TicketServiceTest.java
@@ -92,6 +92,10 @@ public abstract class TicketServiceTest extends GitblitUnitTest {
@Test
public void testLifecycle() throws Exception {
+ // query non-existent ticket
+ TicketModel nonExistent = service.getTicket(getRepository(), 0);
+ assertNull(nonExistent);
+
// create and insert a ticket
Change c1 = newChange("testCreation() " + Long.toHexString(System.currentTimeMillis()));
TicketModel ticket = service.createTicket(getRepository(), c1);