You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (Jira)" <ji...@apache.org> on 2025/01/07 14:07:01 UTC
[jira] [Updated] (BEANUTILS-91) PropertyUtils.copyProperties throws exceptions contrary to documentation
[ https://issues.apache.org/jira/browse/BEANUTILS-91?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gary D. Gregory updated BEANUTILS-91:
-------------------------------------
Fix Version/s: 2.0.0-M2
(was: 2.0.0-M1)
> PropertyUtils.copyProperties throws exceptions contrary to documentation
> ------------------------------------------------------------------------
>
> Key: BEANUTILS-91
> URL: https://issues.apache.org/jira/browse/BEANUTILS-91
> Project: Commons BeanUtils
> Issue Type: Bug
> Components: Bean / Property Utils
> Affects Versions: 1.5
> Environment: Operating System: other
> Platform: Other
> Reporter: Arun Thomas
> Priority: Minor
> Fix For: 2.0.0-M2
>
> Attachments: ASF.LICENSE.NOT.GRANTED--PropertyUtilsTest.java, ASF.LICENSE.NOT.GRANTED--temp.java
>
>
> 1) The copyProperties method is documented as throwing IllegalAccessException
> when access to a particular method is not available. In fact, because
> internally the methods to be invoked are filtered for accessiblity
> (MethodUtils.getAccessibleMethod) before invocation, the possible sources of
> the IllegalAccessException will never actually throw an
> IllegalAccessException.
> Worse, however, is that the result of a failure to return an accessible method
> is actually taken as occasion to throw a NoSuchMethodException instead.
> 2) The copyProperties method is also documented as throwing
> NoSuchMethodException when a method cannot be found. I'm not sure if this is
> an error or not, but a NoSuchMethodException is not thrown when a property of
> the same name but a different type is found. (This would, to my mind, be an
> occasion of not finding an appropriate method for the setter to function
> properly).
> Unfortunately, again, there is something worse. In this case, instead of
> throwing NoSuchMethodException, an IllegalArgumentException is thrown.
> IllegalArgumentException, as a runtime exception, might have been
> appropriateexcept for the fact that it is explicitly documented as being
> thrown when either the source or the destination arguments are null - no other
> reasons for throwing this are detailed. (Wouldn't NullPointerException be
> more appropriate anyway? Curious about the decision to recast this to
> IllegalArgumentException....) While this is certainly allowed for
> RuntimeExceptions, in this case, the documentation is quite misleading about
> what is actually to be expected.
> I'll attach a JUnitTestCase that captures both of these items.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)