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

Advertise lambdas as arguments to then / runRemotely #882

Merged
merged 13 commits into from
Dec 18, 2024

Conversation

jglick
Copy link
Member

@jglick jglick commented Dec 2, 2024

More concise alternative to use of static method handles, at least for the common case that there is only one call site (or the lambda delegates to a static method with arguments). #881 (comment) for discussion (see 1f09a19)

@jglick jglick mentioned this pull request Dec 3, 2024
@jglick jglick marked this pull request as ready for review December 3, 2024 20:01
@jglick jglick requested review from Vlatombe and amuniz December 3, 2024 20:01
@@ -759,6 +758,15 @@ public String[] getTruststoreJavaOptions() {
* If you need to pass and/or return values, you can still use a static method reference:
* try {@link #runRemotely(Step2)} or {@link #runRemotely(StepWithReturnAndOneArg, Serializable)} etc.
* (using {@link XStreamSerializable} as needed).
* <p>
* Alternately, you could use a lambda (taking care not to capture non-serializable objects from scope):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my experience, this is pretty difficult to assess once you experience an issue.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be. Noted in #881 (comment). The difference is that (anonymous) inner classes will always capture variables in lexical scope, whereas lambdas usually will not. Noted another caveat in b9e40f5.

@jglick jglick requested a review from Vlatombe December 17, 2024 17:41
@jglick jglick merged commit ee6dc8d into jenkinsci:master Dec 18, 2024
15 checks passed
@jglick jglick deleted the lambda branch December 18, 2024 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants