summaryrefslogtreecommitdiffstats
path: root/plugins/sonar-core-plugin
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2013-06-04 19:04:44 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2013-06-04 19:05:21 +0200
commitb3070fe1c1fc8c15cf8ba5e0433fec598572bdc4 (patch)
treec8fc47d90d1d8d034c07cad214fa2e70d55ba67d /plugins/sonar-core-plugin
parent01809e26ca0408b39a6153a57c5509e0df98350e (diff)
downloadsonarqube-b3070fe1c1fc8c15cf8ba5e0433fec598572bdc4.tar.gz
sonarqube-b3070fe1c1fc8c15cf8ba5e0433fec598572bdc4.zip
SONAR-4309 Support concurrent modifications on issues made by batch and simultaneously by user
Diffstat (limited to 'plugins/sonar-core-plugin')
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/InitialOpenIssuesSensor.java9
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTrackingDecorator.java1
2 files changed, 10 insertions, 0 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/InitialOpenIssuesSensor.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/InitialOpenIssuesSensor.java
index 9796c39293b..cff5ec73080 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/InitialOpenIssuesSensor.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/InitialOpenIssuesSensor.java
@@ -19,6 +19,7 @@
*/
package org.sonar.plugins.core.issue;
+import org.apache.commons.lang.time.DateUtils;
import org.apache.ibatis.session.ResultContext;
import org.apache.ibatis.session.ResultHandler;
import org.sonar.api.batch.Sensor;
@@ -27,6 +28,9 @@ import org.sonar.api.resources.Project;
import org.sonar.core.issue.db.IssueDao;
import org.sonar.core.issue.db.IssueDto;
+import java.util.Calendar;
+import java.util.Date;
+
/**
* Load all the issues referenced during the previous scan.
*/
@@ -47,10 +51,15 @@ public class InitialOpenIssuesSensor implements Sensor {
@Override
public void analyse(Project project, SensorContext context) {
+ // Adding one second is a hack for resolving conflicts with concurrent user
+ // changes during issue persistence
+ final Date now = DateUtils.addSeconds(DateUtils.truncate(new Date(), Calendar.MILLISECOND), 1);
+
issueDao.selectNonClosedIssuesByModule(project.getId(), new ResultHandler() {
@Override
public void handleResult(ResultContext rc) {
IssueDto dto = (IssueDto) rc.getResultObject();
+ dto.setSelectedAt(now);
initialOpenIssuesStack.addIssue(dto);
}
});
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTrackingDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTrackingDecorator.java
index 1728af0ffd3..539dd16224f 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTrackingDecorator.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTrackingDecorator.java
@@ -133,6 +133,7 @@ public class IssueTrackingDecorator implements Decorator {
issue.setNew(false);
issue.setEndOfLife(false);
issue.setOnDisabledRule(false);
+ issue.setSelectedAt(ref.getSelectedAt());
// fields to update with old values
issue.setActionPlanKey(ref.getActionPlanKey());