From 6c5a78202a340093aa44df95e8ceaa5daa59760d Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Vilain Date: Tue, 13 Aug 2013 11:36:56 +0200 Subject: [PATCH] SONAR-4525 Fixed regression on issue bulk change of plan --- .../org/sonar/server/issue/PlanAction.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/sonar-server/src/main/java/org/sonar/server/issue/PlanAction.java b/sonar-server/src/main/java/org/sonar/server/issue/PlanAction.java index 2ff701d364e..73f2b444627 100644 --- a/sonar-server/src/main/java/org/sonar/server/issue/PlanAction.java +++ b/sonar-server/src/main/java/org/sonar/server/issue/PlanAction.java @@ -40,8 +40,6 @@ public class PlanAction extends Action implements ServerComponent { private final ActionPlanService actionPlanService; private final IssueUpdater issueUpdater; - private ActionPlan actionPlan; - public PlanAction(ActionPlanService actionPlanService, IssueUpdater issueUpdater) { super(KEY); this.actionPlanService = actionPlanService; @@ -53,7 +51,7 @@ public class PlanAction extends Action implements ServerComponent { public boolean verify(Map properties, List issues, UserSession userSession) { String actionPlanValue = planValue(properties); if (!Strings.isNullOrEmpty(actionPlanValue)) { - ActionPlan actionPlan = getOrSelectActionPlan(actionPlanValue, userSession); + ActionPlan actionPlan = selectActionPlan(actionPlanValue, userSession); if (actionPlan == null) { throw new IllegalArgumentException("Unknown action plan: " + actionPlanValue); } @@ -64,8 +62,12 @@ public class PlanAction extends Action implements ServerComponent { @Override public boolean execute(Map properties, Context context) { - String actionPlan = planValue(properties); - return issueUpdater.plan((DefaultIssue) context.issue(), getOrSelectActionPlan(actionPlan, UserSession.get()), context.issueChangeContext()); + ActionPlan actionPlan = null; + String actionPlanValue = planValue(properties); + if (!Strings.isNullOrEmpty(actionPlanValue)) { + actionPlan = selectActionPlan(actionPlanValue, UserSession.get()); + } + return issueUpdater.plan((DefaultIssue) context.issue(), actionPlan, context.issueChangeContext()); } private String planValue(Map properties) { @@ -83,10 +85,7 @@ public class PlanAction extends Action implements ServerComponent { } } - private ActionPlan getOrSelectActionPlan(String planValue, UserSession userSession) { - if(actionPlan == null) { - actionPlan = actionPlanService.findByKey(planValue, userSession); - } - return actionPlan; + private ActionPlan selectActionPlan(String planValue, UserSession userSession) { + return actionPlanService.findByKey(planValue, userSession); } } \ No newline at end of file -- 2.39.5