aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/xml/PmdRule.java2
-rw-r--r--sonar-core/src/main/java/org/sonar/jpa/session/CustomHibernateConnectionProvider.java10
-rw-r--r--sonar-core/src/main/java/org/sonar/jpa/session/DefaultDatabaseConnector.java2
-rw-r--r--sonar-graph/src/main/java/org/sonar/graph/FeedbackCycle.java5
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/measures/RuleMeasure.java6
5 files changed, 18 insertions, 7 deletions
diff --git a/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/xml/PmdRule.java b/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/xml/PmdRule.java
index 7cc292162ce..0df8d6f1a2d 100644
--- a/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/xml/PmdRule.java
+++ b/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/xml/PmdRule.java
@@ -22,7 +22,7 @@ package org.sonar.plugins.pmd.xml;
import java.util.ArrayList;
import java.util.List;
-public class PmdRule implements Comparable<String> {
+public class PmdRule {
private String ref;
diff --git a/sonar-core/src/main/java/org/sonar/jpa/session/CustomHibernateConnectionProvider.java b/sonar-core/src/main/java/org/sonar/jpa/session/CustomHibernateConnectionProvider.java
index 5f8490a3858..e6e36cc1587 100644
--- a/sonar-core/src/main/java/org/sonar/jpa/session/CustomHibernateConnectionProvider.java
+++ b/sonar-core/src/main/java/org/sonar/jpa/session/CustomHibernateConnectionProvider.java
@@ -26,11 +26,15 @@ import java.util.Properties;
public class CustomHibernateConnectionProvider extends InjectedDataSourceConnectionProvider {
- static DataSource datasource;
-
+ private static DataSource datasourceForConfig;
+
+ static void setDatasourceForConfig(DataSource ds) {
+ CustomHibernateConnectionProvider.datasourceForConfig = ds;
+ }
+
@Override
public void configure(Properties props) {
- setDataSource(datasource);
+ setDataSource(datasourceForConfig);
super.configure(props);
}
}
diff --git a/sonar-core/src/main/java/org/sonar/jpa/session/DefaultDatabaseConnector.java b/sonar-core/src/main/java/org/sonar/jpa/session/DefaultDatabaseConnector.java
index cf1e4b83210..b1bed908691 100644
--- a/sonar-core/src/main/java/org/sonar/jpa/session/DefaultDatabaseConnector.java
+++ b/sonar-core/src/main/java/org/sonar/jpa/session/DefaultDatabaseConnector.java
@@ -54,7 +54,7 @@ public class DefaultDatabaseConnector extends AbstractDatabaseConnector {
private void createDatasource() {
try {
- CustomHibernateConnectionProvider.datasource = database.getDataSource();
+ CustomHibernateConnectionProvider.setDatasourceForConfig(database.getDataSource());
} catch (Exception e) {
throw new SonarException("Fail to connect to database", e);
}
diff --git a/sonar-graph/src/main/java/org/sonar/graph/FeedbackCycle.java b/sonar-graph/src/main/java/org/sonar/graph/FeedbackCycle.java
index a23cb74c9f0..5c202597db6 100644
--- a/sonar-graph/src/main/java/org/sonar/graph/FeedbackCycle.java
+++ b/sonar-graph/src/main/java/org/sonar/graph/FeedbackCycle.java
@@ -29,6 +29,9 @@ import java.util.Set;
import com.google.common.collect.HashMultiset;
import com.google.common.collect.Multiset;
+/**
+ * Note: this class has a natural ordering that is inconsistent with equals
+ */
public final class FeedbackCycle implements Iterable<FeedbackEdge>, Comparable<FeedbackCycle> {
private List<FeedbackEdge> orderedFeedbackEdges;
@@ -89,7 +92,7 @@ public final class FeedbackCycle implements Iterable<FeedbackEdge>, Comparable<F
}
public int compareTo(FeedbackCycle feedbackCycle) {
- if (getTotalOccurrencesOfEdgesInCycle() < feedbackCycle.getTotalOccurrencesOfEdgesInCycle()) {
+ if (getTotalOccurrencesOfEdgesInCycle() < feedbackCycle.getTotalOccurrencesOfEdgesInCycle()) {//NOSONAR this class has a natural ordering that is inconsistent with equals
return -1;
}
if (getTotalOccurrencesOfEdgesInCycle() == feedbackCycle.getTotalOccurrencesOfEdgesInCycle()) {
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/RuleMeasure.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/RuleMeasure.java
index c3ca678e7e2..99b9ebac7e9 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/RuleMeasure.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/RuleMeasure.java
@@ -76,7 +76,11 @@ public class RuleMeasure extends Measure {
@Override
public boolean equals(Object obj) {
- if (!(obj.getClass().equals(RuleMeasure.class))) {
+ if (obj == null) {
+ return false;
+ }
+ if (!(obj.getClass().equals(RuleMeasure.class))) {//NOSONAR should be refactored but kept in the current state
+ // for the moment.
return false;
}
if (this == obj) {