spring-projects/spring-framework · error · IllegalArgumentException
Expecting {} arguments to proceed, but was passed {} argumen
Error message
Expecting {} arguments to proceed, but was passed {} arguments What it means
Thrown by MethodInvocationProceedingJoinPoint.proceed(Object[]) when the argument array length differs from the number of arguments of the underlying method invocation. ProceedingJoinPoint.proceed(values) must replace ALL arguments, so the counts must match exactly.
Source
Thrown at spring-aop/src/main/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPoint.java:89
this.methodInvocation = methodInvocation;
}
@Override
public void set$AroundClosure(AroundClosure aroundClosure) {
throw new UnsupportedOperationException();
}
@Override
public @Nullable Object proceed() throws Throwable {
return this.methodInvocation.invocableClone().proceed();
}
@Override
public @Nullable Object proceed(Object[] arguments) throws Throwable {
Assert.notNull(arguments, "Argument array passed to proceed cannot be null");
if (arguments.length != this.methodInvocation.getArguments().length) {
throw new IllegalArgumentException("Expecting " +
this.methodInvocation.getArguments().length + " arguments to proceed, " +
"but was passed " + arguments.length + " arguments");
}
this.methodInvocation.setArguments(arguments);
return this.methodInvocation.invocableClone(arguments).proceed();
}
/**
* Returns the Spring AOP proxy. Cannot be {@code null}.
*/
@Override
public Object getThis() {
return this.methodInvocation.getProxy();
}
/**
* Returns the Spring AOP target. May be {@code null} if there is no target.
*/View on GitHub (pinned to e8729d0438)
Solutions
- Pass an array whose length equals pjp.getArgs().length (the original argument count).
- To modify a single argument, clone the existing args and replace the desired index: Object[] args = pjp.getArgs(); args[i] = newValue; pjp.proceed(args);
- If you only need to proceed without changing arguments, call the no-arg pjp.proceed().
Example fix
// before
@Around("execution(* com.acme.*.*(..))")
public Object around(ProceedingJoinPoint pjp) throws Throwable {
return pjp.proceed(new Object[]{"only-one"}); // throws if method takes 2 args
}
// after
@Around("execution(* com.acme.*.*(..))")
public Object around(ProceedingJoinPoint pjp) throws Throwable {
Object[] args = pjp.getArgs();
args[0] = "replaced";
return pjp.proceed(args);
} Defensive patterns
Strategy: validation
Validate before calling
if (newArgs.length != pjp.getArgs().length) {
throw new IllegalArgumentException("arg count mismatch: expected " + pjp.getArgs().length);
} Prevention
- Clone pjp.getArgs() and replace individual elements rather than building a fresh array.
- Call the no-arg pjp.proceed() when not modifying arguments.
- Update advice when the target method signature changes.
When it happens
Trigger: Inside an @Around advice calling pjp.proceed(newArgs) where newArgs.length != the advised method's argument count.
Common situations: Advice that modifies only a subset of arguments but passes a partial array; advice that appends or removes an argument; refactor of the target method signature without updating the advice.
Related errors
- ProceedingJoinPoint is only supported for around advice
- MethodInvocation is not a Spring ProxyMethodInvocation: {}
- MethodInvocation is not a Spring ProxyMethodInvocation: {}
- 'argumentNames' property of AbstractAspectJAdvice contains a
- Only afterReturning advice can be used to bind a return valu
AI-assisted analysis of spring-projects/spring-framework@e8729d0438 (2026-08-04).
Data as JSON: /data/errors/6121d38ff27a871c.json.
Report an issue: GitHub.