-
-
Notifications
You must be signed in to change notification settings - Fork 141
WorkflowRun.reload must call super.onLoad
#510
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
Conversation
| assertThat("right owner after reload", b.getExecution().getOwner(), is(b.asFlowExecutionOwner())); | ||
| a = b.getAction(A.class); | ||
| assertThat("not attached in this instance", a.attached, is(0)); | ||
| assertThat("loaded", a.loaded, is(1)); |
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.
Without patch, this is zero, as in observed stack traces.
dwnusbaum
left a comment
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.
Seems fine if it works and passes PCT
| * Unfortunately {@link #reload} can be called either directly or implicitly via {@link #WorkflowRun(WorkflowJob, File)} | ||
| * and this is the only way to tell which of those cases this is. | ||
| */ | ||
| private transient volatile boolean loaded; |
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.
FWIW, I find the naming of this field very confusing given the use down below. I guess the clearer thing would be to set the flag only from WorkflowRun(WorkflowJob, File), then change the name (to something like willCallOnLoadImplicitly) and invert the condition in reload here, but IIUC we can't do that because we have to call super(), which calls reload(), so we can't set a field in time.
I think "Early assignment to fields" in https://openjdk.org/jeps/492 would allow us to use a more straightforward approach here, right?
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.
the clearer thing would be to
I went through the same thought process, and yes I think JEP-492 would be helpful here.
Amending #472 as I think I finally tracked down the problem with
TestResultActionthat I was trying without success to fix in #485. Ultimately this feels like a bug, or at least an anomaly, in core since jenkinsci/jenkins@50f7aa3 defined theRun.reloadmethod with a vague comment saying thatonLoadwas not to be called sincereloadwould be used from oneRunconstructor overload (which it is; in this PR that call site will not activate the patched behavior) but also that some unidentified uses do not want to be called multiple times. The latter part makes no sense, since this is on a freshRunAction2instance each time, and due to lazy loading that might already be true. This only seems to affect CloudBees CI, which calls this method in HA mode, since I am not aware of any call toRun.reloadexcept via the load-from-disk constructor.