Nullability refinements and related polishing
This commit is contained in:
parent
99a1388bbd
commit
df977a2fd2
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2018 the original author or authors.
|
* Copyright 2002-2021 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.
|
||||||
|
@ -41,10 +41,10 @@ public class TypeMismatchException extends PropertyAccessException {
|
||||||
private String propertyName;
|
private String propertyName;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private transient Object value;
|
private final transient Object value;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private Class<?> requiredType;
|
private final Class<?> requiredType;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -294,7 +294,7 @@ public class LocalValidatorFactoryBean extends SpringValidatorAdapter
|
||||||
}
|
}
|
||||||
List<InputStream> mappingStreams = null;
|
List<InputStream> mappingStreams = null;
|
||||||
if (this.mappingLocations != null) {
|
if (this.mappingLocations != null) {
|
||||||
mappingStreams = new ArrayList<>(mappingLocations.length);
|
mappingStreams = new ArrayList<>(this.mappingLocations.length);
|
||||||
for (Resource location : this.mappingLocations) {
|
for (Resource location : this.mappingLocations) {
|
||||||
try {
|
try {
|
||||||
InputStream stream = location.getInputStream();
|
InputStream stream = location.getInputStream();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2019 the original author or authors.
|
* Copyright 2002-2021 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.
|
||||||
|
@ -40,7 +40,7 @@ public class EnableLoadTimeWeavingTests {
|
||||||
@Test
|
@Test
|
||||||
public void control() {
|
public void control() {
|
||||||
GenericXmlApplicationContext ctx =
|
GenericXmlApplicationContext ctx =
|
||||||
new GenericXmlApplicationContext(getClass(), "EnableLoadTimeWeavingTests-context.xml");
|
new GenericXmlApplicationContext(getClass(), "EnableLoadTimeWeavingTests-context.xml");
|
||||||
ctx.getBean("loadTimeWeaver", LoadTimeWeaver.class);
|
ctx.getBean("loadTimeWeaver", LoadTimeWeaver.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,9 +73,11 @@ public class EnableLoadTimeWeavingTests {
|
||||||
verify(loadTimeWeaver).addTransformer(isA(ClassFileTransformer.class));
|
verify(loadTimeWeaver).addTransformer(isA(ClassFileTransformer.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableLoadTimeWeaving(aspectjWeaving=AspectJWeaving.DISABLED)
|
@EnableLoadTimeWeaving(aspectjWeaving=AspectJWeaving.DISABLED)
|
||||||
static class EnableLTWConfig_withAjWeavingDisabled implements LoadTimeWeavingConfigurer {
|
static class EnableLTWConfig_withAjWeavingDisabled implements LoadTimeWeavingConfigurer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LoadTimeWeaver getLoadTimeWeaver() {
|
public LoadTimeWeaver getLoadTimeWeaver() {
|
||||||
return mock(LoadTimeWeaver.class);
|
return mock(LoadTimeWeaver.class);
|
||||||
|
@ -85,6 +87,7 @@ public class EnableLoadTimeWeavingTests {
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableLoadTimeWeaving(aspectjWeaving=AspectJWeaving.AUTODETECT)
|
@EnableLoadTimeWeaving(aspectjWeaving=AspectJWeaving.AUTODETECT)
|
||||||
static class EnableLTWConfig_withAjWeavingAutodetect implements LoadTimeWeavingConfigurer {
|
static class EnableLTWConfig_withAjWeavingAutodetect implements LoadTimeWeavingConfigurer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LoadTimeWeaver getLoadTimeWeaver() {
|
public LoadTimeWeaver getLoadTimeWeaver() {
|
||||||
return mock(LoadTimeWeaver.class);
|
return mock(LoadTimeWeaver.class);
|
||||||
|
@ -94,9 +97,11 @@ public class EnableLoadTimeWeavingTests {
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableLoadTimeWeaving(aspectjWeaving=AspectJWeaving.ENABLED)
|
@EnableLoadTimeWeaving(aspectjWeaving=AspectJWeaving.ENABLED)
|
||||||
static class EnableLTWConfig_withAjWeavingEnabled implements LoadTimeWeavingConfigurer {
|
static class EnableLTWConfig_withAjWeavingEnabled implements LoadTimeWeavingConfigurer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LoadTimeWeaver getLoadTimeWeaver() {
|
public LoadTimeWeaver getLoadTimeWeaver() {
|
||||||
return mock(LoadTimeWeaver.class);
|
return mock(LoadTimeWeaver.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2020 the original author or authors.
|
* Copyright 2002-2021 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.
|
||||||
|
@ -67,7 +67,6 @@ public abstract class ApplicationEventsHolder {
|
||||||
* @throws IllegalStateException if an instance of {@code ApplicationEvents}
|
* @throws IllegalStateException if an instance of {@code ApplicationEvents}
|
||||||
* has not been registered for the current thread
|
* has not been registered for the current thread
|
||||||
*/
|
*/
|
||||||
@Nullable
|
|
||||||
public static ApplicationEvents getRequiredApplicationEvents() {
|
public static ApplicationEvents getRequiredApplicationEvents() {
|
||||||
ApplicationEvents events = applicationEvents.get();
|
ApplicationEvents events = applicationEvents.get();
|
||||||
Assert.state(events != null, "Failed to retrieve ApplicationEvents for the current thread. " +
|
Assert.state(events != null, "Failed to retrieve ApplicationEvents for the current thread. " +
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseCookie;
|
import org.springframework.http.ResponseCookie;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.util.LinkedMultiValueMap;
|
import org.springframework.util.LinkedMultiValueMap;
|
||||||
|
@ -147,10 +148,12 @@ class JettyClientHttpResponse implements ClientHttpResponse {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
Iterable<?> iterator = (Iterable<?>)
|
Iterable<?> iterator = (Iterable<?>)
|
||||||
ReflectionUtils.invokeMethod(getHeadersMethod, response.getResponse());
|
ReflectionUtils.invokeMethod(getHeadersMethod, response.getResponse());
|
||||||
|
Assert.notNull(iterator, "Iterator must not be null");
|
||||||
for (Object field : iterator) {
|
for (Object field : iterator) {
|
||||||
headers.add(
|
String name = (String) ReflectionUtils.invokeMethod(getNameMethod, field);
|
||||||
(String) ReflectionUtils.invokeMethod(getNameMethod, field),
|
Assert.notNull(name, "Header name must not be null");
|
||||||
(String) ReflectionUtils.invokeMethod(getValueMethod, field));
|
String value = (String) ReflectionUtils.invokeMethod(getValueMethod, field);
|
||||||
|
headers.add(name, value);
|
||||||
}
|
}
|
||||||
return headers;
|
return headers;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.springframework.lang.Nullable;
|
||||||
*
|
*
|
||||||
* @author Arjen Poutsma
|
* @author Arjen Poutsma
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
|
* @author Rossen Stoyanchev
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
* @param <T> the converted object type
|
* @param <T> the converted object type
|
||||||
*/
|
*/
|
||||||
|
@ -67,8 +68,8 @@ public interface HttpMessageConverter<T> {
|
||||||
/**
|
/**
|
||||||
* Return the list of media types supported by this converter for the given
|
* Return the list of media types supported by this converter for the given
|
||||||
* class. The list may differ from {@link #getSupportedMediaTypes()} if the
|
* class. The list may differ from {@link #getSupportedMediaTypes()} if the
|
||||||
* converter doesn't support given Class or if it support it only for a
|
* converter does not support the given Class or if it supports it only for
|
||||||
* subset of media types.
|
* a subset of media types.
|
||||||
* @param clazz the type of class to check
|
* @param clazz the type of class to check
|
||||||
* @return the list of media types supported for the given class
|
* @return the list of media types supported for the given class
|
||||||
* @since 5.3.4
|
* @since 5.3.4
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.web.reactive.socket.server.upgrade;
|
package org.springframework.web.reactive.socket.server.upgrade;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
@ -35,6 +36,7 @@ import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||||
import org.springframework.http.server.reactive.ServerHttpResponseDecorator;
|
import org.springframework.http.server.reactive.ServerHttpResponseDecorator;
|
||||||
import org.springframework.lang.NonNull;
|
import org.springframework.lang.NonNull;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.ReflectionUtils;
|
import org.springframework.util.ReflectionUtils;
|
||||||
import org.springframework.web.reactive.socket.HandshakeInfo;
|
import org.springframework.web.reactive.socket.HandshakeInfo;
|
||||||
import org.springframework.web.reactive.socket.WebSocketHandler;
|
import org.springframework.web.reactive.socket.WebSocketHandler;
|
||||||
|
@ -67,7 +69,9 @@ public class Jetty10RequestUpgradeStrategy implements RequestUpgradeStrategy {
|
||||||
|
|
||||||
Class<?> type = loader.loadClass("org.eclipse.jetty.websocket.server.JettyWebSocketServerContainer");
|
Class<?> type = loader.loadClass("org.eclipse.jetty.websocket.server.JettyWebSocketServerContainer");
|
||||||
getContainerMethod = type.getMethod("getContainer", ServletContext.class);
|
getContainerMethod = type.getMethod("getContainer", ServletContext.class);
|
||||||
upgradeMethod = ReflectionUtils.findMethod(type, "upgrade", (Class<?>[]) null);
|
Method upgrade = ReflectionUtils.findMethod(type, "upgrade", (Class<?>[]) null);
|
||||||
|
Assert.state(upgrade != null, "Upgrade method not found");
|
||||||
|
upgradeMethod = upgrade;
|
||||||
|
|
||||||
type = loader.loadClass("org.eclipse.jetty.websocket.server.JettyServerUpgradeResponse");
|
type = loader.loadClass("org.eclipse.jetty.websocket.server.JettyServerUpgradeResponse");
|
||||||
setAcceptedSubProtocol = type.getMethod("setAcceptedSubProtocol", String.class);
|
setAcceptedSubProtocol = type.getMethod("setAcceptedSubProtocol", String.class);
|
||||||
|
|
|
@ -203,7 +203,8 @@ public abstract class AbstractMessageConverterMethodArgumentResolver implements
|
||||||
(noContentType && !message.hasBody())) {
|
(noContentType && !message.hasBody())) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
throw new HttpMediaTypeNotSupportedException(contentType, getSupportedMediaTypes(targetClass));
|
throw new HttpMediaTypeNotSupportedException(contentType,
|
||||||
|
getSupportedMediaTypes(targetClass != null ? targetClass : Object.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
MediaType selectedContentType = contentType;
|
MediaType selectedContentType = contentType;
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.web.socket.server.jetty;
|
package org.springframework.web.socket.server.jetty;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
@ -72,7 +73,9 @@ public class Jetty10RequestUpgradeStrategy implements RequestUpgradeStrategy {
|
||||||
|
|
||||||
Class<?> type = loader.loadClass("org.eclipse.jetty.websocket.server.JettyWebSocketServerContainer");
|
Class<?> type = loader.loadClass("org.eclipse.jetty.websocket.server.JettyWebSocketServerContainer");
|
||||||
getContainerMethod = type.getMethod("getContainer", ServletContext.class);
|
getContainerMethod = type.getMethod("getContainer", ServletContext.class);
|
||||||
upgradeMethod = ReflectionUtils.findMethod(type, "upgrade", (Class<?>[]) null);
|
Method upgrade = ReflectionUtils.findMethod(type, "upgrade", (Class<?>[]) null);
|
||||||
|
Assert.state(upgrade != null, "Upgrade method not found");
|
||||||
|
upgradeMethod = upgrade;
|
||||||
|
|
||||||
type = loader.loadClass("org.eclipse.jetty.websocket.server.JettyServerUpgradeResponse");
|
type = loader.loadClass("org.eclipse.jetty.websocket.server.JettyServerUpgradeResponse");
|
||||||
setAcceptedSubProtocol = type.getMethod("setAcceptedSubProtocol", String.class);
|
setAcceptedSubProtocol = type.getMethod("setAcceptedSubProtocol", String.class);
|
||||||
|
|
Loading…
Reference in New Issue