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
Reduce reflection in CpsFlowExecution
#627
Conversation
Or just clean up now. #600 (comment) maybe Jenkins core should somehow warn you when you are running on a Java version known to be outdated, especially if a release of core or any plugin you are using is newer than the release of Java superseding the one you are on. |
Not interested |
Unlike many of my other cleanup PRs, the timing of the merge and release of this PR is relevant: the longer it takes for this PR to be widely adopted, the longer we are forced to maintain the technical debt of the |
Sorry, was hoping a more active maintainer might merge, but I guess not! |
Cheers, somehow this broke our shared library (with controller running on JDK 17.0.5 so now not doing that magic code the PR fenced). Sample code which breaks was a debug print ending up in an This cropped up after updates to workflow-cps:3565.v4b_d9b_8c29a_b_3 and workflow-cps:3581.v2b_e4c99c76ed ; not sure if similar fix in script-security:1228.vd93135a_2fb_25 impacted this use-case. Reverting to workflow-cps:3536.vb_8a_6628079d5 and script-security:1218.v39ca_7f7ed0a_c did hot-fix the issue in the field. By changeset description this reflection-reduction seemed most relevant, but maybe the issue was root-caused in some other bugfix. A trimmed-down version of this looks like this:
UPDATE: Looking at those other contemporary PRs, https://github.com/jenkinsci/workflow-cps-plugin/pull/635/files seems suspicious regarding changes from |
Jenkins core currently specifies
--add-opens java.base/java.io=ALL-UNNAMED
, which is technical debt in the sense that it enables deprecated behavior. This is only needed forworkflow-cps
'scleanUpObjectStreamClassCaches
method, and that method is in turn only needed for old JVMs that do not have the fix for JDK-8277072. This PR makes the reflection-based logic conditional on running on these older JVMs, so that when running on a newer JVM the illegal reflective access is not attempted. When this PR is widely adopted, we can remove the--add-opens java.base/java.io=ALL-UNNAMED
directive from Jenkins core and clean up this technical debt.To test this change I removed
--add-opens java.base/java.io=ALL-UNNAMED
and verified that this exception was logged even when running on Java 11.0.17:With this PR the exception is no longer logged. If accepted I will make a similar PR for the copypasta of this code in
script-security
.