diff --git a/infer/models/java/src/java/lang/Process.java b/infer/models/java/src/java/lang/Process.java index 560bf738b..a40ed2b2f 100644 --- a/infer/models/java/src/java/lang/Process.java +++ b/infer/models/java/src/java/lang/Process.java @@ -55,6 +55,11 @@ public abstract class Process { } catch (IOException e) {}*/ } + public Process destroyForcibly() { + destroy(); + return this; + } + private static class ProcessInputStream extends FileInputStream { private FileDescriptor fd; diff --git a/infer/tests/codetoanalyze/java/infer/ResourceLeaks.java b/infer/tests/codetoanalyze/java/infer/ResourceLeaks.java index cd9cf1384..c625dd6d1 100644 --- a/infer/tests/codetoanalyze/java/infer/ResourceLeaks.java +++ b/infer/tests/codetoanalyze/java/infer/ResourceLeaks.java @@ -884,6 +884,15 @@ public class ResourceLeaks { } } + void processForciblyDestroyed() throws IOException { + Process process = null; + try { + process = Runtime.getRuntime().exec(""); + } finally { + ignore(process.destroyForcibly()); + } + } + class Container { FileInputStream inputStream; }