Uploaded image for project: 'Commons BeanUtils'
  1. Commons BeanUtils
  2. BEANUTILS-380

BeanMap methods should initialize the root cause of exceptions that are thrown when running on JDK 1.4+

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.8.3
    • 1.9.5
    • Bean-Collections
    • None

    Description

      The following code

      import org.apache.commons.beanutils.BeanMap;
      
      import SetterTest.SetterThrownException;
      
      public class SetterTest {
      
      	public static void main(String[] args) {
      		
      		try {
      			BeanMap map = new BeanMap(new SetterTest());
      			map.put("value", "value");
      		} catch (Exception e) {
      			e.printStackTrace();
      		}
      	}
      
      	public void setValue(String value) throws SetterThrownException {
      		throw new SetterThrownException("I want to see this in the stacktrace");
      	}
      	
      	
      	class SetterThrownException extends Exception
      	{
      		
      		public SetterThrownException(String message) {
      			super(message);
      		}
      		
      	}
      
      }
      

      will return this stacktrace

      java.lang.IllegalArgumentException
      	at org.apache.commons.beanutils.BeanMap.put(BeanMap.java:438)
      	at SetterTest.main(SetterTest.java:9)
      

      I think it should show the root cause of the exception

      java.lang.IllegalArgumentException: java.lang.reflect.InvocationTargetException
      	at org.apache.commons.beanutils.BeanMap.put(BeanMap.java:438)
      	at SetterTest.main(SetterTest.java:11)
      Caused by: java.lang.reflect.InvocationTargetException
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at java.lang.reflect.Method.invoke(Method.java:597)
      	at org.apache.commons.beanutils.BeanMap.put(BeanMap.java:431)
      	... 1 more
      Caused by: SetterTest$SetterThrownException: I want to see this in the stacktrace
      	at SetterTest.setValue(SetterTest.java:18)
      	... 6 more
      

      Attachments

        1. BEANUTILS-380.patch
          3 kB
          Brendan Nolan

        Activity

          People

            niallp Niall Pemberton
            brendan.nolan Brendan Nolan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: