From 7aa73792a184a030296de00e0cbac6122496f68d Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 7 Nov 2019 22:43:24 +0100 Subject: [PATCH] Use Method.getParameterCount() when full type array is never needed --- .../springframework/beans/PropertyDescriptorUtils.java | 5 ++--- .../beans/factory/support/DisposableBeanAdapter.java | 8 ++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java b/spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java index c5ac50cb4b4..aa9909822d1 100644 --- a/spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java +++ b/spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,8 +66,7 @@ abstract class PropertyDescriptorUtils { Class propertyType = null; if (readMethod != null) { - Class[] params = readMethod.getParameterTypes(); - if (params.length != 0) { + if (readMethod.getParameterCount() != 0) { throw new IntrospectionException("Bad read method arg count: " + readMethod); } propertyType = readMethod.getReturnType(); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java index 3a2f8ddd602..169d103c3a8 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -309,9 +309,9 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable { * assuming a "force" parameter), else logging an error. */ private void invokeCustomDestroyMethod(final Method destroyMethod) { - Class[] paramTypes = destroyMethod.getParameterTypes(); - final Object[] args = new Object[paramTypes.length]; - if (paramTypes.length == 1) { + int paramCount = destroyMethod.getParameterCount(); + final Object[] args = new Object[paramCount]; + if (paramCount == 1) { args[0] = Boolean.TRUE; } if (logger.isDebugEnabled()) {