envinject-plugin
envinject-plugin copied to clipboard
Avoid unnecessary use of reflection
I saw the recent changes to make this plugin work on Java 17 but I was a bit dissatisfied with having to add --add-opens
arguments. I think the plugin can be simplified to avoid the use of reflection entirely, which simplifies maintenance and obviates the need for --add-opens
directives.
I tested this by running the automated tests and doing some basic tests locally on both the controller and on an agent, but I have not done very exhaustive manual testing and this code is very fragile, so I would appreciate any additional testing that others can offer. @bulanovk are you interested in testing this out in production for a week or so and reporting back if there are any issues?
@basil Yes we could test it on our DevOps dev env
@basil Yes we could test it on our DevOps dev env
Hey @bulanovk,
Did you have a shot to test this out yet?
Hello, sorry was on vacation w\o access to internet.
We try this version on our Test instance, for 2 weeks, and got now issues so far.
Hello! Anyone working on / reviewing this? I am asking as we just upgraded jenkins in version 2.426.3 to run with Java 21 and we are getting this when starting one of our worker nodes;
Dies ist ein Unix- oder Linux-Agent
ERROR: Unerwarteter Fehler beim Start des Agenten. Das ist vermutlich ein Bug in Jenkins.
Also: hudson.remoting.Channel$CallSiteStackTrace: Remote call to uidvdpbp01
at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1787)
at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356)
at hudson.remoting.Channel.call(Channel.java:1003)
at hudson.FilePath.act(FilePath.java:1321)
at org.jenkinsci.plugins.envinject.EnvInjectComputerListener.onOnline(EnvInjectComputerListener.java:144)
at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:751)
at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:441)
at hudson.plugins.sshslaves.SSHLauncher.startAgent(SSHLauncher.java:645)
at hudson.plugins.sshslaves.SSHLauncher.lambda$launch$0(SSHLauncher.java:465)
java.lang.reflect.InaccessibleObjectException: Unable to make private native java.lang.reflect.Field[] java.lang.Class.getDeclaredFields0(boolean) accessible: module java.base does not "opens java.lang" to unnamed module @4674ff26
at java.base/java.lang.reflect.AccessibleObject.throwInaccessibleObjectException(AccessibleObject.java:391)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:367)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:315)
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:203)
at java.base/java.lang.reflect.Method.setAccessible(Method.java:197)
at org.jenkinsci.plugins.envinject.service.EnvInjectMasterEnvVarsSetter.getModifiers(EnvInjectMasterEnvVarsSetter.java:29)
at org.jenkinsci.plugins.envinject.service.EnvInjectMasterEnvVarsSetter.call(EnvInjectMasterEnvVarsSetter.java:55)
at org.jenkinsci.plugins.envinject.service.EnvInjectMasterEnvVarsSetter.call(EnvInjectMasterEnvVarsSetter.java:19)
at hudson.remoting.UserRequest.perform(UserRequest.java:211)
at hudson.remoting.UserRequest.perform(UserRequest.java:54)
at hudson.remoting.Request$2.run(Request.java:377)
at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:78)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base/java.lang.Thread.run(Thread.java:1583)
Agent successfully connected and online