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

DefaultStepContext.get should directly handle certain types #252

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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 @@ -72,7 +72,20 @@ public abstract class DefaultStepContext extends StepContext {
* <p>{@inheritDoc}
*/
@Override public final <T> T get(Class<T> key) throws IOException, InterruptedException {
T value = doGet(key);
T value = null;
if (Run.class.isAssignableFrom(key)) {
value = castOrNull(key, getExecution().getOwner().getExecutable());
} else if (Job.class.isAssignableFrom(key)) {
value = castOrNull(key, get(Run.class).getParent());
} else if (FlowExecution.class.isAssignableFrom(key)) {
value = castOrNull(key,getExecution());
} else if (FlowNode.class.isAssignableFrom(key)) {
value = castOrNull(key, getNode());
}
if (value != null) {
return value;
}
value = doGet(key);
if (key == EnvVars.class) {
Run<?,?> run = get(Run.class);
EnvironmentAction a = run == null ? null : run.getAction(EnvironmentAction.class);
Expand Down Expand Up @@ -100,14 +113,6 @@ public abstract class DefaultStepContext extends StepContext {
}
*/
return castOrNull(key, n);
} else if (Run.class.isAssignableFrom(key)) {
return castOrNull(key, getExecution().getOwner().getExecutable());
} else if (Job.class.isAssignableFrom(key)) {
return castOrNull(key, get(Run.class).getParent());
} else if (FlowExecution.class.isAssignableFrom(key)) {
return castOrNull(key,getExecution());
} else if (FlowNode.class.isAssignableFrom(key)) {
return castOrNull(key, getNode());
} else {
// unrecognized key
return null;
Expand Down