Skip to content
Browse files

Merge pull request #2569 from stephenc/jenkins-38534

[FIXED JENKINS-38534] Isolate the code that requires the `Jenkins` class to be loaded from an agent code path
  • Loading branch information
daniel-beck committed Sep 27, 2016
2 parents 96ec7a2 + 0859573 commit 31ab674c814bf8b987532fcd98b908a59047936f
Showing with 16 additions and 6 deletions.
  1. +16 −6 core/src/main/java/hudson/util/
@@ -23,6 +23,7 @@
package hudson.util;

import hudson.ExtensionList;
import hudson.ExtensionPoint;
import hudson.util.ProcessTreeRemoting.IOSProcess;

@@ -32,7 +33,7 @@
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;

import jenkins.model.Jenkins;
import jenkins.util.JenkinsJVM;

* Allows extensions to veto killing processes. If at least one extension vetoes
@@ -74,11 +75,20 @@ public VetoCause(@Nonnull String message) {
* list if Jenkins is not available, never null.
public static List<ProcessKillingVeto> all() {
// check if we are a thread running on the master JVM or a thread running in a remote JVM
Jenkins jenkins = Jenkins.getInstanceOrNull();
if (jenkins == null)
return Collections.emptyList(); // we are remote, no body gets to veto
return jenkins.getExtensionList(ProcessKillingVeto.class);
if (JenkinsJVM.isJenkinsJVM()) {
return _all();
return Collections.emptyList();

* As classloading is lazy, the classes referenced in this method will not be resolved
* until the first time the method is invoked, so we use this method to guard access to Jenkins JVM only classes.
* @return All ProcessKillingVeto extensions currently registered.
private static List<ProcessKillingVeto> _all() {
return ExtensionList.lookup(ProcessKillingVeto.class);


0 comments on commit 31ab674

Please sign in to comment.
You can’t perform that action at this time.