commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niall Pemberton (JIRA)" <j...@apache.org>
Subject [jira] Resolved: (BEANUTILS-297) ConvertingWrapDynaBean hides cause exceptions
Date Sun, 23 Mar 2008 21:31:24 GMT

     [ https://issues.apache.org/jira/browse/BEANUTILS-297?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Niall Pemberton resolved BEANUTILS-297.
---------------------------------------

    Resolution: Fixed

Fixed - http://svn.apache.org/viewvc?view=rev&revision=640259

> ConvertingWrapDynaBean hides cause exceptions
> ---------------------------------------------
>
>                 Key: BEANUTILS-297
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-297
>             Project: Commons BeanUtils
>          Issue Type: Improvement
>          Components: DynaBean
>    Affects Versions: 1.8.0-BETA
>            Reporter: Alex Tkachev
>             Fix For: 1.8.0
>
>
> ConvertingWrapDynaBean.set(String,Object) method hides cause exception.
> This issue relates to BEANUTILS-23 that partially fixed this problem, by adding only
the message of the cause exception to IllegalArgumentException that is being thrown:
> try {
>             BeanUtils.copyProperty(instance, name, value);
>         } catch (InvocationTargetException ite) {
>             Throwable cause = ite.getTargetException();
>             throw new IllegalArgumentException
>                     ("Error setting property '" + name +
>                               "' nested exception - " + cause);
>         } catch (Throwable t) {
>             throw new IllegalArgumentException
>                     ("Error setting property '" + name +
>                               "', exception - " + t);
>         }
> I think that the cause exception (ie Throwable t) should be passed to newly generated
IllegalArgumentException (as second parameter). I don't really see no good in hiding it, it
only causes problems in identifying the cause why the setter has failed. Good example why
this is important is using Jelly. If for some reason the setter fails (for instance, some
illegal value was passed and nested exception was thrown by the setter), you have no way of
knowing the cause of it. The only way to find out the real cause is through debugging, setting
some complex conditional breakpoints.
> My proposed code is:
> try {
>             BeanUtils.copyProperty(instance, name, value);
>         } catch (InvocationTargetException ite) {
>             Throwable cause = ite.getTargetException();
>             throw new IllegalArgumentException
>                     ("Error setting property '" + name +
>                               "' nested exception - " + cause, t);
>         } catch (Throwable t) {
>             throw new IllegalArgumentException
>                     ("Error setting property '" + name +
>                               "', exception - " + t, t);
>         }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message