-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
Introducing ControllerToAgentCallable
and ControllerToAgentFileCallable
#9921
Conversation
} | ||
|
||
@Restricted(NoExternalUse.class) | ||
public void setEnvVarsFilterRuleWrapper(EnvVarsFilterRuleWrapper envVarsFilterRuleWrapper) { |
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.
@daniel-beck in #4683 you added this as a setter rather than constructor parameter, perhaps out of confusion with the similarly-named field in Launcher
which actually needs to be mutable?
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.
Maybe, the original code is by Wadeck and it's been far too long at this point. If this works, the setter is restricted, so any cleanup is fine.
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 setter is restricted
Not that it needed to be: the class was private
to begin with.
…ntrollerToAgentCallable
ControllerToAgentCallable
ControllerToAgentCallable
and ControllerToAgentFileCallable
core/src/main/java/jenkins/agents/ControllerToAgentCallable.java
Outdated
Show resolved
Hide resolved
* For new code, implement {@link ControllerToAgentFileCallable} | ||
* which has the advantage that it can be used on {@code record}s. |
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.
Given that, should this class be deprecated to discourage any new usage, or hint existing ones to move to records?
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.
I suppose it could be, though it feels like overkill to deprecate it merely because an aesthetically preferable alternative is now available.
Co-authored-by: Vincent Latombe <[email protected]>
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.
LGTM
/label ready-for-merge
This PR is now ready for merge, after ~24 hours, we will merge it if there's no negative feedback.
Thanks!
While updating some plugin code to take advantage of Java 17
record
s, I noticed that one major use case for astatic final class
with allfinal
fields wasMasterToSlaveCallable
s. Unfortunately these cannot be converted torecord
since that cannotextend
anotherclass
. I thought it would be nicer to introduce a similarinterface
(with updated naming, while we are here!) that is friendlier torecord
s.I picked
RemoteLaunchCallable
as an example of substantial legibility improvements from this conversion, but could try doing more as well. (OpenRewrite would be great though I am not experienced in that yet.)Similarly,
MasterToSlaveFileCallable
was unnecessarily awkward to use;FilePath.Archive
can be simplified this way as an example.Testing done
None, just presuming that
RemoteLaunchCallable
andFilePath.Archive
are well covered by existing functional tests.Note that the version of SpotBugs we are currently running suffers from spotbugs/spotbugs#2795 which is relevant for this use case: these
record
s areSerializable
(transiently), but noserialVersionUID
is meaningful since Java serialization forrecord
s is handled specially. The SpotBugs check forjenkins-core
does not seem to complain for whatever reason (maybe this bug priority is already suppressed?); in my plugin doing similar work I needed toI do not feel very comfortable with the idea of reducing the typical idiom further to that using a
static
method as in jenkinsci/jenkins-test-harness#671 because production code might involve different Java versions (or even vendors!) between controller and agent and it is not obvious to me that this would be safe. Givenyou can see a rather complex serial form
Proposed changelog entries
ControllerToAgentCallable
andControllerToAgentFileCallable
with support forrecords
in controller to agent callablesProposed upgrade guidelines
N/A
Submitter checklist
Desired reviewers
@Vlatombe @nevingeorgesunny @gbhat618
Before the changes are marked as
ready-for-merge
:Maintainer checklist