Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

对于返回参数不是Result类型的@JobRunnerItem 方法避免执行不到与异常 #436

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -18,25 +18,32 @@ public static JobRunner build(final Object targetObject, final Method targetMeth
return new JobRunner() {
@Override
public Result run(JobContext jobContext) throws Throwable {
Object resultObj;
if (pTypes == null || pTypes.length == 0) {
return (Result) targetMethod.invoke(targetObject);
}
Object[] pTypeValues = new Object[pTypes.length];

for (int i = 0; i < pTypes.length; i++) {
if (pTypes[i] == Job.class) {
pTypeValues[i] = jobContext.getJob();
} else if (pTypes[i] == JobContext.class) {
pTypeValues[i] = jobContext;
} else {
pTypeValues[i] = null;
resultObj = targetMethod.invoke(targetObject);
}else{

Object[] pTypeValues = new Object[pTypes.length];

for (int i = 0; i < pTypes.length; i++) {
if (pTypes[i] == Job.class) {
pTypeValues[i] = jobContext.getJob();
} else if (pTypes[i] == JobContext.class) {
pTypeValues[i] = jobContext;
} else {
pTypeValues[i] = null;
}
}

resultObj = targetMethod.invoke(targetObject, pTypeValues);
}

Class<?> returnType = targetMethod.getReturnType();
if (returnType != Result.class) {
return new Result(Action.EXECUTE_SUCCESS);
}
return (Result) targetMethod.invoke(targetObject, pTypeValues);

return (Result) resultObj;
}
};
}
Expand Down