Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@ public class ActionExecutorUtil {
public static final String SCRIPT = "script" ;
public static final String RETURN_OBJECT = "returnObject" ;
private static final String EXECUTE_EXPRESSION =
"java.lang.Class<?> actionExecutorClass = java.lang.ClassLoader.getSystemClassLoader().loadClass(\"com.runtime.pivot.agent.ActionExecutor\");\n" +
"java.lang.Class<?> actionExecutorClass = null;\n" +
"java.lang.ClassLoader contextClassLoader = java.lang.Thread.currentThread().getContextClassLoader();\n" +
"if (contextClassLoader != null) {\n" +
" try {\n" +
" actionExecutorClass = contextClassLoader.loadClass(\"com.runtime.pivot.agent.ActionExecutor\");\n" +
" } catch (java.lang.ClassNotFoundException ignore) {\n" +
Comment on lines +19 to +20
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Fall back to system loader when context load fails to link

contextClassLoader.loadClass("com.runtime.pivot.agent.ActionExecutor") is only wrapped for ClassNotFoundException, but loadClass can also fail with linkage errors (for example NoClassDefFoundError/LinkageError when the class exists in that loader but its dependencies are incompatible). In that case this code aborts before reaching the system-loader fallback, so debugger actions still fail in mixed classloader setups instead of recovering. Treating linkage failures as a fallback condition here would preserve the intended behavior.

Useful? React with 👍 / 👎.

" }\n" +
"}\n" +
"if (actionExecutorClass == null) {\n" +
" actionExecutorClass = java.lang.ClassLoader.getSystemClassLoader().loadClass(\"com.runtime.pivot.agent.ActionExecutor\");\n" +
"}\n" +
"java.lang.reflect.Method method = actionExecutorClass.getMethod(\"execute\",String.class,Object[].class);\n" +
"Object "+RETURN_OBJECT+" = method.invoke(null,\"{"+ACTION_TYPE+"}\",new Object[]{{"+ARGS+"}});\n" +
"{"+SCRIPT+"};";
Expand Down
Loading