aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core/src
diff options
context:
space:
mode:
authorEvgeny Mandrikov <mandrikov@gmail.com>2011-04-08 11:47:45 +0400
committerEvgeny Mandrikov <mandrikov@gmail.com>2011-04-08 11:54:46 +0400
commit8ddcea7b859f2a15bd159ae047426f3947460197 (patch)
tree49de17f009ad410c0332e2258bcd25cc545af8f8 /sonar-core/src
parent7d231a67761c8c5637435d21a7e24364bb00fbe1 (diff)
downloadsonarqube-8ddcea7b859f2a15bd159ae047426f3947460197.tar.gz
sonarqube-8ddcea7b859f2a15bd159ae047426f3947460197.zip
JpaDatabaseSession: Don't log and throw NonUniqueResultException - just throw
Diffstat (limited to 'sonar-core/src')
-rw-r--r--sonar-core/src/main/java/org/sonar/jpa/session/JpaDatabaseSession.java12
1 files changed, 4 insertions, 8 deletions
diff --git a/sonar-core/src/main/java/org/sonar/jpa/session/JpaDatabaseSession.java b/sonar-core/src/main/java/org/sonar/jpa/session/JpaDatabaseSession.java
index 12c0f7c7a88..09fb4894c88 100644
--- a/sonar-core/src/main/java/org/sonar/jpa/session/JpaDatabaseSession.java
+++ b/sonar-core/src/main/java/org/sonar/jpa/session/JpaDatabaseSession.java
@@ -20,7 +20,6 @@
package org.sonar.jpa.session;
import org.apache.commons.lang.StringUtils;
-import org.slf4j.LoggerFactory;
import org.sonar.api.database.DatabaseSession;
import java.util.*;
@@ -207,13 +206,10 @@ public class JpaDatabaseSession extends DatabaseSession {
return getSingleResult(getQueryForCriterias(entityClass, true, criterias), (T) null);
} catch (NonUniqueResultException ex) {
- /*
- * TODO Log and throw is anti-pattern ( see http://today.java.net/article/2006/04/04/exception-handling-antipatterns#logAndThrow ),
- * but NonUniqueResultException doesn't have a constructor with cause
- */
- LoggerFactory.getLogger(JpaDatabaseSession.class).warn("NonUniqueResultException on entity {} with criterias : {}",
- entityClass.getSimpleName(), StringUtils.join(criterias, ","));
- throw ex;
+ NonUniqueResultException e = new NonUniqueResultException("Expected single result for entitiy " + entityClass.getSimpleName()
+ + " with criterias : " + StringUtils.join(criterias, ","));
+ e.initCause(ex);
+ throw e;
}
}