See gh-42798
This commit is contained in:
Tran Ngoc Nhan 2024-10-19 20:03:02 +07:00 committed by Moritz Halbritter
parent b16b452131
commit fcbf6b0200
7 changed files with 8 additions and 8 deletions

View File

@ -59,8 +59,8 @@ public final class TransactionManagerCustomizers {
* @since 3.2.0
*/
public static TransactionManagerCustomizers of(Collection<? extends TransactionManagerCustomizer<?>> customizers) {
return new TransactionManagerCustomizers((customizers != null) ? new ArrayList<>(customizers)
: Collections.<TransactionManagerCustomizer<?>>emptyList());
return new TransactionManagerCustomizers(
(customizers != null) ? new ArrayList<>(customizers) : Collections.emptyList());
}
}

View File

@ -74,7 +74,7 @@ public interface DispatcherServletPath {
* @return the path as a servlet URL mapping
*/
default String getServletUrlMapping() {
if (getPath().equals("") || getPath().equals("/")) {
if (getPath().isEmpty() || getPath().equals("/")) {
return "/";
}
if (getPath().contains("*")) {

View File

@ -237,7 +237,7 @@ public class WebMvcProperties {
}
public String getServletMapping() {
if (this.path.equals("") || this.path.equals("/")) {
if (this.path.isEmpty() || this.path.equals("/")) {
return "/";
}
if (this.path.endsWith("/")) {

View File

@ -214,7 +214,7 @@ public class TestDatabaseAutoConfiguration {
List<ConfigurationProperty> bound = new ArrayList<>();
Binder.get(this.environment, new BoundPropertiesTrackingBindHandler(bound::add))
.bind(DATASOURCE_URL_PROPERTY, BINDABLE_STRING);
return (!bound.isEmpty()) ? isUsingTestDatasourceUrl(bound.get(0)) : false;
return !bound.isEmpty() && isUsingTestDatasourceUrl(bound.get(0));
}
private boolean isUsingTestDatasourceUrl(ConfigurationProperty configurationProperty) {

View File

@ -303,7 +303,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
boolean enabledByDefaultAttribute = (boolean) elementValues.getOrDefault("enableByDefault", true);
String defaultAccess = (!enabledByDefaultAttribute) ? "none"
: (elementValues.getOrDefault("defaultAccess", "unrestricted").toString()).toLowerCase(Locale.ENGLISH);
boolean enabledByDefault = "none".equals(defaultAccess) ? false : enabledByDefaultAttribute;
boolean enabledByDefault = !"none".equals(defaultAccess) && enabledByDefaultAttribute;
String type = this.metadataEnv.getTypeUtils().getQualifiedName(element);
this.metadataCollector.addIfAbsent(ItemMetadata.newGroup(endpointKey, type, type, null));
ItemMetadata accessProperty = ItemMetadata.newProperty(endpointKey, "access", endpointAccessEnum(), type, null,

View File

@ -48,7 +48,7 @@ class SpringEnvironmentPropertySource implements PropertySource {
@Override
public boolean containsProperty(String key) {
Environment environment = this.environment;
return (environment != null) ? environment.containsProperty(key) : false;
return environment != null && environment.containsProperty(key);
}
void setEnvironment(Environment environment) {

View File

@ -416,7 +416,7 @@ public class TomcatWebServer implements WebServer {
.map(TomcatEmbeddedContext.class::cast)
.filter(this::imperative)
.map(TomcatEmbeddedContext::getPath)
.map((path) -> path.equals("") ? "/" : path)
.map((path) -> path.isEmpty() ? "/" : path)
.collect(Collectors.joining(" "));
return StringUtils.hasText(contextPath) ? contextPath : null;
}