mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Merge branch '4.0.x'
Closes gh-50851
This commit is contained in:
+1
-1
@@ -233,7 +233,7 @@ public class StartMojo extends AbstractRunMojo {
|
||||
}
|
||||
|
||||
private boolean hasCauseWithType(Throwable t, Class<? extends Exception> type) {
|
||||
return type.isAssignableFrom(t.getClass()) || t.getCause() != null && hasCauseWithType(t.getCause(), type);
|
||||
return type.isInstance(t) || t.getCause() != null && hasCauseWithType(t.getCause(), type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -88,6 +88,18 @@
|
||||
value="Please use static AssertJ imports." />
|
||||
<property name="ignoreComments" value="true" />
|
||||
</module>
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck">
|
||||
<property name="maximum" value="0"/>
|
||||
<property name="format" value="\.isAssignableFrom\(.+\.getClass\(\)\)" />
|
||||
<property name="message" value="Please use type.isInstance(object) instead." />
|
||||
<property name="ignoreComments" value="true" />
|
||||
</module>
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck">
|
||||
<property name="maximum" value="0"/>
|
||||
<property name="format" value="\w+\.class\.isInstance\(.+\)" />
|
||||
<property name="message" value="Please use object instanceof type instead." />
|
||||
<property name="ignoreComments" value="true" />
|
||||
</module>
|
||||
<module name="io.spring.javaformat.checkstyle.check.SpringJavadocCheck">
|
||||
<property name="publicOnlySinceTags" value="true" />
|
||||
<property name="requireSinceTag" value="true" />
|
||||
|
||||
+4
-4
@@ -55,14 +55,14 @@ class ExpressionTree extends ReflectionWrapper {
|
||||
}
|
||||
|
||||
Object getLiteralValue() throws Exception {
|
||||
if (this.literalTreeType.isAssignableFrom(getInstance().getClass())) {
|
||||
if (this.literalTreeType.isInstance(getInstance())) {
|
||||
return this.literalValueMethod.invoke(getInstance());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Object getFactoryValue() throws Exception {
|
||||
if (this.methodInvocationTreeType.isAssignableFrom(getInstance().getClass())) {
|
||||
if (this.methodInvocationTreeType.isInstance(getInstance())) {
|
||||
List<?> arguments = (List<?>) this.methodInvocationArgumentsMethod.invoke(getInstance());
|
||||
if (arguments.size() == 1) {
|
||||
return new ExpressionTree(arguments.get(0)).getLiteralValue();
|
||||
@@ -72,7 +72,7 @@ class ExpressionTree extends ReflectionWrapper {
|
||||
}
|
||||
|
||||
Member getSelectedMember() throws Exception {
|
||||
if (this.memberSelectTreeType.isAssignableFrom(getInstance().getClass())) {
|
||||
if (this.memberSelectTreeType.isInstance(getInstance())) {
|
||||
String expression = this.memberSelectTreeExpressionMethod.invoke(getInstance()).toString();
|
||||
String identifier = this.memberSelectTreeIdentifierMethod.invoke(getInstance()).toString();
|
||||
if (expression != null && identifier != null) {
|
||||
@@ -83,7 +83,7 @@ class ExpressionTree extends ReflectionWrapper {
|
||||
}
|
||||
|
||||
List<? extends ExpressionTree> getArrayExpression() throws Exception {
|
||||
if (this.newArrayTreeType.isAssignableFrom(getInstance().getClass())) {
|
||||
if (this.newArrayTreeType.isInstance(getInstance())) {
|
||||
List<?> elements = (List<?>) this.arrayValueMethod.invoke(getInstance());
|
||||
List<ExpressionTree> result = new ArrayList<>();
|
||||
if (elements == null) {
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ public abstract class AbstractInjectionFailureAnalyzer<T extends Throwable> exte
|
||||
Throwable candidate = root;
|
||||
C result = null;
|
||||
while (candidate != null) {
|
||||
if (type.isAssignableFrom(candidate.getClass())) {
|
||||
if (type.isInstance(candidate)) {
|
||||
result = (C) candidate;
|
||||
}
|
||||
candidate = candidate.getCause();
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ public abstract class AbstractJsonParser implements JsonParser {
|
||||
return parser.call();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
if (check.isAssignableFrom(ex.getClass())) {
|
||||
if (check.isInstance(ex)) {
|
||||
throw new JsonParseException(ex);
|
||||
}
|
||||
ReflectionUtils.rethrowRuntimeException(ex);
|
||||
|
||||
+1
-1
@@ -337,7 +337,7 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext
|
||||
if (value == null || ClassUtils.isPrimitiveOrWrapper(value.getClass()) || value instanceof String) {
|
||||
return value;
|
||||
}
|
||||
if (CharSequence.class.isAssignableFrom(value.getClass())) {
|
||||
if (value instanceof CharSequence) {
|
||||
return value.toString();
|
||||
}
|
||||
return "Complex property value " + value.getClass().getName();
|
||||
|
||||
+2
-3
@@ -208,11 +208,10 @@ public class EnvironmentEndpoint {
|
||||
}
|
||||
|
||||
protected @Nullable Object stringifyIfNecessary(@Nullable Object value) {
|
||||
if (value == null || ClassUtils.isPrimitiveOrWrapper(value.getClass())
|
||||
|| Number.class.isAssignableFrom(value.getClass())) {
|
||||
if (value == null || ClassUtils.isPrimitiveOrWrapper(value.getClass()) || value instanceof Number) {
|
||||
return value;
|
||||
}
|
||||
if (CharSequence.class.isAssignableFrom(value.getClass())) {
|
||||
if (value instanceof CharSequence) {
|
||||
return value.toString();
|
||||
}
|
||||
return "Complex property type " + value.getClass().getName();
|
||||
|
||||
+1
-1
@@ -169,7 +169,7 @@ class CodecsAutoConfigurationTests {
|
||||
.filter((writer) -> writer instanceof EncoderHttpMessageWriter<?>)
|
||||
.map((writer) -> (EncoderHttpMessageWriter<?>) writer)
|
||||
.map(EncoderHttpMessageWriter::getEncoder)
|
||||
.filter((encoder) -> encoderClass.isAssignableFrom(encoder.getClass()))
|
||||
.filter(encoderClass::isInstance)
|
||||
.findFirst()
|
||||
.orElseThrow();
|
||||
}
|
||||
|
||||
+6
-11
@@ -465,18 +465,14 @@ class HttpMessageConvertersAutoConfigurationTests {
|
||||
|
||||
private void assertConverterIsRegistered(AssertableApplicationContext context,
|
||||
Class<? extends HttpMessageConverter<?>> converterType) {
|
||||
assertThat(getClientConverters(context)).filteredOn((c) -> converterType.isAssignableFrom(c.getClass()))
|
||||
.hasSize(1);
|
||||
assertThat(getServerConverters(context)).filteredOn((c) -> converterType.isAssignableFrom(c.getClass()))
|
||||
.hasSize(1);
|
||||
assertThat(getClientConverters(context)).filteredOn(converterType::isInstance).hasSize(1);
|
||||
assertThat(getServerConverters(context)).filteredOn(converterType::isInstance).hasSize(1);
|
||||
}
|
||||
|
||||
private void assertConverterIsNotRegistered(AssertableApplicationContext context,
|
||||
Class<? extends HttpMessageConverter<?>> converterType) {
|
||||
assertThat(getClientConverters(context)).filteredOn((c) -> converterType.isAssignableFrom(c.getClass()))
|
||||
.isEmpty();
|
||||
assertThat(getServerConverters(context)).filteredOn((c) -> converterType.isAssignableFrom(c.getClass()))
|
||||
.isEmpty();
|
||||
assertThat(getClientConverters(context)).filteredOn(converterType::isInstance).isEmpty();
|
||||
assertThat(getServerConverters(context)).filteredOn(converterType::isInstance).isEmpty();
|
||||
}
|
||||
|
||||
private void assertBeanExists(AssertableApplicationContext context, Class<?> type, String beanName) {
|
||||
@@ -504,7 +500,7 @@ class HttpMessageConvertersAutoConfigurationTests {
|
||||
private <T extends HttpMessageConverter<?>> T findConverter(HttpMessageConverters converters,
|
||||
Class<? extends HttpMessageConverter<?>> type) {
|
||||
for (HttpMessageConverter<?> converter : converters) {
|
||||
if (type.isAssignableFrom(converter.getClass())) {
|
||||
if (type.isInstance(converter)) {
|
||||
return (T) converter;
|
||||
}
|
||||
}
|
||||
@@ -589,8 +585,7 @@ class HttpMessageConvertersAutoConfigurationTests {
|
||||
|
||||
@Bean
|
||||
JacksonJsonHttpMessageConverter customJacksonMessageConverter(JsonMapper jsonMapperMapper) {
|
||||
JacksonJsonHttpMessageConverter converter = new JacksonJsonHttpMessageConverter(jsonMapperMapper);
|
||||
return converter;
|
||||
return new JacksonJsonHttpMessageConverter(jsonMapperMapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ abstract class JdbcConnectionDetailsBeanPostProcessor<T> implements BeanPostProc
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
if (this.dataSourceClass.isAssignableFrom(bean.getClass()) && "dataSource".equals(beanName)) {
|
||||
if (this.dataSourceClass.isInstance(bean) && "dataSource".equals(beanName)) {
|
||||
JdbcConnectionDetails connectionDetails = this.connectionDetailsProvider.getObject();
|
||||
if (!(connectionDetails instanceof PropertiesJdbcConnectionDetails)) {
|
||||
return processDataSource((T) bean, connectionDetails);
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ class TracingAndMeterObservationHandlerGroup implements ObservationHandlerGroup
|
||||
|
||||
@Override
|
||||
public boolean isMember(ObservationHandler<?> handler) {
|
||||
return MeterObservationHandler.class.isInstance(handler) || TracingObservationHandler.class.isInstance(handler);
|
||||
return handler instanceof MeterObservationHandler || handler instanceof TracingObservationHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -314,7 +314,7 @@ public class TomcatWebServerFactoryCustomizer
|
||||
Class<T> type, ObjIntConsumer<T> consumer) {
|
||||
factory.addConnectorCustomizers((connector) -> {
|
||||
ProtocolHandler handler = connector.getProtocolHandler();
|
||||
if (type.isAssignableFrom(handler.getClass())) {
|
||||
if (type.isInstance(handler)) {
|
||||
consumer.accept(type.cast(handler), value);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user