Browse Source

Ensure PackWriter releases its ObjectReader

Change-Id: I3f8af29066cc5a2132dc4a75c9654d97800f2f18
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
stable-0.9
Shawn O. Pearce 15 years ago
parent
commit
b5aa52e98a
  1. 29
      org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java

29
org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java

@ -610,19 +610,22 @@ public class PackWriter {
* stream. * stream.
*/ */
public void writePack(OutputStream packStream) throws IOException { public void writePack(OutputStream packStream) throws IOException {
if ((reuseDeltas || reuseObjects) && reuseSupport != null) try {
searchForReuse(); if ((reuseDeltas || reuseObjects) && reuseSupport != null)
searchForReuse();
out = new PackOutputStream(packStream, isDeltaBaseAsOffset());
out = new PackOutputStream(packStream, isDeltaBaseAsOffset());
writeMonitor.beginTask(WRITING_OBJECTS_PROGRESS, getObjectsNumber());
out.writeFileHeader(PACK_VERSION_GENERATED, getObjectsNumber()); int cnt = getObjectsNumber();
writeObjects(); writeMonitor.beginTask(WRITING_OBJECTS_PROGRESS, cnt);
writeChecksum(); out.writeFileHeader(PACK_VERSION_GENERATED, cnt);
writeObjects();
out = null; writeChecksum();
reader.release(); writeMonitor.endTask();
writeMonitor.endTask(); } finally {
out = null;
reader.release();
}
} }
private void searchForReuse() throws IOException { private void searchForReuse() throws IOException {

Loading…
Cancel
Save