Skip to content

Commit bdb1a81

Browse files
committed
Use Method.getParameterCount() when full type array is never needed
1 parent c2e7b63 commit bdb1a81

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,9 @@ private Method findDestroyMethod(String name) {
311311
* assuming a "force" parameter), else logging an error.
312312
*/
313313
private void invokeCustomDestroyMethod(final Method destroyMethod) {
314-
Class<?>[] paramTypes = destroyMethod.getParameterTypes();
315-
final Object[] args = new Object[paramTypes.length];
316-
if (paramTypes.length == 1) {
314+
int paramCount = destroyMethod.getParameterCount();
315+
final Object[] args = new Object[paramCount];
316+
if (paramCount == 1) {
317317
args[0] = Boolean.TRUE;
318318
}
319319
if (logger.isTraceEnabled()) {

0 commit comments

Comments
 (0)