提交 1004d327 编写于 作者: M Marat Radchenko 提交者: Oleg Nenashev

Fix NPE in ProcessTree#killAll if proc is null and add a test for it (#4232)

Javadoc for ProcessTree#killAll says that "either of the parameter can be null",
but it wasn't true for proc.
上级 144642ca
......@@ -167,8 +167,12 @@ public abstract class ProcessTree implements Iterable<OSProcess>, IProcessTree,
*/
public void killAll(Process proc, Map<String, String> modelEnvVars) throws InterruptedException {
LOGGER.fine("killAll: process="+proc+" and envs="+modelEnvVars);
OSProcess p = get(proc);
if(p!=null) p.killRecursively();
if (proc != null) {
OSProcess p = get(proc);
if (p != null) p.killRecursively();
}
if(modelEnvVars!=null)
killAll(modelEnvVars);
}
......
......@@ -65,6 +65,12 @@ public class ProcessTreeKillerTest {
b.getWorkspace().deleteRecursive();
}
@Test
public void killNullProcess() throws Exception {
ProcessTree.enabled = true;
ProcessTree.get().killAll(null, null);
}
@Test
@Issue("JENKINS-22641")
public void processProperlyKilledUnix() throws Exception {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册