summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/gitblit/tickets
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2014-09-04 14:59:05 -0400
committerJames Moger <james.moger@gitblit.com>2014-09-04 14:59:05 -0400
commit270e9e762820833d6815e362034dc3f4809b6470 (patch)
treefdcf985b8d276c88786db5513b95b58a7c71bfbd /src/main/java/com/gitblit/tickets
parent624a7215a635630508d12b80508e0df708632066 (diff)
downloadgitblit-270e9e762820833d6815e362034dc3f4809b6470.tar.gz
gitblit-270e9e762820833d6815e362034dc3f4809b6470.zip
Fix NPEs when handling referenced milestones that do not exist
Diffstat (limited to 'src/main/java/com/gitblit/tickets')
-rw-r--r--src/main/java/com/gitblit/tickets/ITicketService.java18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/main/java/com/gitblit/tickets/ITicketService.java b/src/main/java/com/gitblit/tickets/ITicketService.java
index 668d0bcc..4cf099ff 100644
--- a/src/main/java/com/gitblit/tickets/ITicketService.java
+++ b/src/main/java/com/gitblit/tickets/ITicketService.java
@@ -670,21 +670,24 @@ public abstract class ITicketService {
Repository db = null;
try {
db = repositoryManager.getRepository(repository.name);
- TicketMilestone milestone = getMilestone(repository, oldName);
+ TicketMilestone tm = getMilestone(repository, oldName);
+ if (tm == null) {
+ return false;
+ }
StoredConfig config = db.getConfig();
config.unsetSection(MILESTONE, oldName);
- config.setString(MILESTONE, newName, STATUS, milestone.status.name());
- config.setString(MILESTONE, newName, COLOR, milestone.color);
- if (milestone.due != null) {
+ config.setString(MILESTONE, newName, STATUS, tm.status.name());
+ config.setString(MILESTONE, newName, COLOR, tm.color);
+ if (tm.due != null) {
config.setString(MILESTONE, newName, DUE,
- new SimpleDateFormat(DUE_DATE_PATTERN).format(milestone.due));
+ new SimpleDateFormat(DUE_DATE_PATTERN).format(tm.due));
}
config.save();
milestonesCache.remove(repository.name);
TicketNotifier notifier = createNotifier();
- for (QueryResult qr : milestone.tickets) {
+ for (QueryResult qr : tm.tickets) {
Change change = new Change(createdBy);
change.setField(Field.milestone, newName);
TicketModel ticket = updateTicket(repository, qr.number, change);
@@ -738,6 +741,9 @@ public abstract class ITicketService {
Repository db = null;
try {
TicketMilestone tm = getMilestone(repository, milestone);
+ if (tm == null) {
+ return false;
+ }
db = repositoryManager.getRepository(repository.name);
StoredConfig config = db.getConfig();
config.unsetSection(MILESTONE, milestone);