Close input stream after use

The InputStream in FileStream in downloadPack is never closed.

Change-Id: I59975d0b8d51f4b3e3ba9d4496b254d508cb936d
Signed-off-by: Zhen Chen <czhen@google.com>
This commit is contained in:
Zhen Chen 2016-11-22 11:59:32 -08:00
parent 81f9c18433
commit 5af3f9bd63
1 changed files with 11 additions and 7 deletions

View File

@ -881,13 +881,17 @@ else if (tmpIdx.isFile()) {
void downloadPack(final ProgressMonitor monitor) throws IOException {
String name = "pack/" + packName; //$NON-NLS-1$
WalkRemoteObjectDatabase.FileStream s = connection.open(name);
PackParser parser = inserter.newPackParser(s.in);
parser.setAllowThin(false);
parser.setObjectChecker(objCheck);
parser.setLockMessage(lockMessage);
PackLock lock = parser.parse(monitor);
if (lock != null)
packLocks.add(lock);
try {
PackParser parser = inserter.newPackParser(s.in);
parser.setAllowThin(false);
parser.setObjectChecker(objCheck);
parser.setLockMessage(lockMessage);
PackLock lock = parser.parse(monitor);
if (lock != null)
packLocks.add(lock);
} finally {
s.in.close();
}
}
}
}