diff --git a/spring-boot-project/spring-boot-parent/build.gradle b/spring-boot-project/spring-boot-parent/build.gradle index 1482eeea8d..e0f264ad19 100644 --- a/spring-boot-project/spring-boot-parent/build.gradle +++ b/spring-boot-project/spring-boot-parent/build.gradle @@ -55,6 +55,13 @@ bom { ] } } + library("Janino", "3.1.8") { + group("org.codehaus.janino") { + imports = [ + "janino" + ] + } + } library("JLine", "2.11") { prohibit("[2.12,)") { because "it contains breaking changes" diff --git a/spring-boot-project/spring-boot/build.gradle b/spring-boot-project/spring-boot/build.gradle index 68c494dc41..9993334d2e 100644 --- a/spring-boot-project/spring-boot/build.gradle +++ b/spring-boot-project/spring-boot/build.gradle @@ -115,6 +115,7 @@ dependencies { testImplementation("org.apache.derby:derby") testImplementation("org.apache.derby:derbytools") testImplementation("org.awaitility:awaitility") + testImplementation("org.codehaus.janino:janino") testImplementation("org.eclipse.jetty:jetty-client") testImplementation("org.eclipse.jetty.http2:http2-client") testImplementation("org.eclipse.jetty.http2:http2-http-client-transport") diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/SpringBootJoranConfigurator.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/SpringBootJoranConfigurator.java index be1a949921..b2a82e5864 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/SpringBootJoranConfigurator.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/SpringBootJoranConfigurator.java @@ -84,13 +84,13 @@ class SpringBootJoranConfigurator extends JoranConfigurator { @Override protected void addModelHandlerAssociations(DefaultProcessor defaultProcessor) { - super.addModelHandlerAssociations(defaultProcessor); defaultProcessor.addHandler(SpringPropertyModel.class, (handlerContext, handlerMic) -> new SpringPropertyModelHandler(this.context, this.initializationContext.getEnvironment())); defaultProcessor.addHandler(SpringProfileModel.class, (handlerContext, handlerMic) -> new SpringProfileModelHandler(this.context, this.initializationContext.getEnvironment())); + super.addModelHandlerAssociations(defaultProcessor); } @Override diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/SpringBootJoranConfiguratorTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/SpringBootJoranConfiguratorTests.java index 20b06e6662..2dfb9fe3b5 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/SpringBootJoranConfiguratorTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/SpringBootJoranConfiguratorTests.java @@ -189,6 +189,20 @@ class SpringBootJoranConfiguratorTests { assertThat(this.context.getProperty("MINE")).isEqualTo("bar"); } + @Test + void springPropertyInIfWhenTrue() throws Exception { + TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.environment, "my.example-property=true"); + initialize("property-in-if.xml"); + assertThat(this.context.getProperty("MYCHECK")).isEqualTo("i-was-included"); + } + + @Test + void springPropertyInIfWhenFalse() throws Exception { + TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.environment, "my.example-property=false"); + initialize("property-in-if.xml"); + assertThat(this.context.getProperty("MYCHECK")).isNull(); + } + @Test void addsAotContributionToContextDuringAotProcessing() throws Exception { withSystemProperty("spring.aot.processing", "true", () -> { diff --git a/spring-boot-project/spring-boot/src/test/resources/org/springframework/boot/logging/logback/property-in-if.xml b/spring-boot-project/spring-boot/src/test/resources/org/springframework/boot/logging/logback/property-in-if.xml new file mode 100644 index 0000000000..b16fde51f3 --- /dev/null +++ b/spring-boot-project/spring-boot/src/test/resources/org/springframework/boot/logging/logback/property-in-if.xml @@ -0,0 +1,10 @@ + + + + + + + + + +