Hi, I'm still working on https://issues.apache.org/jira/browse/SANDBOX-423 and I wanted to test if all the new exception get thrown correctly. For that reason I implemented a new class - ExceptionThrowingTestBean that properties and methods that throw exceptions when they get called. That way I can test if the InvocationTargetException gets wrapped correctly in.
I also implemented getters and setters with default, protected and private visibility. I expected to get an IllegalAccessException wrapped in a PropertyNotAccessibleException. Instead I got: java.lang.Exception: Unexpected exception, expected<org.apache.commons.beanutils2.exception.PropertyNotAccessibleException> but was<org.apache.commons.beanutils2.exception.PropertyNotFoundException> at org.junit.internal.runners.statements.ExpectException.evaluate(ExpectException.java:31) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: org.apache.commons.beanutils2.exception.PropertyNotFoundException: Property privateProperty not found in type org.apache.commons.beanutils2.testbeans.ExceptionThrowingTestBean at org.apache.commons.beanutils2.DefaultBeanAccessor.get(DefaultBeanAccessor.java:73) at org.apache.commons.beanutils2.GetPropertyTestCase.getPrivateProperty(GetPropertyTestCase.java:93) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.ExpectException.evaluate(ExpectException.java:22) ... 17 more Caused by: java.beans.IntrospectionException: Property 'privateProperty' does not exist in bean of type org.apache.commons.beanutils2.testbeans.ExceptionThrowingTestBean at org.apache.commons.beanutils2.DefaultBeanProperties.getPropertyDescriptor(DefaultBeanProperties.java:106) at org.apache.commons.beanutils2.DefaultBeanProperties.getReadPropertyMethod(DefaultBeanProperties.java:119) at org.apache.commons.beanutils2.DefaultBeanAccessor.get(DefaultBeanAccessor.java:65) ... 27 more I believe this is, because somewhere deep inside AccessibleObjectsRegistry everthing that is not public will be ignored (see line 352 in that class). So the AccessibleObjectsRegistry returns null for a property getter that is not accessible. Is this an acceptable behavior or do we have to change that? I believe that even if the user code has access to a method/property/constructor, the BU2 code won't have access. This is because client code may reside in the same class (private visibility), package (default visibility) or in an inheriting class (protected visibility), but the code that actually calls the methods is in BU2 and won't have access. Am I right? What do we do about that? My suggestion would be instead of returning null (line 354) in AccessibleObjectsRegistry, we could throw an IllegalAccessException that could be caught and wrapped later on. What do you think? Regrads, Benedikt --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org