Skip to content

Commit

Permalink
Fix method may be null, and NullPointerException will be thrown in Me…
Browse files Browse the repository at this point in the history
…thodUtils (apache#7606)

* Fix method may be null, and NullPointerException will be thrown in MethodUtils(apache#7605)

* Update by review

Signed-off-by: xingrufei <xingrufei@sogou-inc.com>

Co-authored-by: xingrufei <xingrufei@sogou-inc.com>
  • Loading branch information
2 people authored and goodjava committed May 6, 2021
1 parent 0b39093 commit a3e51b1
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ static <T> T invokeMethod(Object object, String methodName, Object... methodPara
Method method = findMethod(type, methodName, parameterTypes);
T value = null;

if (method == null) {
throw new IllegalStateException(String.format("cannot find method %s,class: %s", methodName, type.getName()));
}

try {
ReflectUtils.makeAccessible(method);
value = (T) method.invoke(object, methodParameters);
Expand Down

0 comments on commit a3e51b1

Please sign in to comment.