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",
"procedure": "void CursorLeaks.loadPrefsFromContentProviderNotClosed()"
},
{
"bug_type": "RESOURCE_LEAK",
"file": "infer/tests/utils/matchers/DotFilesEqual.java",
"procedure": "boolean DotFilesEqual.matches(Object)"
},
{
"bug_type": "RESOURCE_LEAK",
"file": "infer/tests/codetoanalyze/java/infer/ResourceLeaks.java",

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

Loading…
Cancel
Save