Upgrade NullAway to 0.12.4
This commit also slightly refines nullness but without significant user-side impact expected. Closes gh-34525
This commit is contained in:
parent
f7db4bf4f0
commit
7bc712e304
|
@ -13,7 +13,7 @@ dependencies {
|
|||
jmh 'org.openjdk.jmh:jmh-generator-annprocess:1.37'
|
||||
jmh 'org.openjdk.jmh:jmh-generator-bytecode:1.37'
|
||||
jmh 'net.sf.jopt-simple:jopt-simple'
|
||||
errorprone 'com.uber.nullaway:nullaway:0.12.3'
|
||||
errorprone 'com.uber.nullaway:nullaway:0.12.4'
|
||||
errorprone 'com.google.errorprone:error_prone_core:2.36.0'
|
||||
}
|
||||
|
||||
|
|
|
@ -41,11 +41,11 @@ import org.springframework.context.annotation.Role;
|
|||
@Configuration(proxyBeanMethods = false)
|
||||
public abstract class AbstractJCacheConfiguration extends AbstractCachingConfiguration {
|
||||
|
||||
protected @Nullable Supplier<? extends @Nullable CacheResolver> exceptionCacheResolver;
|
||||
protected @Nullable Supplier<@Nullable CacheResolver> exceptionCacheResolver;
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("NullAway") // https://github.com/uber/NullAway/issues/1126
|
||||
@SuppressWarnings("NullAway") // https://github.com/uber/NullAway/issues/1128
|
||||
protected void useCachingConfigurer(CachingConfigurerSupplier cachingConfigurerSupplier) {
|
||||
super.useCachingConfigurer(cachingConfigurerSupplier);
|
||||
this.exceptionCacheResolver = cachingConfigurerSupplier.adapt(config -> {
|
||||
|
|
|
@ -79,8 +79,8 @@ public class DefaultJCacheOperationSource extends AnnotationJCacheOperationSourc
|
|||
* @since 5.1
|
||||
*/
|
||||
public DefaultJCacheOperationSource(
|
||||
@Nullable Supplier<? extends @Nullable CacheManager> cacheManager, @Nullable Supplier<? extends @Nullable CacheResolver> cacheResolver,
|
||||
@Nullable Supplier<? extends @Nullable CacheResolver> exceptionCacheResolver, @Nullable Supplier<? extends @Nullable KeyGenerator> keyGenerator) {
|
||||
@Nullable Supplier<@Nullable CacheManager> cacheManager, @Nullable Supplier<@Nullable CacheResolver> cacheResolver,
|
||||
@Nullable Supplier<@Nullable CacheResolver> exceptionCacheResolver, @Nullable Supplier<@Nullable KeyGenerator> keyGenerator) {
|
||||
|
||||
this.cacheManager = SingletonSupplier.ofNullable(cacheManager);
|
||||
this.cacheResolver = SingletonSupplier.ofNullable(cacheResolver);
|
||||
|
|
|
@ -50,13 +50,13 @@ public abstract class AbstractCachingConfiguration implements ImportAware {
|
|||
|
||||
protected @Nullable AnnotationAttributes enableCaching;
|
||||
|
||||
protected @Nullable Supplier<? extends @Nullable CacheManager> cacheManager;
|
||||
protected @Nullable Supplier<@Nullable CacheManager> cacheManager;
|
||||
|
||||
protected @Nullable Supplier<? extends @Nullable CacheResolver> cacheResolver;
|
||||
protected @Nullable Supplier<@Nullable CacheResolver> cacheResolver;
|
||||
|
||||
protected @Nullable Supplier<? extends @Nullable KeyGenerator> keyGenerator;
|
||||
protected @Nullable Supplier<@Nullable KeyGenerator> keyGenerator;
|
||||
|
||||
protected @Nullable Supplier<? extends @Nullable CacheErrorHandler> errorHandler;
|
||||
protected @Nullable Supplier<@Nullable CacheErrorHandler> errorHandler;
|
||||
|
||||
|
||||
@Override
|
||||
|
@ -70,9 +70,8 @@ public abstract class AbstractCachingConfiguration implements ImportAware {
|
|||
}
|
||||
|
||||
@Autowired
|
||||
@SuppressWarnings("NullAway") // https://github.com/uber/NullAway/issues/1126
|
||||
void setConfigurers(ObjectProvider<CachingConfigurer> configurers) {
|
||||
Supplier<? extends @Nullable CachingConfigurer> configurer = () -> {
|
||||
Supplier<@Nullable CachingConfigurer> configurer = () -> {
|
||||
List<CachingConfigurer> candidates = configurers.stream().toList();
|
||||
if (CollectionUtils.isEmpty(candidates)) {
|
||||
return null;
|
||||
|
@ -91,7 +90,7 @@ public abstract class AbstractCachingConfiguration implements ImportAware {
|
|||
/**
|
||||
* Extract the configuration from the nominated {@link CachingConfigurer}.
|
||||
*/
|
||||
@SuppressWarnings("NullAway") // https://github.com/uber/NullAway/issues/1126
|
||||
@SuppressWarnings("NullAway") // https://github.com/uber/NullAway/issues/1128
|
||||
protected void useCachingConfigurer(CachingConfigurerSupplier cachingConfigurerSupplier) {
|
||||
this.cacheManager = cachingConfigurerSupplier.adapt(CachingConfigurer::cacheManager);
|
||||
this.cacheResolver = cachingConfigurerSupplier.adapt(CachingConfigurer::cacheResolver);
|
||||
|
@ -104,7 +103,7 @@ public abstract class AbstractCachingConfiguration implements ImportAware {
|
|||
|
||||
private final SingletonSupplier<CachingConfigurer> supplier;
|
||||
|
||||
public CachingConfigurerSupplier(Supplier<? extends @Nullable CachingConfigurer> supplier) {
|
||||
public CachingConfigurerSupplier(Supplier<@Nullable CachingConfigurer> supplier) {
|
||||
this.supplier = SingletonSupplier.ofNullable(supplier);
|
||||
}
|
||||
|
||||
|
@ -117,7 +116,7 @@ public abstract class AbstractCachingConfiguration implements ImportAware {
|
|||
* @param <T> the type of the supplier
|
||||
* @return another supplier mapped by the specified function
|
||||
*/
|
||||
public <T> Supplier<@Nullable T> adapt(Function<CachingConfigurer, ? extends @Nullable T> provider) {
|
||||
public <T> Supplier<@Nullable T> adapt(Function<CachingConfigurer, @Nullable T> provider) {
|
||||
return () -> {
|
||||
CachingConfigurer cachingConfigurer = this.supplier.get();
|
||||
return (cachingConfigurer != null ? provider.apply(cachingConfigurer) : null);
|
||||
|
|
|
@ -506,7 +506,6 @@ public abstract class AbstractReflectiveMBeanInfoAssembler extends AbstractMBean
|
|||
* of the {@code MBeanExporter}
|
||||
* @return the {@code MBeanParameterInfo} array
|
||||
*/
|
||||
@SuppressWarnings("NullAway") // https://github.com/uber/NullAway/issues/1127
|
||||
protected MBeanParameterInfo[] getOperationParameters(Method method, String beanKey) {
|
||||
ParameterNameDiscoverer paramNameDiscoverer = getParameterNameDiscoverer();
|
||||
@Nullable String[] paramNames = (paramNameDiscoverer != null ? paramNameDiscoverer.getParameterNames(method) : null);
|
||||
|
|
|
@ -67,7 +67,7 @@ public abstract class AbstractAsyncConfiguration implements ImportAware {
|
|||
* Collect any {@link AsyncConfigurer} beans through autowiring.
|
||||
*/
|
||||
@Autowired
|
||||
@SuppressWarnings("NullAway") // https://github.com/uber/NullAway/issues/1126
|
||||
@SuppressWarnings("NullAway") // https://github.com/uber/NullAway/issues/1128
|
||||
void setConfigurers(ObjectProvider<AsyncConfigurer> configurers) {
|
||||
SingletonSupplier<AsyncConfigurer> configurer = SingletonSupplier.ofNullable(() -> {
|
||||
List<AsyncConfigurer> candidates = configurers.stream().toList();
|
||||
|
|
|
@ -162,7 +162,7 @@ public class SingletonSupplier<T> implements Supplier<@Nullable T> {
|
|||
* @return the singleton supplier, or {@code null} if the instance supplier was {@code null}
|
||||
*/
|
||||
@Contract("null -> null; !null -> !null")
|
||||
public static <T> @Nullable SingletonSupplier<T> ofNullable(@Nullable Supplier<? extends @Nullable T> supplier) {
|
||||
public static <T> @Nullable SingletonSupplier<T> ofNullable(@Nullable Supplier<@Nullable T> supplier) {
|
||||
return (supplier != null ? new SingletonSupplier<>(supplier) : null);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.time.Duration;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
|
@ -166,7 +167,7 @@ final class RSocketServiceMethod {
|
|||
((Mono<?>) responsePublisher).blockOptional());
|
||||
}
|
||||
else {
|
||||
return (blockTimeout != null ?
|
||||
return Objects.requireNonNull(blockTimeout != null ?
|
||||
((Mono<?>) responsePublisher).block(blockTimeout) :
|
||||
((Mono<?>) responsePublisher).block());
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ public class SpringSessionContext implements CurrentSessionContext {
|
|||
public SpringSessionContext(SessionFactoryImplementor sessionFactory) {
|
||||
this.sessionFactory = sessionFactory;
|
||||
try {
|
||||
JtaPlatform jtaPlatform = sessionFactory.getServiceRegistry().getService(JtaPlatform.class);
|
||||
JtaPlatform jtaPlatform = sessionFactory.getServiceRegistry().requireService(JtaPlatform.class);
|
||||
this.transactionManager = jtaPlatform.retrieveTransactionManager();
|
||||
if (this.transactionManager != null) {
|
||||
this.jtaSessionContext = new SpringJtaSessionContext(sessionFactory);
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.lang.reflect.InvocationTargetException;
|
|||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.JvmClassMappingKt;
|
||||
|
@ -317,7 +318,7 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
|||
KType type = parameter.getType();
|
||||
if (!(type.isMarkedNullable() && arg == null) && type.getClassifier() instanceof KClass<?> kClass
|
||||
&& KotlinDetector.isInlineClass(JvmClassMappingKt.getJavaClass(kClass))) {
|
||||
KFunction<?> constructor = KClasses.getPrimaryConstructor(kClass);
|
||||
KFunction<?> constructor = Objects.requireNonNull(KClasses.getPrimaryConstructor(kClass));
|
||||
if (!KCallablesJvm.isAccessible(constructor)) {
|
||||
KCallablesJvm.setAccessible(constructor, true);
|
||||
}
|
||||
|
|
|
@ -94,6 +94,7 @@ public abstract class AbstractReactorHttpExchangeAdapter implements ReactorHttpE
|
|||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T exchangeForBody(HttpRequestValues requestValues, ParameterizedTypeReference<T> bodyType) {
|
||||
return (this.blockTimeout != null ?
|
||||
exchangeForBodyMono(requestValues, bodyType).block(this.blockTimeout) :
|
||||
|
|
|
@ -140,7 +140,6 @@ public class DefaultUriBuilderFactory implements UriBuilderFactory {
|
|||
* with a Map of variables.
|
||||
* @param defaultUriVariables default URI variable values
|
||||
*/
|
||||
@SuppressWarnings("NullAway") // https://github.com/uber/NullAway/issues/1126
|
||||
public void setDefaultUriVariables(@Nullable Map<String, ? extends @Nullable Object> defaultUriVariables) {
|
||||
if (defaultUriVariables != null) {
|
||||
if (this.defaultUriVariables == null) {
|
||||
|
@ -432,7 +431,6 @@ public class DefaultUriBuilderFactory implements UriBuilderFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("NullAway") // https://github.com/uber/NullAway/issues/1126
|
||||
public URI build(Map<String, ?> uriVars) {
|
||||
if (!CollectionUtils.isEmpty(defaultUriVariables)) {
|
||||
Map<String, Object> map = new HashMap<>(defaultUriVariables.size() + uriVars.size());
|
||||
|
@ -448,7 +446,6 @@ public class DefaultUriBuilderFactory implements UriBuilderFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("NullAway") // https://github.com/uber/NullAway/issues/1126
|
||||
public URI build(@Nullable Object... uriVars) {
|
||||
if (ObjectUtils.isEmpty(uriVars) && !CollectionUtils.isEmpty(defaultUriVariables)) {
|
||||
return build(Collections.emptyMap());
|
||||
|
|
|
@ -232,8 +232,7 @@ class DefaultClientResponse implements ClientResponse {
|
|||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("NullAway") // https://github.com/uber/NullAway/issues/1126
|
||||
private Function<ResolvableType, ? extends @Nullable Object> initDecodeFunction(byte[] body, @Nullable MediaType contentType) {
|
||||
private Function<ResolvableType, @Nullable Object> initDecodeFunction(byte[] body, @Nullable MediaType contentType) {
|
||||
return targetType -> {
|
||||
if (ObjectUtils.isEmpty(body)) {
|
||||
return null;
|
||||
|
|
|
@ -92,7 +92,6 @@ public class CompositeRequestCondition extends AbstractRequestCondition<Composit
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("NullAway") // https://github.com/uber/NullAway/issues/1126
|
||||
protected Collection<? extends @Nullable Object> getContent() {
|
||||
return (!isEmpty() ? getConditions() : Collections.emptyList());
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.lang.reflect.Type;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import kotlin.Unit;
|
||||
|
@ -355,7 +356,7 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
|||
KType type = parameter.getType();
|
||||
if (!(type.isMarkedNullable() && arg == null) && type.getClassifier() instanceof KClass<?> kClass
|
||||
&& KotlinDetector.isInlineClass(JvmClassMappingKt.getJavaClass(kClass))) {
|
||||
KFunction<?> constructor = KClasses.getPrimaryConstructor(kClass);
|
||||
KFunction<?> constructor = Objects.requireNonNull(KClasses.getPrimaryConstructor(kClass));
|
||||
if (!KCallablesJvm.isAccessible(constructor)) {
|
||||
KCallablesJvm.setAccessible(constructor, true);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
package org.springframework.web.reactive.result.method.annotation;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
|
@ -69,7 +71,7 @@ public abstract class AbstractNamedValueSyncArgumentResolver extends AbstractNam
|
|||
MethodParameter parameter, BindingContext context, ServerWebExchange exchange) {
|
||||
|
||||
// This won't block since resolveName below doesn't
|
||||
return resolveArgument(parameter, context, exchange).block();
|
||||
return Objects.requireNonNull(resolveArgument(parameter, context, exchange).block());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue