diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2012-12-12 15:27:05 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2012-12-12 15:27:23 +0100 |
commit | 31784eb3bfc2e9e320e96c0c3ef0e3f3abcd0880 (patch) | |
tree | 7058872e4500e814317d5a5811fd9e3871b86a8c /sonar-batch | |
parent | abadc6eed3365966b36874c64a445a05d94b2e77 (diff) | |
download | sonarqube-31784eb3bfc2e9e320e96c0c3ef0e3f3abcd0880.tar.gz sonarqube-31784eb3bfc2e9e320e96c0c3ef0e3f3abcd0880.zip |
SONAR-3887 release lock when plugin license is not valid
Diffstat (limited to 'sonar-batch')
5 files changed, 25 insertions, 16 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/Batch.java b/sonar-batch/src/main/java/org/sonar/batch/Batch.java index 90ce02e881e..4e56e1f36b6 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/Batch.java +++ b/sonar-batch/src/main/java/org/sonar/batch/Batch.java @@ -38,7 +38,8 @@ public final class Batch { private Module bootstrapModule; public Batch(ProjectReactor reactor, Object... bootstrapperComponents) { - this.bootstrapModule = new BootstrapModule(reactor, bootstrapperComponents).init(); + this.bootstrapModule = new BootstrapModule(reactor, bootstrapperComponents); + this.bootstrapModule.init(); } /** @@ -47,7 +48,8 @@ public final class Batch { @Deprecated public Batch(Configuration configuration, Object... bootstrapperComponents) {//NOSONAR configuration is not needed // because it's already included in ProjectDefinition. - this.bootstrapModule = new BootstrapModule(extractProjectReactor(bootstrapperComponents), bootstrapperComponents).init(); + this.bootstrapModule = new BootstrapModule(extractProjectReactor(bootstrapperComponents), bootstrapperComponents); + this.bootstrapModule.init(); } static ProjectReactor extractProjectReactor(Object[] components) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchModule.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchModule.java index 3067a161cda..94448f6f16f 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchModule.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchModule.java @@ -141,11 +141,12 @@ public class BatchModule extends Module { analyze(subProject); } - Module projectComponents = installChild(new ProjectModule(project)); + ProjectModule projectModule = new ProjectModule(project); try { - projectComponents.start(); + installChild(projectModule); + projectModule.start(); } finally { - projectComponents.stop(); + projectModule.stop(); uninstallChild(); } } diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/Module.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/Module.java index fcafd4856a8..80567137eff 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/Module.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/Module.java @@ -33,17 +33,16 @@ public abstract class Module { /** * @return this */ - public final Module init() { - return init(new ComponentContainer()); + public final void init() { + init(new ComponentContainer()); } /** * @return this */ - private Module init(ComponentContainer container) { + private void init(ComponentContainer container) { this.container = container; configure(); - return this; } /** diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java index c670d4439ec..0970bd5bc55 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java @@ -70,7 +70,8 @@ public final class Batch { private void startBatch() { Module bootstrapModule = null; try { - bootstrapModule = new BootstrapModule(projectReactor, components.toArray(new Object[components.size()])).init(); + bootstrapModule = new BootstrapModule(projectReactor, components.toArray(new Object[components.size()])); + bootstrapModule.init(); bootstrapModule.start(); } catch (RuntimeException e) { PicoUtils.propagateStartupException(e); diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/ModuleTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/ModuleTest.java index 4a5b8361c45..67b8921f685 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/ModuleTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/ModuleTest.java @@ -32,7 +32,8 @@ public class ModuleTest { @Test public void shouldInitModule() { - Module module = new FakeModule(FakeService.class).init(); + Module module = new FakeModule(FakeService.class); + module.init(); FakeService service = module.container.getComponentByType(FakeService.class); assertThat(service, not(nullValue())); @@ -42,7 +43,8 @@ public class ModuleTest { @Test public void shouldStartAndStopModule() { - Module module = new FakeModule(FakeService.class).init(); + Module module = new FakeModule(FakeService.class); + module.init(); module.start(); FakeService service = module.container.getComponentByType(FakeService.class); @@ -54,27 +56,31 @@ public class ModuleTest { @Test(expected = RuntimeException.class) public void shouldNotIgnoreStartFailures() { - Module module = new FakeModule(NonStartableService.class).init(); + Module module = new FakeModule(NonStartableService.class); + module.init(); module.start(); } @Test public void shouldIgnoreStopFailures() { - Module module = new FakeModule(NonStoppableService.class).init(); + Module module = new FakeModule(NonStoppableService.class); + module.init(); module.start(); module.stop(); // no exception is raised } @Test public void componentsShouldBeSingletons() { - Module module = new FakeModule(FakeService.class).init(); + Module module = new FakeModule(FakeService.class); + module.init(); assertThat(module.container.getComponentByType(FakeService.class) == module.container.getComponentByType(FakeService.class), is(true)); } @Test public void shouldInstallChildModule() { - Module parent = new FakeModule(FakeService.class).init(); + Module parent = new FakeModule(FakeService.class); + parent.init(); parent.start(); Module child = parent.installChild(new FakeModule(ChildService.class)); |