From a416b7c90da67f2a94688ffe73683f9ad9701e6d Mon Sep 17 00:00:00 2001 From: Jeremy Dubreil Date: Thu, 2 Feb 2017 21:58:21 -0800 Subject: [PATCH] [infer][java] Add a model for Process.destroyForcibly() Reviewed By: sblackshear Differential Revision: D4506823 fbshipit-source-id: 6016744 --- infer/models/java/src/java/lang/Process.java | 5 +++++ infer/tests/codetoanalyze/java/infer/ResourceLeaks.java | 9 +++++++++ 2 files changed, 14 insertions(+) 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; }