Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn O. Pearce2010-06-28 17:24:12 +0000
committerShawn O. Pearce2010-06-28 17:25:11 +0000
commita45728d7a4fe1b83953ba38ec980caa6a3f1d3c4 (patch)
tree385b6d3de173bc1615dd701f0b61a8400211624e /org.eclipse.jgit.junit
parentb5aa52e98a8e1ee9b8530fc2c37a04df224aa0c1 (diff)
downloadjgit-a45728d7a4fe1b83953ba38ec980caa6a3f1d3c4.tar.gz
jgit-a45728d7a4fe1b83953ba38ec980caa6a3f1d3c4.tar.xz
jgit-a45728d7a4fe1b83953ba38ec980caa6a3f1d3c4.zip
Ensure ObjectReader used by PackWriter is released
The ObjectReader API demands that we release the reader when we are done with it. PackWriter contains a reader, which it uses for the entire packing session. Expose the release of the reader through a release method on the writer. This still doesn't address the RevWalk and TreeWalk users, who don't correctly release their reader. But its a small step in the right direction. Change-Id: I5cb0b5c1b432434a799fceb21b86479e09b84a0a Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit.junit')
-rw-r--r--org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java47
1 files changed, 26 insertions, 21 deletions
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
index 18275ec710..5b0e74cace 100644
--- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
+++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
@@ -600,33 +600,38 @@ public class TestRepository<R extends Repository> {
public void packAndPrune() throws Exception {
if (db.getObjectDatabase() instanceof ObjectDirectory) {
ObjectDirectory odb = (ObjectDirectory) db.getObjectDatabase();
- PackWriter pw = new PackWriter(db, NullProgressMonitor.INSTANCE);
- Set<ObjectId> all = new HashSet<ObjectId>();
- for (Ref r : db.getAllRefs().values())
- all.add(r.getObjectId());
- pw.preparePack(all, Collections.<ObjectId> emptySet());
+ final File pack, idx;
+ PackWriter pw = new PackWriter(db, NullProgressMonitor.INSTANCE);
+ try {
+ Set<ObjectId> all = new HashSet<ObjectId>();
+ for (Ref r : db.getAllRefs().values())
+ all.add(r.getObjectId());
+ pw.preparePack(all, Collections.<ObjectId> emptySet());
- final ObjectId name = pw.computeName();
- OutputStream out;
+ final ObjectId name = pw.computeName();
+ OutputStream out;
- final File pack = nameFor(odb, name, ".pack");
- out = new BufferedOutputStream(new FileOutputStream(pack));
- try {
- pw.writePack(out);
- } finally {
- out.close();
- }
- pack.setReadOnly();
+ pack = nameFor(odb, name, ".pack");
+ out = new BufferedOutputStream(new FileOutputStream(pack));
+ try {
+ pw.writePack(out);
+ } finally {
+ out.close();
+ }
+ pack.setReadOnly();
- final File idx = nameFor(odb, name, ".idx");
- out = new BufferedOutputStream(new FileOutputStream(idx));
- try {
- pw.writeIndex(out);
+ idx = nameFor(odb, name, ".idx");
+ out = new BufferedOutputStream(new FileOutputStream(idx));
+ try {
+ pw.writeIndex(out);
+ } finally {
+ out.close();
+ }
+ idx.setReadOnly();
} finally {
- out.close();
+ pw.release();
}
- idx.setReadOnly();
odb.openPack(pack, idx);
updateServerInfo();

Back to the top