aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-db-dao/src/main/java/org/sonar/db/notification
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2017-02-23 22:49:29 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2017-02-25 18:38:06 +0100
commit2bb205d4b2acf725c86f35b379070d8398c0e4dd (patch)
tree6b06965859eb0892b63b660bb4f747adf5caa7b7 /server/sonar-db-dao/src/main/java/org/sonar/db/notification
parent7f4403beb69264d759d02a2610c18347f4c875fe (diff)
downloadsonarqube-2bb205d4b2acf725c86f35b379070d8398c0e4dd.tar.gz
sonarqube-2bb205d4b2acf725c86f35b379070d8398c0e4dd.zip
Replace DbClient#closeSession(DbSession) by try-with-resources
Diffstat (limited to 'server/sonar-db-dao/src/main/java/org/sonar/db/notification')
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/notification/NotificationQueueDao.java25
1 files changed, 6 insertions, 19 deletions
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/notification/NotificationQueueDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/notification/NotificationQueueDao.java
index be390291444..ab56cd0c704 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/notification/NotificationQueueDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/notification/NotificationQueueDao.java
@@ -21,7 +21,6 @@ package org.sonar.db.notification;
import java.util.Collections;
import java.util.List;
-import org.apache.ibatis.session.SqlSession;
import org.sonar.db.Dao;
import org.sonar.db.DbSession;
import org.sonar.db.MyBatis;
@@ -35,28 +34,22 @@ public class NotificationQueueDao implements Dao {
}
public void insert(List<NotificationQueueDto> dtos) {
- DbSession session = mybatis.openSession(true);
- NotificationQueueMapper mapper = session.getMapper(NotificationQueueMapper.class);
- try {
+ try (DbSession session = mybatis.openSession(true)) {
+ NotificationQueueMapper mapper = session.getMapper(NotificationQueueMapper.class);
for (NotificationQueueDto dto : dtos) {
mapper.insert(dto);
}
session.commit();
- } finally {
- MyBatis.closeQuietly(session);
}
}
public void delete(List<NotificationQueueDto> dtos) {
- DbSession session = mybatis.openSession(true);
- NotificationQueueMapper mapper = session.getMapper(NotificationQueueMapper.class);
- try {
+ try (DbSession session = mybatis.openSession(true)) {
+ NotificationQueueMapper mapper = session.getMapper(NotificationQueueMapper.class);
for (NotificationQueueDto dto : dtos) {
mapper.delete(dto.getId());
}
session.commit();
- } finally {
- MyBatis.closeQuietly(session);
}
}
@@ -64,20 +57,14 @@ public class NotificationQueueDao implements Dao {
if (count < 1) {
return Collections.emptyList();
}
- SqlSession session = mybatis.openSession(false);
- try {
+ try (DbSession session = mybatis.openSession(false)) {
return session.getMapper(NotificationQueueMapper.class).findOldest(count);
- } finally {
- MyBatis.closeQuietly(session);
}
}
public long count() {
- SqlSession session = mybatis.openSession(false);
- try {
+ try (DbSession session = mybatis.openSession(false)) {
return session.getMapper(NotificationQueueMapper.class).count();
- } finally {
- MyBatis.closeQuietly(session);
}
}
}