Code changed in jenkins
User: Kohsuke Kawaguchi
Path:
pom.xml
src/main/java/org/jenkinsci/plugins/workflow/cps/CpsGroovyShellFactory.java
src/main/java/org/jenkinsci/plugins/workflow/cps/CpsThread.java
src/main/java/org/jenkinsci/plugins/workflow/cps/CpsThreadGroup.java
src/main/java/org/jenkinsci/plugins/workflow/cps/Safepoint.java
src/test/java/org/jenkinsci/plugins/workflow/WorkflowJobNonRestartingTest.java
http://jenkins-ci.org/commit/workflow-cps-plugin/95e73725ec0479685916ace0e1b2d80801519e43
Log:
JENKINS-25623
previously, CpsThreadGroup.run() was greedy. It was running as much as
it can before it returns. This means if the Pipeline script in question
has an infinite loop, this method never returns. This prevents other
activities to take place on CPS VM thread, most notably the attempt to
kill the execution.
In this change, CpsThreadGroup.run() is modified to execute just a
little bit, not as much as it can, by using the new safepoint capability
in groovy-cps. CpsThreadGroup.scheduleRun() is modified so that if the
Pipeline Script is still runnable, the next chunk of execution is
scheduled.
Future implementation from scheduleRun() was simplified a bit. This code
is really only used for testing, so it's not that important that the
cancel() and other methods work correctly.
We probably need a multistaged approach here.
¹Ignore the stern deprecation warnings. In practice it works fine—have used it for years in NetBeans “internal execution”, such as is used for Ant scripts—and any harm it might cause is AFAIK purely theoretical and a much lesser evil than JENKINS-32986.