mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Merge pull request #40985 from asashour
* pr/40985: Prevent unnecessary unboxing Remove redundant cast Polish "Use 'switch' instead of 'if'" Use 'switch' instead of 'if' Closes gh-40985
This commit is contained in:
commit
ef99ce0ba9
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.springframework.boot.build.classpath;
|
package org.springframework.boot.build.classpath;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -35,6 +36,11 @@ import org.gradle.api.tasks.TaskAction;
|
|||||||
*/
|
*/
|
||||||
public class CheckClasspathForProhibitedDependencies extends DefaultTask {
|
public class CheckClasspathForProhibitedDependencies extends DefaultTask {
|
||||||
|
|
||||||
|
private static final Set<String> PROHIBITED_GROUPS = Set.of("org.codehaus.groovy", "org.eclipse.jetty.toolchain",
|
||||||
|
"commons-logging", "org.apache.geronimo.specs", "com.sun.activation");
|
||||||
|
|
||||||
|
private static final Set<String> PERMITTED_JAVAX_GROUPS = Set.of("javax.batch", "javax.cache", "javax.money");
|
||||||
|
|
||||||
private Configuration classpath;
|
private Configuration classpath;
|
||||||
|
|
||||||
public CheckClasspathForProhibitedDependencies() {
|
public CheckClasspathForProhibitedDependencies() {
|
||||||
@ -69,41 +75,20 @@ public class CheckClasspathForProhibitedDependencies extends DefaultTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean prohibited(ModuleVersionIdentifier id) {
|
private boolean prohibited(ModuleVersionIdentifier id) {
|
||||||
String group = id.getGroup();
|
return PROHIBITED_GROUPS.contains(id.getGroup()) || prohibitedJavax(id) || prohibitedSlf4j(id)
|
||||||
if (group.equals("javax.batch")) {
|
|| prohibitedJbossSpec(id);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (group.equals("javax.cache")) {
|
|
||||||
return false;
|
private boolean prohibitedSlf4j(ModuleVersionIdentifier id) {
|
||||||
|
return id.getGroup().equals("org.slf4j") && id.getName().equals("jcl-over-slf4j");
|
||||||
}
|
}
|
||||||
if (group.equals("javax.money")) {
|
|
||||||
return false;
|
private boolean prohibitedJbossSpec(ModuleVersionIdentifier id) {
|
||||||
|
return id.getGroup().startsWith("org.jboss.spec");
|
||||||
}
|
}
|
||||||
if (group.equals("org.codehaus.groovy")) {
|
|
||||||
return true;
|
private boolean prohibitedJavax(ModuleVersionIdentifier id) {
|
||||||
}
|
return id.getGroup().startsWith("javax.") && !PERMITTED_JAVAX_GROUPS.contains(id.getGroup());
|
||||||
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;
|
|
||||||
}
|
|
||||||
if (group.equals("com.sun.activation")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -37,14 +37,10 @@ class ModifiedClassPathExtensionForkParameterizedTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(strings = { "one", "two", "three" })
|
@ValueSource(strings = { "one", "two", "three" })
|
||||||
void testIsInvokedOnceForEachArgument(String argument) {
|
void testIsInvokedOnceForEachArgument(String argument) {
|
||||||
if (argument.equals("one")) {
|
switch (argument) {
|
||||||
assertThat(arguments).isEmpty();
|
case "one" -> assertThat(arguments).isEmpty();
|
||||||
}
|
case "two" -> assertThat(arguments).doesNotContain("two", "three");
|
||||||
else if (argument.equals("two")) {
|
case "three" -> assertThat(arguments).doesNotContain("three");
|
||||||
assertThat(arguments).doesNotContain("two", "three");
|
|
||||||
}
|
|
||||||
else if (argument.equals("three")) {
|
|
||||||
assertThat(arguments).doesNotContain("three");
|
|
||||||
}
|
}
|
||||||
arguments.add(argument);
|
arguments.add(argument);
|
||||||
}
|
}
|
||||||
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -219,7 +219,7 @@ public class LoggingSystemProperties {
|
|||||||
if (this.environment instanceof ConfigurableEnvironment configurableEnvironment) {
|
if (this.environment instanceof ConfigurableEnvironment configurableEnvironment) {
|
||||||
PropertySourcesPropertyResolver resolver = new PropertySourcesPropertyResolver(
|
PropertySourcesPropertyResolver resolver = new PropertySourcesPropertyResolver(
|
||||||
configurableEnvironment.getPropertySources());
|
configurableEnvironment.getPropertySources());
|
||||||
resolver.setConversionService(((ConfigurableEnvironment) this.environment).getConversionService());
|
resolver.setConversionService(configurableEnvironment.getConversionService());
|
||||||
resolver.setIgnoreUnresolvableNestedPlaceholders(true);
|
resolver.setIgnoreUnresolvableNestedPlaceholders(true);
|
||||||
return resolver;
|
return resolver;
|
||||||
}
|
}
|
||||||
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -128,7 +128,7 @@ class NestedJarResourceSet extends AbstractSingleArchiveResourceSet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.multiRelease.booleanValue();
|
return this.multiRelease;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user