mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Catch InaccessibleObjectException next to IllegalAccessException
Closes gh-35190
This commit is contained in:
+3
-2
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.context.event;
|
||||
|
||||
import java.lang.reflect.InaccessibleObjectException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
@@ -374,8 +375,8 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
|
||||
return null;
|
||||
}
|
||||
|
||||
ReflectionUtils.makeAccessible(this.method);
|
||||
try {
|
||||
ReflectionUtils.makeAccessible(this.method);
|
||||
if (KotlinDetector.isSuspendingFunction(this.method)) {
|
||||
return CoroutinesUtils.invokeSuspendingFunction(this.method, bean, args);
|
||||
}
|
||||
@@ -385,7 +386,7 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
|
||||
assertTargetBean(this.method, bean, args);
|
||||
throw new IllegalStateException(getInvocationErrorMessage(bean, ex.getMessage(), args), ex);
|
||||
}
|
||||
catch (IllegalAccessException ex) {
|
||||
catch (IllegalAccessException | InaccessibleObjectException ex) {
|
||||
throw new IllegalStateException(getInvocationErrorMessage(bean, ex.getMessage(), args), ex);
|
||||
}
|
||||
catch (InvocationTargetException ex) {
|
||||
|
||||
+2
-1
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.scheduling.annotation;
|
||||
|
||||
import java.lang.reflect.InaccessibleObjectException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
@@ -173,7 +174,7 @@ abstract class ScheduledAnnotationReactiveSupport {
|
||||
"Cannot obtain a Publisher-convertible value from the @Scheduled reactive method",
|
||||
ex.getTargetException());
|
||||
}
|
||||
catch (IllegalAccessException ex) {
|
||||
catch (IllegalAccessException | InaccessibleObjectException ex) {
|
||||
throw new IllegalArgumentException(
|
||||
"Cannot obtain a Publisher-convertible value from the @Scheduled reactive method", ex);
|
||||
}
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@
|
||||
package org.springframework.scripting.groovy;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InaccessibleObjectException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import groovy.lang.GroovyClassLoader;
|
||||
@@ -341,7 +342,7 @@ public class GroovyScriptFactory implements ScriptFactory, BeanFactoryAware, Bea
|
||||
throw new ScriptCompilationException(
|
||||
scriptSource, "Unable to instantiate Groovy script class: " + scriptClass.getName(), ex);
|
||||
}
|
||||
catch (IllegalAccessException ex) {
|
||||
catch (IllegalAccessException | InaccessibleObjectException ex) {
|
||||
throw new ScriptCompilationException(
|
||||
scriptSource, "Could not access Groovy script constructor: " + scriptClass.getName(), ex);
|
||||
}
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@
|
||||
package org.springframework.scripting.support;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InaccessibleObjectException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import javax.script.Invocable;
|
||||
@@ -172,7 +173,7 @@ public class StandardScriptFactory implements ScriptFactory, BeanClassLoaderAwar
|
||||
throw new ScriptCompilationException(
|
||||
scriptSource, "Unable to instantiate script class: " + scriptClass.getName(), ex);
|
||||
}
|
||||
catch (IllegalAccessException ex) {
|
||||
catch (IllegalAccessException | InaccessibleObjectException ex) {
|
||||
throw new ScriptCompilationException(
|
||||
scriptSource, "Could not access script constructor: " + scriptClass.getName(), ex);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user