Skip to content

Commit

Permalink
Refine null-safety in the spring-expression module
Browse files Browse the repository at this point in the history
Closes gh-34156
  • Loading branch information
sdeleuze committed Dec 26, 2024
1 parent 4747ab6 commit be11e73
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public String toDetailedString() {
* that caused the failure.
* @since 4.0
*/
@SuppressWarnings("NullAway")
@SuppressWarnings("NullAway") // Dataflow analysis limitation
public String getSimpleMessage() {
return super.getMessage();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ private TypedValue executeFunctionViaMethod(ExpressionState state, Method method
* @throws EvaluationException if there is any problem invoking the method
* @since 6.1
*/
@SuppressWarnings("NullAway") // TODO Remove when NullAway 0.12.2 is released, see https://github.com/uber/NullAway/pull/1089
private TypedValue executeFunctionViaMethodHandle(ExpressionState state, MethodHandle methodHandle) throws EvaluationException {
Object[] functionArgs = getArguments(state);
MethodType declaredParams = methodHandle.type();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ private DescriptorComparison(boolean areNumbers, boolean areCompatible, char com
* @param rightActualDescriptor the dynamic/runtime right object descriptor
* @return a DescriptorComparison object indicating the type of compatibility, if any
*/
@SuppressWarnings("NullAway")
@SuppressWarnings("NullAway") // Dataflow analysis limitation
public static DescriptorComparison checkNumericCompatibility(
@Nullable String leftDeclaredDescriptor, @Nullable String rightDeclaredDescriptor,
@Nullable String leftActualDescriptor, @Nullable String rightActualDescriptor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ private void checkExpressionLength(String string) {
// | (DEFAULT^ logicalOrExpression)
// | (QMARK^ expression COLON! expression)
// | (ELVIS^ expression))?;
@SuppressWarnings("NullAway")
@SuppressWarnings("NullAway") // Not null assertion performed in SpelNodeImpl constructor
private @Nullable SpelNodeImpl eatExpression() {
SpelNodeImpl expr = eatLogicalOrExpression();
Token t = peekToken();
Expand Down Expand Up @@ -273,7 +273,7 @@ private void checkExpressionLength(String string) {
}

//sumExpression: productExpression ( (PLUS^ | MINUS^) productExpression)*;
@SuppressWarnings("NullAway")
@SuppressWarnings("NullAway") // Not null assertion performed in SpelNodeImpl constructor
private @Nullable SpelNodeImpl eatSumExpression() {
SpelNodeImpl expr = eatProductExpression();
while (peekToken(TokenKind.PLUS, TokenKind.MINUS, TokenKind.INC)) {
Expand Down Expand Up @@ -311,7 +311,7 @@ else if (t.kind == TokenKind.MOD) {
}

// powerExpr : unaryExpression (POWER^ unaryExpression)? (INC || DEC) ;
@SuppressWarnings("NullAway")
@SuppressWarnings("NullAway") // Not null assertion performed in SpelNodeImpl constructor
private @Nullable SpelNodeImpl eatPowerIncDecExpression() {
SpelNodeImpl expr = eatUnaryExpression();
if (peekToken(TokenKind.POWER)) {
Expand All @@ -331,7 +331,7 @@ else if (t.kind == TokenKind.MOD) {
}

// unaryExpression: (PLUS^ | MINUS^ | BANG^ | INC^ | DEC^) unaryExpression | primaryExpression ;
@SuppressWarnings("NullAway")
@SuppressWarnings("NullAway") // Not null assertion performed in SpelNodeImpl constructor
private @Nullable SpelNodeImpl eatUnaryExpression() {
if (peekToken(TokenKind.NOT, TokenKind.PLUS, TokenKind.MINUS)) {
Token t = takeToken();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public boolean canRead(EvaluationContext context, @Nullable Object target, Strin
}

@Override
@SuppressWarnings("NullAway")
@SuppressWarnings("NullAway") // Dataflow analysis limitation
public TypedValue read(EvaluationContext context, @Nullable Object target, String name) throws AccessException {
Assert.state(target != null, "Target must not be null");
Class<?> type = (target instanceof Class<?> clazz ? clazz : target.getClass());
Expand Down Expand Up @@ -507,7 +507,7 @@ protected String getPropertyMethodSuffix(String propertyName) {
* <p>Note: An optimized accessor is currently only usable for read attempts.
* Do not call this method if you need a read-write accessor.
*/
@SuppressWarnings("NullAway")
@SuppressWarnings("NullAway") // Dataflow analysis limitation
public PropertyAccessor createOptimalAccessor(EvaluationContext context, @Nullable Object target, String name) {
// Don't be clever for arrays or a null target...
if (target == null) {
Expand Down

0 comments on commit be11e73

Please sign in to comment.