[infer] Fix resource leak in DirCache

Bug: 509385
Change-Id: I5f914c910ef3a7583594fb31c7757d3dddf6a05e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
Matthias Sohn 2016-12-18 01:42:24 +01:00
parent aa199ff648
commit 1779fb4a57
1 changed files with 3 additions and 3 deletions

View File

@ -634,9 +634,9 @@ public boolean lock() throws IOException {
public void write() throws IOException {
final LockFile tmp = myLock;
requireLocked(tmp);
try {
writeTo(liveFile.getParentFile(),
new BufferedOutputStream(tmp.getOutputStream()));
try (OutputStream o = tmp.getOutputStream();
OutputStream bo = new BufferedOutputStream(o)) {
writeTo(liveFile.getParentFile(), bo);
} catch (IOException err) {
tmp.unlock();
throw err;