DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=18811>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=18811 Misleading error message in ConvertingWrapDynaBean ------- Additional Comments From [EMAIL PROTECTED] 2004-07-04 11:20 ------- Just adding t.getMessage to the string is not solving the catch of exceptions that should be passed on. Nor is it helping much in the cases where a NullPointerException is thrown with an uninformative message. Most importantly, ThreadDeath should *never* be caught (instanceof Error). I believe we can safely pass any errors and runtime exceptions that were thrown in the invoked message. Note that the WrapDynaBean setters also lack a better exception handling. Here is a new patch I'd like to propose: Index: ConvertingWrapDynaBean.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/ConvertingWrapDynaBean.java,v retrieving revision 1.7 diff -u -r1.7 ConvertingWrapDynaBean.java --- ConvertingWrapDynaBean.java 28 Feb 2004 13:18:33 -0000 1.7 +++ ConvertingWrapDynaBean.java 4 Jul 2004 11:09:57 -0000 @@ -16,6 +16,8 @@ package org.apache.commons.beanutils; +import java.lang.reflect.InvocationTargetException; + /** * <p>Implementation of <code>DynaBean</code> that wraps a standard JavaBean @@ -67,9 +69,19 @@ try { BeanUtils.copyProperty(instance, name, value); - } catch (Throwable t) { + } catch (InvocationTargetException e) { + Throwable cause = e.getCause(); + if (cause instanceof RuntimeException) { + throw (RuntimeException)cause; + } else if (cause instanceof Error) { + throw (Error)cause; + } else { + throw new RuntimeException( + "Property setter '" + name + "' nested exception:" + cause); + } + } catch (IllegalAccessException t) { throw new IllegalArgumentException - ("Property '" + name + "' has no write method"); + ("Property '" + name + "' has no accessible write method"); } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
