aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-07-10 18:17:03 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2014-07-10 18:30:22 +0200
commit6b764ab6b45278aedb15c330539129dbce82875a (patch)
tree4f797165a793cc7e460af2320218d243e8bb58a7
parent30bc2f00dca4af5e649117c2e50da65374526d5b (diff)
downloadsonarqube-6b764ab6b45278aedb15c330539129dbce82875a.tar.gz
sonarqube-6b764ab6b45278aedb15c330539129dbce82875a.zip
SONAR-5416 Fix LazyInitializationException
-rw-r--r--sonar-core/src/main/java/org/sonar/core/rule/CacheRuleFinder.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/rule/CacheRuleFinder.java b/sonar-core/src/main/java/org/sonar/core/rule/CacheRuleFinder.java
index 76a59f8ea80..4c93ba8f977 100644
--- a/sonar-core/src/main/java/org/sonar/core/rule/CacheRuleFinder.java
+++ b/sonar-core/src/main/java/org/sonar/core/rule/CacheRuleFinder.java
@@ -23,6 +23,7 @@ import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.Maps;
import org.apache.commons.lang.StringUtils;
+import org.hibernate.Hibernate;
import org.sonar.api.database.DatabaseSession;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rules.Rule;
@@ -32,6 +33,7 @@ import org.sonar.jpa.session.DatabaseSessionFactory;
import javax.annotation.CheckForNull;
import javax.persistence.Query;
+
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
@@ -72,6 +74,7 @@ public final class CacheRuleFinder implements RuleFinder {
rulesByKey.put(repositoryKey, repository);
for (Rule rule : findAll(RuleQuery.create().withRepositoryKey(repositoryKey))) {
+ hibernateHack(rule);
repository.put(rule.getKey(), rule);
rulesById.put(rule.getId(), rule);
}
@@ -79,6 +82,10 @@ public final class CacheRuleFinder implements RuleFinder {
return repository;
}
+ private void hibernateHack(Rule rule) {
+ Hibernate.initialize(rule.getParams());
+ }
+
protected final Rule doFindById(int ruleId) {
DatabaseSession session = sessionFactory.getSession();
return session.getSingleResult(
@@ -89,7 +96,6 @@ public final class CacheRuleFinder implements RuleFinder {
null);
}
-
@Override
@CheckForNull
public Rule findByKey(RuleKey key) {