mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-10-27 11:35:20 +00:00
Cleanup warnings for missing getPlugin() null checks (#5222)
This commit is contained in:
1 parent
b95da6ef32
commit
b49610e29f
5 files changed
+33
-8
No files matched your search
@@ -523,12 +523,25 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
|
||||
/**
|
||||
* Gets the instance of {@link Plugin} contributed by this plugin.
|
||||
* @return Plugin instace or {@code null} if it is not present in the plugin instance store.
|
||||
*/
|
||||
public @CheckForNull Plugin getPlugin() {
|
||||
PluginInstanceStore pis = Jenkins.lookup(PluginInstanceStore.class);
|
||||
return pis != null ? pis.store.get(this) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the instance of {@link Plugin} contributed by this plugin.
|
||||
* @throws Exception no plugin in the {@link PluginInstanceStore}
|
||||
*/
|
||||
public @NonNull Plugin getPluginOrFail() throws Exception {
|
||||
Plugin plugin = getPlugin();
|
||||
if (plugin == null) {
|
||||
throw new Exception("Cannot find the plugin instance: " + shortName);
|
||||
}
|
||||
return plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the URL that shows more information about this plugin.
|
||||
* @return
|
||||
|
||||
Reference in new issue
Block a user