diff --git a/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForProhibitedDependencies.java b/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForProhibitedDependencies.java index abc1098e8d3..2a3c36c19f7 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForProhibitedDependencies.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForProhibitedDependencies.java @@ -16,6 +16,7 @@ package org.springframework.boot.build.classpath; +import java.util.Set; import java.util.TreeSet; import java.util.stream.Collectors; @@ -35,6 +36,11 @@ import org.gradle.api.tasks.TaskAction; */ public class CheckClasspathForProhibitedDependencies extends DefaultTask { + private static final Set PROHIBITED_GROUPS = Set.of("org.codehaus.groovy", "org.eclipse.jetty.toolchain", + "commons-logging", "org.apache.geronimo.specs", "com.sun.activation"); + + private static final Set PERMITTED_JAVAX_GROUPS = Set.of("javax.batch", "javax.cache", "javax.money"); + private Configuration classpath; public CheckClasspathForProhibitedDependencies() { @@ -69,38 +75,20 @@ public class CheckClasspathForProhibitedDependencies extends DefaultTask { } private boolean prohibited(ModuleVersionIdentifier id) { - String group = id.getGroup(); - if (group.equals("javax.batch")) { - return false; - } - if (group.equals("javax.cache")) { - return false; - } - if (group.equals("javax.money")) { - return false; - } - if (group.equals("org.codehaus.groovy")) { - return true; - } - if (group.equals("org.eclipse.jetty.toolchain")) { - return true; - } - if (group.startsWith("javax")) { - return true; - } - if (group.equals("commons-logging")) { - return true; - } - if (group.equals("org.slf4j") && id.getName().equals("jcl-over-slf4j")) { - return true; - } - if (group.startsWith("org.jboss.spec")) { - return true; - } - if (group.equals("org.apache.geronimo.specs")) { - return true; - } - return group.equals("com.sun.activation"); + return PROHIBITED_GROUPS.contains(id.getGroup()) || prohibitedJavax(id) || prohibitedSlf4j(id) + || prohibitedJbossSpec(id); + } + + private boolean prohibitedSlf4j(ModuleVersionIdentifier id) { + return id.getGroup().equals("org.slf4j") && id.getName().equals("jcl-over-slf4j"); + } + + private boolean prohibitedJbossSpec(ModuleVersionIdentifier id) { + return id.getGroup().startsWith("org.jboss.spec"); + } + + private boolean prohibitedJavax(ModuleVersionIdentifier id) { + return id.getGroup().startsWith("javax.") && !PERMITTED_JAVAX_GROUPS.contains(id.getGroup()); } } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/test/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathExtensionForkParameterizedTests.java b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/test/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathExtensionForkParameterizedTests.java index 2a1bc4f47e5..c2ddf1b7708 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/test/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathExtensionForkParameterizedTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/test/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathExtensionForkParameterizedTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,14 +37,10 @@ class ModifiedClassPathExtensionForkParameterizedTests { @ParameterizedTest @ValueSource(strings = { "one", "two", "three" }) void testIsInvokedOnceForEachArgument(String argument) { - if (argument.equals("one")) { - assertThat(arguments).isEmpty(); - } - else if (argument.equals("two")) { - assertThat(arguments).doesNotContain("two", "three"); - } - else if (argument.equals("three")) { - assertThat(arguments).doesNotContain("three"); + switch (argument) { + case "one" -> assertThat(arguments).isEmpty(); + case "two" -> assertThat(arguments).doesNotContain("two", "three"); + case "three" -> assertThat(arguments).doesNotContain("three"); } arguments.add(argument); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystemProperties.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystemProperties.java index a39c8afbdb0..51a03bb308e 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystemProperties.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystemProperties.java @@ -219,7 +219,7 @@ public class LoggingSystemProperties { if (this.environment instanceof ConfigurableEnvironment configurableEnvironment) { PropertySourcesPropertyResolver resolver = new PropertySourcesPropertyResolver( configurableEnvironment.getPropertySources()); - resolver.setConversionService(((ConfigurableEnvironment) this.environment).getConversionService()); + resolver.setConversionService(configurableEnvironment.getConversionService()); resolver.setIgnoreUnresolvableNestedPlaceholders(true); return resolver; } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/NestedJarResourceSet.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/NestedJarResourceSet.java index 47a9f5b5711..6e6606c6a67 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/NestedJarResourceSet.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/NestedJarResourceSet.java @@ -128,7 +128,7 @@ class NestedJarResourceSet extends AbstractSingleArchiveResourceSet { } } } - return this.multiRelease.booleanValue(); + return this.multiRelease; } @Override