-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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-72111] Allow Lifecycle
to load implementations from plugins
#8589
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I retained sources in the plugin archive, but for the convenience of reviewers:
package test.custom_lifecycle;
import hudson.lifecycle.Lifecycle;
public final class CustomLifecycle extends Lifecycle {
public int count;
@Override
public void restart() {
count++;
}
}
activePlugins.add(p); | ||
((UberClassLoader) uberClassLoader).clearCacheMisses(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found that UberClassLoader.loaded
cached class loading misses after plugins were loaded during startup. This would not normally be noticeable, but in this case a call to Lifecycle.get
before initializing plugins would cache the miss and it would not subsequently be cleared.
((UberClassLoader) uberClassLoader).loaded.clear(); | ||
((UberClassLoader) uberClassLoader).clearCacheMisses(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for dynamic plugin loading, so already cleared the cache, though also cache hits which seemed unnecessary.
Lifecycle
to load implementations from pluginsLifecycle
to load implementations from plugins
/label ready-for-merge This PR is now ready for merge, after ~24 hours, we will merge it if there's no negative feedback. Thanks! |
See JENKINS-72111 and #8555 (comment). Unlike the original PR, this requires no API change or plugin initializer, just the existing system property—which had long used
UberClassLoader
but did not work for a class defined in a plugin.Testing done
The functional test added here, as well as validation that this works for a
Lifecycle
implementation in a plugin in CloudBees CI when the system property is set. (Without this patch, setting the system property to the plugin-defined class causes a boot failure, since the class is not loadable whenLifecycle.get
is first called early during startup.)Proposed changelog entries
Lifecycle
.Desired reviewers
@Vlatombe @jtnord
Before the changes are marked as
ready-for-merge
:Maintainer checklist