From e4dc2a8ea862b81881453c7ef06e41e366a99ebf Mon Sep 17 00:00:00 2001 From: Teryk Bellahsene Date: Thu, 26 Feb 2015 18:01:30 +0100 Subject: [PATCH] fix connection leak --- .../org/sonar/server/computation/ComputationService.java | 2 +- .../org/sonar/server/properties/ProjectSettingsFactory.java | 5 ++--- .../computation/step/PurgeDatastoresStepMediumTest.java | 4 ++-- .../sonar/server/properties/ProjectSettingsFactoryTest.java | 3 +-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/ComputationService.java b/server/sonar-server/src/main/java/org/sonar/server/computation/ComputationService.java index 7d24da7e5f8..509f243f236 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/ComputationService.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/ComputationService.java @@ -61,7 +61,7 @@ public class ComputationService implements ServerComponent { ComponentDto project = loadProject(report); try { ComputationContext context = new ComputationContext(report, project); - context.setProjectSettings(projectSettingsFactory.newProjectSettings(dbClient.openSession(false), project.getId())); + context.setProjectSettings(projectSettingsFactory.newProjectSettings(project.getId())); for (ComputationStep step : steps.orderedSteps()) { if (ArrayUtils.contains(step.supportedProjectQualifiers(), context.getProject().qualifier())) { Profiler stepProfiler = Profiler.create(LOG).startInfo(step.getDescription()); diff --git a/server/sonar-server/src/main/java/org/sonar/server/properties/ProjectSettingsFactory.java b/server/sonar-server/src/main/java/org/sonar/server/properties/ProjectSettingsFactory.java index 3a9793e7fb9..e3b84813f30 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/properties/ProjectSettingsFactory.java +++ b/server/sonar-server/src/main/java/org/sonar/server/properties/ProjectSettingsFactory.java @@ -24,7 +24,6 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Maps; import org.sonar.api.ServerComponent; import org.sonar.api.config.Settings; -import org.sonar.core.persistence.DbSession; import org.sonar.core.properties.PropertiesDao; import org.sonar.core.properties.PropertyDto; @@ -41,8 +40,8 @@ public class ProjectSettingsFactory implements ServerComponent { this.settings = settings; } - public Settings newProjectSettings(DbSession session, long projectId) { - List propertyList = dao.selectProjectProperties(projectId, session); + public Settings newProjectSettings(long projectId) { + List propertyList = dao.selectProjectProperties(projectId); return new ProjectSettings(settings, getPropertyMap(propertyList)); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PurgeDatastoresStepMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PurgeDatastoresStepMediumTest.java index 0287a364966..5cdd7ecc269 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PurgeDatastoresStepMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PurgeDatastoresStepMediumTest.java @@ -98,7 +98,7 @@ public class PurgeDatastoresStepMediumTest { dbClient.propertiesDao().setProperty(new PropertyDto().setKey(DbCleanerConstants.WEEKS_BEFORE_DELETING_ALL_SNAPSHOTS).setValue("52")); dbSession.commit(); ComputationContext context = new ComputationContext(report, project); - context.setProjectSettings(new ProjectSettingsFactory(tester.get(Settings.class), tester.get(PropertiesDao.class)).newProjectSettings(dbSession, project.getId())); + context.setProjectSettings(new ProjectSettingsFactory(tester.get(Settings.class), tester.get(PropertiesDao.class)).newProjectSettings(project.getId())); // ACT sut.execute(context); @@ -137,7 +137,7 @@ public class PurgeDatastoresStepMediumTest { dbClient.propertiesDao().setProperty(new PropertyDto().setKey(DbCleanerConstants.WEEKS_BEFORE_DELETING_ALL_SNAPSHOTS).setValue("1").setResourceId(project.getId())); dbSession.commit(); ComputationContext context = new ComputationContext(report, project); - context.setProjectSettings(new ProjectSettingsFactory(tester.get(Settings.class), tester.get(PropertiesDao.class)).newProjectSettings(dbSession, project.getId())); + context.setProjectSettings(new ProjectSettingsFactory(tester.get(Settings.class), tester.get(PropertiesDao.class)).newProjectSettings(project.getId())); // ACT sut.execute(context); diff --git a/server/sonar-server/src/test/java/org/sonar/server/properties/ProjectSettingsFactoryTest.java b/server/sonar-server/src/test/java/org/sonar/server/properties/ProjectSettingsFactoryTest.java index d894cf48f65..1ca4a8cc6d6 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/properties/ProjectSettingsFactoryTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/properties/ProjectSettingsFactoryTest.java @@ -24,7 +24,6 @@ import com.google.common.collect.Lists; import org.junit.Before; import org.junit.Test; import org.sonar.api.config.Settings; -import org.sonar.core.persistence.DbSession; import org.sonar.core.properties.PropertiesDao; import org.sonar.core.properties.PropertyDto; @@ -50,7 +49,7 @@ public class ProjectSettingsFactoryTest { @Test public void newProjectSettings_returns_a_ProjectSettings() throws Exception { - Settings projectSettings = sut.newProjectSettings(mock(DbSession.class), 1L); + Settings projectSettings = sut.newProjectSettings(1L); assertThat(projectSettings).isInstanceOf(ProjectSettings.class); } -- 2.39.5