From 4fa33dfece3e558447e151bdf1a0c963097496a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Thu, 26 Dec 2024 15:30:59 +0100 Subject: [PATCH] Refine null-safety in the spring-aop module See gh-34154 --- .../springframework/aop/aspectj/AbstractAspectJAdvice.java | 6 +++--- .../annotation/BeanFactoryAspectJAdvisorsBuilder.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/AbstractAspectJAdvice.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/AbstractAspectJAdvice.java index 6a297ed9d81..4af259af0d7 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/AbstractAspectJAdvice.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/AbstractAspectJAdvice.java @@ -570,7 +570,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence for (PointcutParameter parameter : parameterBindings) { String name = parameter.getName(); Integer index = this.argumentBindings.get(name); - Assert.notNull(index, "Index must not be null"); + Assert.state(index != null, "Index must not be null"); adviceInvocationArgs[index] = parameter.getBinding(); numBound++; } @@ -578,14 +578,14 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence // binding from returning clause if (this.returningName != null) { Integer index = this.argumentBindings.get(this.returningName); - Assert.notNull(index, "Index must not be null"); + Assert.state(index != null, "Index must not be null"); adviceInvocationArgs[index] = returnValue; numBound++; } // binding from thrown exception if (this.throwingName != null) { Integer index = this.argumentBindings.get(this.throwingName); - Assert.notNull(index, "Index must not be null"); + Assert.state(index != null, "Index must not be null"); adviceInvocationArgs[index] = ex; numBound++; } diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/BeanFactoryAspectJAdvisorsBuilder.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/BeanFactoryAspectJAdvisorsBuilder.java index ceb10d7f51f..990b588ffd8 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/BeanFactoryAspectJAdvisorsBuilder.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/BeanFactoryAspectJAdvisorsBuilder.java @@ -157,7 +157,7 @@ public class BeanFactoryAspectJAdvisorsBuilder { } else { MetadataAwareAspectInstanceFactory factory = this.aspectFactoryCache.get(aspectName); - Assert.notNull(factory, "Factory must not be null"); + Assert.state(factory != null, "Factory must not be null"); advisors.addAll(this.advisorFactory.getAdvisors(factory)); } }