-
Notifications
You must be signed in to change notification settings - Fork 128
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
Removing uses of Guice #28
Conversation
|
||
/** Placeholder for getRequiredContext. */ | ||
@StepContextParameter private transient Run<?,?> run; | ||
@StepContextParameter private transient TaskListener listener; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the evil tricks that is no longer necessary.
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@Inject(optional=true) private transient SleepStep step; | ||
@StepContextParameter private transient TaskListener listener; | ||
private transient final SleepStep step; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternately could have kept just the result of step.unit.toMillis(step.time)
.
This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation. |
return getContext().get(TaskListener.class); | ||
} catch (Exception x) { | ||
LOGGER.log(Level.WARNING, null, x); | ||
return TaskListener.NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using injection, there were two ways StepContext.get
errors were handled: AbstractStepImpl.start
would throw up the exception, which we could still do in a StepExecution
constructor; and AbstractStepExecutionImpl.onResume
would send the exception to StepContext.onFailure
(but presumably leave the field null, without preventing the rest of an onResume
override from running—perhaps the root cause of JENKINS-34021 and the still-open JENKINS-37486).
This idiom is more verbose but clearer—the step gets to decide what to do.
Alternately, we could change onResume
to throw Exception
. (Would still be binary-compatible.) FlowExecutionList.ItemListenerImpl.onLoaded
would then need to catch exceptions and call StepContext.onFailure
. Like AbstractStepExecutionImpl
, this would rely on transient
fields holding the contextual object; the improvement would be that a failure in StepContext.get
would stop anything else in onResume
(such as setupTimer
here) from running.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed JENKINS-40161 to track the latter proposal.
@StepContextParameter private transient Launcher launcher; | ||
@StepContextParameter private transient TaskListener listener; | ||
@SuppressFBWarnings(value="SE_TRANSIENT_FIELD_NOT_RESTORED", justification="Only used when starting.") | ||
private transient final SimpleBuildStep delegate; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have the option of simplifying StepExecution
state, especially in cases where the Step
had only one field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐝
🐝 |
|
||
public static class Execution extends AbstractStepExecutionImpl { | ||
public static class Execution extends StepExecution { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likely to cause JENKINS-40909.
Downstream of jenkinsci/workflow-step-api-plugin#15.
@reviewbybees