feat: support method job direct return ProcessResult #798

This commit is contained in:
tjq 2024-11-22 21:05:23 +08:00
parent 4fe2d7fdf1
commit 4e84bc60d7

View File

@ -24,6 +24,12 @@ class MethodBasicProcessor implements BasicProcessor {
public ProcessResult process(TaskContext context) throws Exception { public ProcessResult process(TaskContext context) throws Exception {
try { try {
Object result = method.invoke(bean, context); Object result = method.invoke(bean, context);
// 支持直接返回 ProcessResult https://github.com/PowerJob/PowerJob/issues/798
if (result instanceof ProcessResult) {
return (ProcessResult) result;
}
return new ProcessResult(true, JsonUtils.toJSONString(result)); return new ProcessResult(true, JsonUtils.toJSONString(result));
} catch (InvocationTargetException ite) { } catch (InvocationTargetException ite) {
ExceptionUtils.rethrow(ite.getTargetException()); ExceptionUtils.rethrow(ite.getTargetException());