WalkRemoteObjectDatabase: Open auto-closeable resources in try-with-resource
Change-Id: Ie4f67ca8cab1031089782f202588b08cc157dd79 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
This commit is contained in:
parent
99c187a5da
commit
fa9ee83697
|
@ -264,11 +264,8 @@ OutputStream writeFile(final String path, final ProgressMonitor monitor,
|
|||
* failed, possibly due to permissions or remote disk full, etc.
|
||||
*/
|
||||
void writeFile(final String path, final byte[] data) throws IOException {
|
||||
final OutputStream os = writeFile(path, null, null);
|
||||
try {
|
||||
try (OutputStream os = writeFile(path, null, null)) {
|
||||
os.write(data);
|
||||
} finally {
|
||||
os.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -394,8 +391,7 @@ BufferedReader openReader(final String path) throws IOException {
|
|||
*/
|
||||
Collection<WalkRemoteObjectDatabase> readAlternates(final String listPath)
|
||||
throws IOException {
|
||||
final BufferedReader br = openReader(listPath);
|
||||
try {
|
||||
try (BufferedReader br = openReader(listPath)) {
|
||||
final Collection<WalkRemoteObjectDatabase> alts = new ArrayList<>();
|
||||
for (;;) {
|
||||
String line = br.readLine();
|
||||
|
@ -406,8 +402,6 @@ Collection<WalkRemoteObjectDatabase> readAlternates(final String listPath)
|
|||
alts.add(openAlternate(line));
|
||||
}
|
||||
return alts;
|
||||
} finally {
|
||||
br.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -422,14 +416,8 @@ Collection<WalkRemoteObjectDatabase> readAlternates(final String listPath)
|
|||
*/
|
||||
protected void readPackedRefs(final Map<String, Ref> avail)
|
||||
throws TransportException {
|
||||
try {
|
||||
final BufferedReader br = openReader(ROOT_DIR
|
||||
+ Constants.PACKED_REFS);
|
||||
try {
|
||||
try (BufferedReader br = openReader(ROOT_DIR + Constants.PACKED_REFS)) {
|
||||
readPackedRefsImpl(avail, br);
|
||||
} finally {
|
||||
br.close();
|
||||
}
|
||||
} catch (FileNotFoundException notPacked) {
|
||||
// Perhaps it wasn't worthwhile, or is just an older repository.
|
||||
} catch (IOException e) {
|
||||
|
|
Loading…
Reference in New Issue