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

[JENKINS-74814] java.lang.UnsupportedOperationException: This stack walker does not have RETAIN_CLASS_REFERENCE access #9945

Merged
merged 1 commit into from
Nov 8, 2024

Conversation

basil
Copy link
Member

@basil basil commented Nov 5, 2024

See JENKINS-74814. When attempting to use the zero-argument version of jenkins.util.SetContextClassLoader from #6575 in ldap-plugin, I got this exception:

java.lang.UnsupportedOperationException: This stack walker does not have RETAIN_CLASS_REFERENCE access
	at java.base/java.lang.StackWalker.getCallerClass(StackWalker.java:687)
	at jenkins.util.SetContextClassLoader.<init>(SetContextClassLoader.java:65)
	at PluginClassLoader for ldap//hudson.security.LDAPSecurityRealm$LDAPAuthenticationManager.authenticate(LDAPSecurityRealm.java:989)
	at org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter.attemptAuthentication(UsernamePasswordAuthenticationFilter.java:85)
	at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:231)
	at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:221)
	at hudson.security.ChainedServletFilter2$1.doFilter(ChainedServletFilter2.java:99)

This apparently has never worked, but the bug was easy to fix by configuring the stack walker with the StackWalker.Option.RETAIN_CLASS_REFERENCE option (which instructs the stack walker to retain class information in each stack frame).

Testing done

Reproduced the problem in context in a draft ldap-plugin change and verified that after this PR the problem was resolved.

Proposed changelog entries

  • Developer: Allow context classloaders to be defined without making explicit reference to the calling class.

Proposed upgrade guidelines

N/A

Submitter checklist

Desired reviewers

@mention

Before the changes are marked as ready-for-merge:

Maintainer checklist

… walker does not have `RETAIN_CLASS_REFERENCE` access
@basil basil added the bug For changelog: Minor bug. Will be listed after features label Nov 5, 2024
@MarkEWaite
Copy link
Contributor

This PR is now ready for merge. We will merge it after approximately 24 hours if there is no negative feedback.

/label ready-for-merge

@comment-ops-bot comment-ops-bot bot added the ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback label Nov 6, 2024
@basil basil merged commit ac63b7f into jenkinsci:master Nov 8, 2024
15 checks passed
krisstern pushed a commit to krisstern/jenkins that referenced this pull request Nov 9, 2024
… walker does not have `RETAIN_CLASS_REFERENCE` access (jenkinsci#9945)

(cherry picked from commit ac63b7f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug For changelog: Minor bug. Will be listed after features ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants