mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 16:39:29 +00:00
Catch InaccessibleObjectException next to IllegalAccessException
Closes gh-35190
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package org.springframework.beans;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InaccessibleObjectException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -144,7 +145,7 @@ public class DirectFieldAccessor extends AbstractNestablePropertyAccessor {
|
||||
ReflectionUtils.makeAccessible(this.field);
|
||||
return this.field.get(getWrappedInstance());
|
||||
}
|
||||
catch (IllegalAccessException ex) {
|
||||
catch (IllegalAccessException | InaccessibleObjectException ex) {
|
||||
throw new InvalidPropertyException(getWrappedClass(),
|
||||
this.field.getName(), "Field is not accessible", ex);
|
||||
}
|
||||
@@ -156,7 +157,7 @@ public class DirectFieldAccessor extends AbstractNestablePropertyAccessor {
|
||||
ReflectionUtils.makeAccessible(this.field);
|
||||
this.field.set(getWrappedInstance(), value);
|
||||
}
|
||||
catch (IllegalAccessException ex) {
|
||||
catch (IllegalAccessException | InaccessibleObjectException ex) {
|
||||
throw new InvalidPropertyException(getWrappedClass(), this.field.getName(),
|
||||
"Field is not accessible", ex);
|
||||
}
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@
|
||||
package org.springframework.beans.factory.support;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InaccessibleObjectException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.function.Supplier;
|
||||
@@ -184,7 +185,7 @@ public class SimpleInstantiationStrategy implements InstantiationStrategy {
|
||||
"Illegal arguments to factory method '" + factoryMethod.getName() + "'; " +
|
||||
"args: " + StringUtils.arrayToCommaDelimitedString(args), ex);
|
||||
}
|
||||
catch (IllegalAccessException ex) {
|
||||
catch (IllegalAccessException | InaccessibleObjectException ex) {
|
||||
throw new BeanInstantiationException(factoryMethod,
|
||||
"Cannot access factory method '" + factoryMethod.getName() + "'; is it public?", ex);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user