Skip to content

Commit c7e29b7

Browse files
committed
Polish
1 parent bfeeb6d commit c7e29b7

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/FilteringSpringBootCondition.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -132,7 +132,7 @@ public boolean matches(String className, ClassLoader classLoader) {
132132

133133
abstract boolean matches(String className, ClassLoader classLoader);
134134

135-
static boolean isPresent(String className, ClassLoader classLoader) {
135+
private static boolean isPresent(String className, ClassLoader classLoader) {
136136
if (classLoader == null) {
137137
classLoader = ClassUtils.getDefaultClassLoader();
138138
}

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnWebApplicationCondition.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -67,17 +67,18 @@ private ConditionOutcome getOutcome(String type) {
6767
return null;
6868
}
6969
ConditionMessage.Builder message = ConditionMessage.forCondition(ConditionalOnWebApplication.class);
70+
ClassNameFilter missingClassFilter = ClassNameFilter.MISSING;
7071
if (ConditionalOnWebApplication.Type.SERVLET.name().equals(type)) {
71-
if (!ClassNameFilter.isPresent(SERVLET_WEB_APPLICATION_CLASS, getBeanClassLoader())) {
72+
if (missingClassFilter.matches(SERVLET_WEB_APPLICATION_CLASS, getBeanClassLoader())) {
7273
return ConditionOutcome.noMatch(message.didNotFind("servlet web application classes").atAll());
7374
}
7475
}
7576
if (ConditionalOnWebApplication.Type.REACTIVE.name().equals(type)) {
76-
if (!ClassNameFilter.isPresent(REACTIVE_WEB_APPLICATION_CLASS, getBeanClassLoader())) {
77+
if (missingClassFilter.matches(REACTIVE_WEB_APPLICATION_CLASS, getBeanClassLoader())) {
7778
return ConditionOutcome.noMatch(message.didNotFind("reactive web application classes").atAll());
7879
}
7980
}
80-
if (!ClassNameFilter.isPresent(SERVLET_WEB_APPLICATION_CLASS, getBeanClassLoader())
81+
if (missingClassFilter.matches(SERVLET_WEB_APPLICATION_CLASS, getBeanClassLoader())
8182
&& !ClassUtils.isPresent(REACTIVE_WEB_APPLICATION_CLASS, getBeanClassLoader())) {
8283
return ConditionOutcome.noMatch(message.didNotFind("reactive or servlet web application classes").atAll());
8384
}
@@ -123,7 +124,7 @@ private ConditionOutcome isAnyWebApplication(ConditionContext context, boolean r
123124

124125
private ConditionOutcome isServletWebApplication(ConditionContext context) {
125126
ConditionMessage.Builder message = ConditionMessage.forCondition("");
126-
if (!ClassNameFilter.isPresent(SERVLET_WEB_APPLICATION_CLASS, context.getClassLoader())) {
127+
if (ClassNameFilter.MISSING.matches(SERVLET_WEB_APPLICATION_CLASS, context.getClassLoader())) {
127128
return ConditionOutcome.noMatch(message.didNotFind("servlet web application classes").atAll());
128129
}
129130
if (context.getBeanFactory() != null) {
@@ -143,7 +144,7 @@ private ConditionOutcome isServletWebApplication(ConditionContext context) {
143144

144145
private ConditionOutcome isReactiveWebApplication(ConditionContext context) {
145146
ConditionMessage.Builder message = ConditionMessage.forCondition("");
146-
if (!ClassNameFilter.isPresent(REACTIVE_WEB_APPLICATION_CLASS, context.getClassLoader())) {
147+
if (ClassNameFilter.MISSING.matches(REACTIVE_WEB_APPLICATION_CLASS, context.getClassLoader())) {
147148
return ConditionOutcome.noMatch(message.didNotFind("reactive web application classes").atAll());
148149
}
149150
if (context.getEnvironment() instanceof ConfigurableReactiveWebEnvironment) {

0 commit comments

Comments
 (0)