This code predates the NB utility class. I'd prefer to reuse the code over keeping this duplicate copy of the logic. Signed-off-by: Shawn O. Pearce <spearce@xxxxxxxxxxx> --- .../org/spearce/jgit/lib/UnpackedObjectLoader.java | 14 ++++++-------- 1 files changed, 6 insertions(+), 8 deletions(-) diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/UnpackedObjectLoader.java b/org.spearce.jgit/src/org/spearce/jgit/lib/UnpackedObjectLoader.java index f2cae87..b086821 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/lib/UnpackedObjectLoader.java +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/UnpackedObjectLoader.java @@ -46,6 +46,7 @@ import org.spearce.jgit.errors.CorruptObjectException; import org.spearce.jgit.util.MutableInteger; +import org.spearce.jgit.util.NB; import org.spearce.jgit.util.RawParseUtils; /** @@ -74,17 +75,14 @@ public UnpackedObjectLoader(final Repository db, final AnyObjectId id) private static byte[] readCompressed(final Repository db, final AnyObjectId id) throws FileNotFoundException, IOException { - final FileInputStream objStream = new FileInputStream(db.toFile(id)); - final byte[] compressed; + final FileInputStream in = new FileInputStream(db.toFile(id)); try { - compressed = new byte[objStream.available()]; - int off = 0; - while (off < compressed.length) - off += objStream.read(compressed, off, compressed.length - off); + final byte[] compressed = new byte[(int) in.getChannel().size()]; + NB.readFully(in, compressed, 0, compressed.length); + return compressed; } finally { - objStream.close(); + in.close(); } - return compressed; } /** -- 1.6.3.rc1.188.ga02b -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html