Browse Source

LargePackedWholeObject: Refactor to open DfsReader in try-with-resource

Change-Id: Ia9557e6c1ab230dbe2e94e025a49e93159d8658c
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
stable-5.0
David Pursehouse 7 years ago committed by Matthias Sohn
parent
commit
b0ac5f9c89
  1. 12
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/LargePackedWholeObject.java

12
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/LargePackedWholeObject.java

@ -104,8 +104,8 @@ final class LargePackedWholeObject extends ObjectLoader {
/** {@inheritDoc} */
@Override
public ObjectStream openStream() throws MissingObjectException, IOException {
DfsReader ctx = db.newReader();
InputStream in;
try (DfsReader ctx = db.newReader()) {
try {
in = new PackInputStream(pack, objectOffset + headerLength, ctx);
} catch (IOException packGone) {
@ -113,14 +113,8 @@ final class LargePackedWholeObject extends ObjectLoader {
// probably was repacked recently. Go find the object
// again and open the stream from that location instead.
//
try {
ObjectId obj = pack.getReverseIdx(ctx).findObject(objectOffset);
return ctx.open(obj, type).openStream();
} finally {
ctx.close();
}
} finally {
ctx.close();
}
// Align buffer to inflater size, at a larger than default block.
@ -128,8 +122,8 @@ final class LargePackedWholeObject extends ObjectLoader {
// caller down into the pack stream inflation.
int bufsz = 8192;
in = new BufferedInputStream(
new InflaterInputStream(in, ctx.inflater(), bufsz),
bufsz);
new InflaterInputStream(in, ctx.inflater(), bufsz), bufsz);
return new ObjectStream.Filter(type, size, in);
}
}
}

Loading…
Cancel
Save