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

Avoid unnecessary use of reflection #214

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

basil
Copy link
Member

@basil basil commented Aug 4, 2022

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 basil requested a review from a team as a code owner August 4, 2022 04:13
}

public Void call() {
EnvVars.masterEnvVars.putAll(enVars);
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure how this would work with multiple calls to EnvInjectMasterEnvVarsSetter#call. This very well may be incorrect. 😕

@basil basil marked this pull request as draft August 4, 2022 04:37
@bulanovk
Copy link
Contributor

bulanovk commented Aug 4, 2022

@basil Yes we could test it on our DevOps dev env

@NotMyFault
Copy link
Member

@basil Yes we could test it on our DevOps dev env

Hey @bulanovk,

Did you have a shot to test this out yet?

@bulanovk
Copy link
Contributor

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.

@cquoss
Copy link

cquoss commented Feb 2, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants