Skip to content

Commit 0aa3205

Browse files
committed
Fix nullability warnings
1 parent 5b910a8 commit 0aa3205

File tree

4 files changed

+20
-14
lines changed

4 files changed

+20
-14
lines changed

spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/AbstractEncoderMethodReturnValueHandler.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.messaging.handler.invocation.reactive;
1818

19+
import java.lang.reflect.Method;
1920
import java.util.Collections;
2021
import java.util.List;
2122
import java.util.Map;
@@ -120,7 +121,6 @@ public Mono<Void> handleReturnValue(
120121
handleEncodedContent(Flux.from(publisher), returnType, message));
121122
}
122123

123-
@SuppressWarnings("unchecked")
124124
private Flux<DataBuffer> encodeContent(
125125
@Nullable Object content, MethodParameter returnType, DataBufferFactory bufferFactory,
126126
@Nullable MimeType mimeType, Map<String, Object> hints) {
@@ -132,9 +132,10 @@ private Flux<DataBuffer> encodeContent(
132132
ResolvableType elementType;
133133
if (adapter != null) {
134134
publisher = adapter.toPublisher(content);
135-
boolean isUnwrapped = KotlinDetector.isSuspendingFunction(returnType.getMethod()) &&
136-
!COROUTINES_FLOW_CLASS_NAME.equals(returnValueType.toClass().getName());
137-
ResolvableType genericType = isUnwrapped ? returnValueType : returnValueType.getGeneric();
135+
Method method = returnType.getMethod();
136+
boolean isUnwrapped = (method != null && KotlinDetector.isSuspendingFunction(method) &&
137+
!COROUTINES_FLOW_CLASS_NAME.equals(returnValueType.toClass().getName()));
138+
ResolvableType genericType = (isUnwrapped ? returnValueType : returnValueType.getGeneric());
138139
elementType = getElementType(adapter, genericType);
139140
}
140141
else {

spring-test/src/main/java/org/springframework/test/context/TestContextAnnotationUtils.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,10 @@ public abstract class TestContextAnnotationUtils {
7575
private static final ConcurrentLruCache<Class<?>, EnclosingConfiguration> cachedEnclosingConfigurationModes =
7676
new ConcurrentLruCache<>(32, TestContextAnnotationUtils::lookUpEnclosingConfiguration);
7777

78+
@Nullable
7879
private static volatile EnclosingConfiguration defaultEnclosingConfigurationMode;
7980

81+
8082
/**
8183
* Find the first annotation of the specified {@code annotationType} within
8284
* the annotation hierarchy <em>above</em> the supplied class, merge that
@@ -411,13 +413,15 @@ private static EnclosingConfiguration lookUpEnclosingConfiguration(Class<?> claz
411413
}
412414

413415
private static EnclosingConfiguration getDefaultEnclosingConfigurationMode() {
414-
if (defaultEnclosingConfigurationMode == null) {
416+
EnclosingConfiguration defaultConfigurationMode = defaultEnclosingConfigurationMode;
417+
if (defaultConfigurationMode == null) {
415418
String value = SpringProperties.getProperty(NestedTestConfiguration.ENCLOSING_CONFIGURATION_PROPERTY_NAME);
416419
EnclosingConfiguration enclosingConfigurationMode = EnclosingConfiguration.from(value);
417-
defaultEnclosingConfigurationMode =
420+
defaultConfigurationMode =
418421
(enclosingConfigurationMode != null ? enclosingConfigurationMode : EnclosingConfiguration.INHERIT);
422+
defaultEnclosingConfigurationMode = defaultConfigurationMode;
419423
}
420-
return defaultEnclosingConfigurationMode;
424+
return defaultConfigurationMode;
421425
}
422426

423427
private static void assertNonEmptyAnnotationTypeArray(Class<?>[] annotationTypes, String message) {
@@ -503,9 +507,10 @@ public static class AnnotationDescriptor<T extends Annotation> {
503507
this.declaringClass = declaringClass;
504508
this.composedAnnotation = composedAnnotation;
505509
this.annotation = annotation;
506-
this.annotationAttributes = AnnotatedElementUtils.findMergedAnnotationAttributes(
510+
AnnotationAttributes attributes = AnnotatedElementUtils.findMergedAnnotationAttributes(
507511
rootDeclaringClass, annotation.annotationType().getName(), false, false);
508-
Assert.state(this.annotationAttributes != null, "No annotation attributes");
512+
Assert.state(attributes != null, "No annotation attributes");
513+
this.annotationAttributes = attributes;
509514
}
510515

511516
public Class<?> getRootDeclaringClass() {

spring-test/src/main/java/org/springframework/test/context/support/TestPropertySourceUtils.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,15 @@ else if (!duplicationDetected(currentAttributes, previousAttributes)) {
126126
}
127127

128128
private static boolean duplicationDetected(TestPropertySourceAttributes currentAttributes,
129-
TestPropertySourceAttributes previousAttributes) {
129+
@Nullable TestPropertySourceAttributes previousAttributes) {
130130

131131
boolean duplicationDetected =
132132
(currentAttributes.equals(previousAttributes) && !currentAttributes.isEmpty());
133133

134134
if (duplicationDetected && logger.isDebugEnabled()) {
135-
logger.debug(String.format("Ignoring duplicate %s declaration on %s, "
136-
+ "since it is also declared on %s.", currentAttributes,
137-
previousAttributes.getDeclaringClass().getName(),
138-
currentAttributes.getDeclaringClass().getName()));
135+
logger.debug(String.format("Ignoring duplicate %s declaration on %s since it is also declared on %s",
136+
currentAttributes, currentAttributes.getDeclaringClass().getName(),
137+
previousAttributes.getDeclaringClass().getName()));
139138
}
140139

141140
return duplicationDetected;

spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,7 @@ private static Object asFlow(Publisher<?> publisher) {
851851
}
852852

853853
@SuppressWarnings("unchecked")
854+
@Nullable
854855
private static Object awaitSingleOrNull(Publisher<?> publisher, Object continuation) {
855856
return AwaitKt.awaitSingleOrNull(publisher, (Continuation<Object>) continuation);
856857
}

0 commit comments

Comments
 (0)