diff options
author | Stephane Gamard <stephane.gamard@searchbox.com> | 2014-05-02 20:00:38 +0200 |
---|---|---|
committer | Stephane Gamard <stephane.gamard@searchbox.com> | 2014-05-02 20:00:38 +0200 |
commit | dc35542f2609c0377dc2a634df1dbd9684427561 (patch) | |
tree | b84fb685dff84b0c7e431f9c51e13b509825cb4a | |
parent | 30f4a5b847331f41fb2b46d31561401cbecab943 (diff) | |
download | sonarqube-dc35542f2609c0377dc2a634df1dbd9684427561.tar.gz sonarqube-dc35542f2609c0377dc2a634df1dbd9684427561.zip |
Fixed RuleDao for Junits due to insert of Param with non-existing Rule
-rw-r--r-- | sonar-server/src/main/java/org/sonar/server/rule2/RuleDao.java | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/rule2/RuleDao.java b/sonar-server/src/main/java/org/sonar/server/rule2/RuleDao.java index 4dd69190e0a..aa924cd1e3f 100644 --- a/sonar-server/src/main/java/org/sonar/server/rule2/RuleDao.java +++ b/sonar-server/src/main/java/org/sonar/server/rule2/RuleDao.java @@ -237,9 +237,12 @@ public class RuleDao extends BaseDao<RuleDto, RuleKey> public void insert(RuleParamDto param, DbSession session) { getMapper(session).insertParameter(param); - session.enqueue(new EmbeddedIndexAction<RuleKey>(this.getIndexName(), - IndexAction.Method.INSERT, param, - this.selectById(param.getRuleId(), session).getKey())); + RuleDto dto = this.selectById(param.getRuleId(), session); + if(dto != null){ + session.enqueue(new EmbeddedIndexAction<RuleKey>(this.getIndexName(), + IndexAction.Method.INSERT, param, + dto.getKey())); + } } public void insert(RuleParamDto param) { @@ -254,9 +257,12 @@ public class RuleDao extends BaseDao<RuleDto, RuleKey> public void update(RuleParamDto param, DbSession session) { getMapper(session).updateParameter(param); - session.enqueue(new EmbeddedIndexAction<RuleKey>(this.getIndexName(), - IndexAction.Method.UPDATE, param, - this.selectById(param.getRuleId(), session).getKey())); + RuleDto dto = this.selectById(param.getRuleId(), session); + if(dto != null) { + session.enqueue(new EmbeddedIndexAction<RuleKey>(this.getIndexName(), + IndexAction.Method.UPDATE, param, + dto.getKey())); + } } public void update(RuleParamDto param) { |