Fix resource leaks in the testing framework

Reviewed By: peterogithub

Differential Revision: D3381503

fbshipit-source-id: 6513ebd
master
Jeremy Dubreil 9 years ago committed by Facebook Github Bot 1
parent a85a88d145
commit 707a9ae51b

@ -494,11 +494,6 @@
"file": "infer/tests/codetoanalyze/java/infer/CursorLeaks.java", "file": "infer/tests/codetoanalyze/java/infer/CursorLeaks.java",
"procedure": "void CursorLeaks.loadPrefsFromContentProviderNotClosed()" "procedure": "void CursorLeaks.loadPrefsFromContentProviderNotClosed()"
}, },
{
"bug_type": "RESOURCE_LEAK",
"file": "infer/tests/utils/matchers/DotFilesEqual.java",
"procedure": "boolean DotFilesEqual.matches(Object)"
},
{ {
"bug_type": "RESOURCE_LEAK", "bug_type": "RESOURCE_LEAK",
"file": "infer/tests/codetoanalyze/java/infer/ResourceLeaks.java", "file": "infer/tests/codetoanalyze/java/infer/ResourceLeaks.java",

@ -38,8 +38,9 @@ public class DotFilesEqual extends BaseMatcher<File> {
} else { } else {
diffCommand = "diff -u " + dotFile + " " + newDotFile.getAbsolutePath(); diffCommand = "diff -u " + dotFile + " " + newDotFile.getAbsolutePath();
} }
Process diff_process = null;
try { try {
Process diff_process = Runtime.getRuntime().exec(diffCommand); diff_process = Runtime.getRuntime().exec(diffCommand);
try (BufferedReader inputReader = try (BufferedReader inputReader =
new BufferedReader(new InputStreamReader(diff_process.getInputStream())); new BufferedReader(new InputStreamReader(diff_process.getInputStream()));
BufferedReader errorReader = BufferedReader errorReader =
@ -64,6 +65,8 @@ public class DotFilesEqual extends BaseMatcher<File> {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return false; return false;
} finally {
if (diff_process != null) diff_process.destroy();
} }
} }

Loading…
Cancel
Save