From 1a76c972e3524003ad2129779ab9222fc14c869b Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 25 Oct 2013 14:33:00 +0100 Subject: [PATCH] Always install new GrapeEngine Previously, GrapeEngineInstaller would only install its GrapeEngine if an engine had not already been installed. As the Grape class stores the engine in a static field, this meant that the engine would only be installed once for the lifetime of Grape's classloader. This caused an ordering issue in SampleIntegrationTests. The test for the integration sample clears the disableSpringSnapshotRepos system property to allow M1 of the integration DSL to be resolved. However, this property is only examined and honoured in AetherGrapeEngine's constructor. If another test had run and had already created and installed an AetherGrapeEngine, the new AetherGrapeEngine that allowed the use of snapshot repositories would not be installed and the test would fail. This commit updates GrapeEngineInstaller so that it always installs its GrapeEngine, overwriting any previously installed engine. --- .../boot/cli/compiler/GrapeEngineInstaller.java | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GrapeEngineInstaller.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GrapeEngineInstaller.java index f2c44db94e..f49da5ce27 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GrapeEngineInstaller.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GrapeEngineInstaller.java @@ -37,17 +37,7 @@ public class GrapeEngineInstaller { try { Field instanceField = Grape.class.getDeclaredField("instance"); instanceField.setAccessible(true); - - GrapeEngine existingGrapeEngine = (GrapeEngine) instanceField.get(null); - - if (existingGrapeEngine == null) { - instanceField.set(null, this.grapeEngine); - } - else if (!existingGrapeEngine.getClass().equals( - this.grapeEngine.getClass())) { - throw new IllegalStateException( - "Another GrapeEngine of a different type has already been initialized"); - } + instanceField.set(null, this.grapeEngine); } catch (Exception ex) { throw new IllegalStateException("Failed to install GrapeEngine", ex);