{"id":"6121d38ff27a871c","repo":"spring-projects/spring-framework","slug":"expecting-arguments-to-proceed-but-was-passed","errorCode":null,"errorMessage":"Expecting {} arguments to proceed, but was passed {} arguments","messagePattern":"Expecting (.+?) arguments to proceed, but was passed (.+?) arguments","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-aop/src/main/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPoint.java","lineNumber":89,"sourceCode":"\t\tthis.methodInvocation = methodInvocation;\n\t}\n\n\n\t@Override\n\tpublic void set$AroundClosure(AroundClosure aroundClosure) {\n\t\tthrow new UnsupportedOperationException();\n\t}\n\n\t@Override\n\tpublic @Nullable Object proceed() throws Throwable {\n\t\treturn this.methodInvocation.invocableClone().proceed();\n\t}\n\n\t@Override\n\tpublic @Nullable Object proceed(Object[] arguments) throws Throwable {\n\t\tAssert.notNull(arguments, \"Argument array passed to proceed cannot be null\");\n\t\tif (arguments.length != this.methodInvocation.getArguments().length) {\n\t\t\tthrow new IllegalArgumentException(\"Expecting \" +\n\t\t\t\t\tthis.methodInvocation.getArguments().length + \" arguments to proceed, \" +\n\t\t\t\t\t\"but was passed \" + arguments.length + \" arguments\");\n\t\t}\n\t\tthis.methodInvocation.setArguments(arguments);\n\t\treturn this.methodInvocation.invocableClone(arguments).proceed();\n\t}\n\n\t/**\n\t * Returns the Spring AOP proxy. Cannot be {@code null}.\n\t */\n\t@Override\n\tpublic Object getThis() {\n\t\treturn this.methodInvocation.getProxy();\n\t}\n\n\t/**\n\t * Returns the Spring AOP target. May be {@code null} if there is no target.\n\t */","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/spring-projects/spring-framework/blob/e8729d043887bf0d0baf91e062e909b56eb2b708/spring-aop/src/main/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPoint.java#L71-L107","documentation":"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.","triggerScenarios":"Inside an @Around advice calling pjp.proceed(newArgs) where newArgs.length != the advised method's argument count.","commonSituations":"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.","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()."],"exampleFix":"// before\n@Around(\"execution(* com.acme.*.*(..))\")\npublic Object around(ProceedingJoinPoint pjp) throws Throwable {\n    return pjp.proceed(new Object[]{\"only-one\"}); // throws if method takes 2 args\n}\n\n// after\n@Around(\"execution(* com.acme.*.*(..))\")\npublic Object around(ProceedingJoinPoint pjp) throws Throwable {\n    Object[] args = pjp.getArgs();\n    args[0] = \"replaced\";\n    return pjp.proceed(args);\n}","handlingStrategy":"validation","validationCode":"if (newArgs.length != pjp.getArgs().length) {\n    throw new IllegalArgumentException(\"arg count mismatch: expected \" + pjp.getArgs().length);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["spring-aop","aspectj","around-advice","arguments"],"analyzedSha":"e8729d043887bf0d0baf91e062e909b56eb2b708","analyzedAt":"2026-08-04T19:07:39.725Z","schemaVersion":2}