Alwaysgaurav1 opened a new pull request, #1861: URL: https://github.com/apache/commons-lang/pull/1861
### Summary In commit `5dede14ab` (#1828), a check `parameterTypes.length >= methodParameterTypes.length - 1` was added to `MemberUtils.isMatchingExecutable` to reject varargs candidates with too few arguments. However, in Java reflection and Commons Lang reflection utilities, `parameterTypes` may be `null` to represent an empty parameter list (e.g. `MethodUtils.getMatchingAccessibleMethod(cls, name, (Class<?>[]) null)` or `ConstructorUtils.getMatchingAccessibleConstructor(cls, (Class<?>[]) null)`). When `parameterTypes` is `null` and a candidate method/constructor is varargs, calling `.length` threw a `NullPointerException`. Similarly, `MemberUtils.getTotalTransformationCost` evaluated `srcArgs.length` without checking for `null`, leading to potential NPEs during candidate fit comparison when `actual` argument types are `null`. ### Changes - Normalized `parameterTypes` using `ArrayUtils.nullToEmpty(parameterTypes)` in `MemberUtils.isMatchingExecutable`. - Normalized `srcArgs` using `ArrayUtils.nullToEmpty(srcArgs)` in `MemberUtils.getTotalTransformationCost`. - Added unit tests in `MethodUtilsTest` and `ConstructorUtilsTest` verifying that passing `null` parameter types to methods/constructors with varargs candidates does not throw `NullPointerException`. ### Test Results All 679 tests in `org.apache.commons.lang3.reflect` pass cleanly. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
