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.
*/
public void writePack(OutputStream packStream) throws IOException {
if ((reuseDeltas || reuseObjects) && reuseSupport != null)
searchForReuse();
out = new PackOutputStream(packStream, isDeltaBaseAsOffset());
writeMonitor.beginTask(WRITING_OBJECTS_PROGRESS, getObjectsNumber());
out.writeFileHeader(PACK_VERSION_GENERATED, getObjectsNumber());
writeObjects();
writeChecksum();
out = null;
reader.release();
writeMonitor.endTask();
try {
if ((reuseDeltas || reuseObjects) && reuseSupport != null)
searchForReuse();
out = new PackOutputStream(packStream, isDeltaBaseAsOffset());
int cnt = getObjectsNumber();
writeMonitor.beginTask(WRITING_OBJECTS_PROGRESS, cnt);
out.writeFileHeader(PACK_VERSION_GENERATED, cnt);
writeObjects();
writeChecksum();
writeMonitor.endTask();
} finally {
out = null;
reader.release();
}
}
private void searchForReuse() throws IOException {

Loading…
Cancel
Save