aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-09-24 16:02:35 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-09-24 16:02:35 +0000
commit51c728457cb0ea1763625d3600bddc2c3d7f049b (patch)
treeb5b29779f065bb57d4755a541db08879cb61bfc2 /sonar-plugin-api
parenta5ba257ffd83b0418f12c0dc1ba9542873f0d6e8 (diff)
downloadsonarqube-51c728457cb0ea1763625d3600bddc2c3d7f049b.tar.gz
sonarqube-51c728457cb0ea1763625d3600bddc2c3d7f049b.zip
SONAR-1711 add a lock on SensorContext/DecoratorContext in order to avoid creation of resources in methods saveViolation() and saveMeasure().
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractSourceImporter.java5
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/ResourceCreationLock.java38
2 files changed, 43 insertions, 0 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractSourceImporter.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractSourceImporter.java
index 662bfbad2e5..f32e3e951ff 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractSourceImporter.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractSourceImporter.java
@@ -70,6 +70,11 @@ public abstract class AbstractSourceImporter implements Sensor {
*/
public void analyse(Project project, SensorContext context) {
analyse(project.getFileSystem(), context);
+ onFinished();
+ }
+
+ protected void onFinished() {
+
}
protected void analyse(ProjectFileSystem fileSystem, SensorContext context) {
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/ResourceCreationLock.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/ResourceCreationLock.java
new file mode 100644
index 00000000000..12280f59237
--- /dev/null
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/ResourceCreationLock.java
@@ -0,0 +1,38 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.batch;
+
+import org.sonar.api.BatchComponent;
+
+/**
+ * This lock is used to ensure that Sonar resources (files, packages, directories) are not created by buggy plugins
+ * when saving measures/violations on unknown resources.
+ *
+ * @since 2.3
+ */
+public interface ResourceCreationLock extends BatchComponent {
+
+ /**
+ * Forbids the creation of resources when saving violations and measures. By default it's unlocked, so only warnings
+ * are logged. When locked, then an exception is thrown.
+ */
+ void lock();
+
+}