-
Notifications
You must be signed in to change notification settings - Fork 1.1k
GH-10083 Add Nullability to the mapping package #10382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Related to: spring-projects#10083 * AbstractHeaderMapper.java - Enhanced null safety by adding @nullable annotations to fields and methods. * Updated method signatures to match those in AbstractHeaderMapper for the following classes: - DefaultAmqpHeaderMapper.java - DefaultSoapHeaderMapper.java - DefaultXmppHeaderMapper.java
f349850
to
14a2d7c
Compare
...gration-core/src/main/java/org/springframework/integration/mapping/AbstractHeaderMapper.java
Outdated
Show resolved
Hide resolved
...egration-core/src/main/java/org/springframework/integration/mapping/support/JsonHeaders.java
Outdated
Show resolved
Hide resolved
Add Contract for buildResolvableType where the first param can be anything, and if the 2 or 3 value is not null, it will return a not null.
* @since 5.2.4 | ||
*/ | ||
public static ResolvableType buildResolvableType(@Nullable Class<?> targetClass, @Nullable Class<?> contentClass, | ||
@Contract("_, !null, _ -> !null; _, _, !null -> !null") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong.
The method does not return null
at all.
See getClassForValue()
.
That's where the @Contract
has to be.
Class<?> keyClass = getClassForValue(classLoader, keyClassValue); | ||
Class<?> contentClass = getClassForValue(classLoader, contentClassValue); | ||
|
||
Assert.notNull(targetClass, "targetClass must not be null"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you fix getClassForValue()
with the @Contract
, this is not necessary.
return buildResolvableType(targetClass, contentClass, keyClass); | ||
} | ||
|
||
@Nullable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, move this next to the return type.
Remove associated Assert.state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGMT.
Will merge when build is green.
Related to: #10083