Skip to content

Commit 7aa7379

Browse files
committed
Use Method.getParameterCount() when full type array is never needed
1 parent 9529dfb commit 7aa7379

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -66,8 +66,7 @@ public static Class<?> findPropertyType(@Nullable Method readMethod, @Nullable M
6666
Class<?> propertyType = null;
6767

6868
if (readMethod != null) {
69-
Class<?>[] params = readMethod.getParameterTypes();
70-
if (params.length != 0) {
69+
if (readMethod.getParameterCount() != 0) {
7170
throw new IntrospectionException("Bad read method arg count: " + readMethod);
7271
}
7372
propertyType = readMethod.getReturnType();

spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -309,9 +309,9 @@ private Method findDestroyMethod(String name) {
309309
* assuming a "force" parameter), else logging an error.
310310
*/
311311
private void invokeCustomDestroyMethod(final Method destroyMethod) {
312-
Class<?>[] paramTypes = destroyMethod.getParameterTypes();
313-
final Object[] args = new Object[paramTypes.length];
314-
if (paramTypes.length == 1) {
312+
int paramCount = destroyMethod.getParameterCount();
313+
final Object[] args = new Object[paramCount];
314+
if (paramCount == 1) {
315315
args[0] = Boolean.TRUE;
316316
}
317317
if (logger.isDebugEnabled()) {

0 commit comments

Comments
 (0)