8000 Upgrade NullAway to 0.12.4 · spring-projects/spring-framework@7bc712e · GitHub
[go: up one dir, main page]

Skip to content

Commit 7bc712e

Browse files
committed
Upgrade NullAway to 0.12.4
This commit also slightly refines nullness but without significant user-side impact expected. Closes gh-34525
1 parent f7db4bf commit 7bc712e

File tree

16 files changed

+27
-28
lines changed

16 files changed

+27
-28
lines changed

gradle/spring-module.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies {
1313
jmh 'org.openjdk.jmh:jmh-generator-annprocess:1.37'
1414
jmh 'org.openjdk.jmh:jmh-generator-bytecode:1.37'
1515
jmh 'net.sf.jopt-simple:jopt-simple'
16-
errorprone 'com.uber.nullaway:nullaway:0.12.3'
16+
errorprone 'com.uber.nullaway:nullaway:0.12.4'
1717
errorprone 'com.google.errorprone:error_prone_core:2.36.0'
1818
}
1919

spring-context-support/src/main/java/org/springframework/cache/jcache/config/AbstractJCacheConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@
4141
@Configuration(proxyBeanMethods = false)
4242
public abstract class AbstractJCacheConfiguration extends AbstractCachingConfiguration {
4343

44-
protected @Nullable Supplier<? extends @Nullable CacheResolver> exceptionCacheResolver;
44+
protected @Nullable Supplier<@Nullable CacheResolver> exceptionCacheResolver;
4545

4646

4747
@Override
48-
@SuppressWarnings("NullAway") // https://github.com/uber/NullAway/issues/1126
48+
@SuppressWarnings("NullAway") // https://github.com/uber/NullAway/issues/1128
4949
protected void useCachingConfigurer(CachingConfigurerSupplier cachingConfigurerSupplier) {
5050
super.useCachingConfigurer(cachingConfigurerSupplier);
5151
this.exceptionCacheResolver = cachingConfigurerSupplier.adapt(config -> {

spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/DefaultJCacheOperationSource.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ public DefaultJCacheOperationSource() {
7979
* @since 5.1
8080
*/
8181
public DefaultJCacheOperationSource(
82-
@Nullable Supplier<? extends @Nullable CacheManager> cacheManager, @Nullable Supplier<? extends @Nullable CacheResolver> cacheResolver,
83-
@Nullable Supplier<? extends @Nullable CacheResolver> exceptionCacheResolver, @Nullable Supplier<? extends @Nullable KeyGenerator> keyGenerator) {
82+
@Nullable Supplier<@Nullable CacheManager> cacheManager, @Nullable Supplier<@Nullable CacheResolver> cacheResolver,
83+
@Nullable Supplier<@Nullable CacheResolver> exceptionCacheResolver, @Nullable Supplier<@Nullable KeyGenerator> keyGenerator) {
8484

8585
this.cacheManager = SingletonSupplier.ofNullable(cacheManager);
8686
this.cacheResolver = SingletonSupplier.ofNullable(cacheResolver);

spring-context/src/main/java/org/springframework/cache/annotation/AbstractCachingConfiguration.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ public abstract class AbstractCachingConfiguration implements ImportAware {
5050

5151
protected @Nullable AnnotationAttributes enableCaching;
5252

53-
protected @Nullable Supplier<? extends @Nullable CacheManager> cacheManager;
53+
protected @Nullable Supplier<@Nullable CacheManager> cacheManager;
5454

55-
protected @Nullable Supplier<? extends @Nullable CacheResolver> cacheResolver;
55+
protected @Nullable Supplier<@Nullable CacheResolver> cacheResolver;
5656

57-
protected @Nullable Supplier<? extends @Nullable KeyGenerator> keyGenerator;
57+
protected @Nullable Supplier<@Nullable KeyGenerator> keyGenerator;
5858

59-
protected @Nullable Supplier<? extends @Nullable CacheErrorHandler> errorHandler;
59+
protected @Nullable Supplier<@Nullable CacheErrorHandler> errorHandler;
6060

6161

6262
@Override
@@ -70,9 +70,8 @@ public void setImportMetadata(AnnotationMetadata importMetadata) {
7070
}
7171

7272
@Autowired
73-
@SuppressWarnings("NullAway") // https://github.com/uber/NullAway/issues/1126
7473
void setConfigurers(ObjectProvider<CachingConfigurer> configurers) {
75-
Supplier<? extends @Nullable CachingConfigurer> configurer = () -> {
74+
Supplier<@Nullable CachingConfigurer> configurer = () -> {
7675
List<CachingConfigurer> candidates = configurers.stream().toList();
7776
if (CollectionUtils.isEmpty(candidates)) {
7877
return null;
@@ -91,7 +90,7 @@ void setConfigurers(ObjectProvider<CachingConfigurer> configurers) {
9190
/**
9291
* Extract the configuration from the nominated {@link CachingConfigurer}.
9392
*/
94-
@SuppressWarnings("NullAway") // https://github.com/uber/NullAway/issues/1126
93+
@SuppressWarnings("NullAway") // https://github.com/uber/NullAway/issues/1128
9594
protected void useCachingConfigurer(CachingConfigurerSupplier cachingConfigurerSupplier) {
9695
this.cacheManager = cachingConfigurerSupplier.adapt(CachingConfigurer::cacheManager);
9796
this.cacheResolver = cachingConfigurerSupplier.adapt(CachingConfigurer::cacheResolver);
@@ -104,7 +103,7 @@ protected static class CachingConfigurerSupplier {
104103

105104
private final SingletonSupplier<CachingConfigurer> supplier;
106105

107-
public CachingConfigurerSupplier(Supplier<? extends @Nullable CachingConfigurer> supplier) {
106+
public CachingConfigurerSupplier(Supplier<@Nullable CachingConfigurer> supplier) {
108107
this.supplier = SingletonSupplier.ofNullable(supplier);
109108
}
110109

@@ -117,7 +116,7 @@ public CachingConfigurerSupplier(Supplier<? extends @Nullable CachingConfigurer>
117116
* @param <T> the type of the supplier
118117
* @return another supplier mapped by the specified function
119118
*/
120-
public <T> Supplier<@Nullable T> adapt(Function<CachingConfigurer, ? extends @Nullable T> provider) {
119+
public <T> Supplier<@Nullable T> adapt(Function<CachingConfigurer, @Nullable T> provider) {
121120
return () -> {
122121
CachingConfigurer cachingConfigurer = this.supplier.get();
123122
return (cachingConfigurer != null ? provider.apply(cachingConfigurer) : null);

spring-context/src/main/java/org/springframework/jmx/export/assembler/AbstractReflectiveMBeanInfoAssembler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,6 @@ protected String getOperationDescription(Method method, String beanKey) {
506506
* of the {@code MBeanExporter}
507507
* @return the {@code MBeanParameterInfo} array
508508
*/
509-
@SuppressWarnings("NullAway") // https://github.com/uber/NullAway/issues/1127
510509
protected MBeanParameterInfo[] getOperationParameters(Method method, String beanKey) {
511510
ParameterNameDiscoverer paramNameDiscoverer = getParameterNameDiscoverer();
512511
@Nullable String[] paramNames = (paramNameDiscoverer != null ? paramNameDiscoverer.getParameterNames(method) : null);

spring-context/src/main/java/org/springframework/scheduling/annotation/AbstractAsyncConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void setImportMetadata(AnnotationMetadata importMetadata) {
6767
* Collect any {@link AsyncConfigurer} beans through autowiring.
6868
*/
6969
@Autowired
70-
@SuppressWarnings("NullAway") // https://github.com/uber/NullAway/issues/1126
70+
@SuppressWarnings("NullAway") // https://github.com/uber/NullAway/issues/1128
7171
void setConfigurers(ObjectProvider<AsyncConfigurer> configurers) {
7272
SingletonSupplier<AsyncConfigurer> configurer = SingletonSupplier.ofNullable(() -> {
7373
List<AsyncConfigurer> candidates = configurers.stream().toList();

spring-core/src/main/java/org/springframework/util/function/SingletonSupplier.java

Lines changed: 1 addition & 1 deletion
Original E377 file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public static <T> SingletonSupplier<T> of(Supplier<T> supplier) {
162162
* @return the singleton supplier, or {@code null} if the instance supplier was {@code null}
163163
*/
164164
@Contract("null -> null; !null -> !null")
165-
public static <T> @Nullable SingletonSupplier<T> ofNullable(@Nullable Supplier<? extends @Nullable T> supplier) {
165+
public static <T> @Nullable SingletonSupplier<T> ofNullable(@Nullable Supplier<@Nullable T> supplier) {
166166
return (supplier != null ? new SingletonSupplier<>(supplier) : null);
167167
}
168168

spring-messaging/src/main/java/org/springframework/messaging/rsocket/service/RSocketServiceMethod.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.Iterator;
2222
import java.util.List;
2323
import java.util.Map;
24+
import java.util.Objects;
2425
import java.util.Optional;
2526
import java.util.function.Function;
2627

@@ -166,7 +167,7 @@ else if (reactiveAdapter == null) {
166167
((Mono<?>) responsePublisher).blockOptional());
167168
}
168169
else {
169-
return (blockTimeout != null ?
170+
return Objects.requireNonNull(blockTimeout != null ?
170171
((Mono<?>) responsePublisher).block(blockTimeout) :
171172
((Mono<?>) responsePublisher).block());
172173
}

spring-orm/src/main/java/org/springframework/orm/hibernate5/SpringSessionContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public class SpringSessionContext implements CurrentSessionContext {
6060
public SpringSessionContext(SessionFactoryImplementor sessionFactory) {
6161
this.sessionFactory = sessionFactory;
6262
try {
63-
JtaPlatform jtaPlatform = sessionFactory.getServiceRegistry().getService(JtaPlatform.class);
63+
JtaPlatform jtaPlatform = sessionFactory.getServiceRegistry().requireService(JtaPlatform.class);
6464
this.transactionManager = jtaPlatform.retrieveTransactionManager();
6565
if (this.transactionManager != null) {
6666
this.jtaSessionContext = new SpringJtaSessionContext(sessionFactory);

spring-web/src/main/java/org/springframework/web/method/support/InvocableHandlerMethod.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.lang.reflect.Method;
2121
import java.util.Arrays;
2222
import java.util.Map;
23+
import java.util.Objects;
2324

2425
import kotlin.Unit;
2526
import kotlin.jvm.JvmClassMappingKt;
@@ -317,7 +318,7 @@ private static class KotlinDelegate {
317318
KType type = parameter.getType();
318319
if (!(type.isMarkedNullable() && arg == null) && type.getClassifier() instanceof KClass<?> kClass
319320
&& KotlinDetector.isInlineClass(JvmClassMappingKt.getJavaClass(kClass))) {
320-
KFunction<?> constructor = KClasses.getPrimaryConstructor(kClass);
321+
KFunction<?> constructor = Objects.requireNonNull(KClasses.getPrimaryConstructor(kClass));
321322
if (!KCallablesJvm.isAccessible(constructor)) {
322323
KCallablesJvm.setAccessible(constructor, true);
323324
}

0 commit comments

Comments
 (0)
0