diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2010-06-29 15:12:51 -0700 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2010-06-29 15:12:53 -0700 |
commit | 515deaf7e503738b4c53c3c2dfd6d7acab3bef18 (patch) | |
tree | 5372d28cace8f3f8d9080f9d539273bb63c3f743 /org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java | |
parent | 4913ad57fce7f9c3ab9600a55ba02f589b3088c1 (diff) | |
download | jgit-515deaf7e503738b4c53c3c2dfd6d7acab3bef18.tar.gz jgit-515deaf7e503738b4c53c3c2dfd6d7acab3bef18.zip |
Ensure RevWalk is released when done
Update a number of calling sites of RevWalk to ensure the walker's
internal ObjectReader is released after the walk is no longer used.
Because the ObjectReader is likely to hold onto a native resource
like an Inflater, we don't want to leak them outside of their
useful scope.
Where possible we also try to share ObjectReaders across several
walk pools, or between a walker and a PackWriter. This permits
the ObjectReader to actually do some caching if it felt inclined
to do so.
Not everything was updated, we'll probably need to come back and
update even more call sites, but these are some of the biggest
offenders. Test cases in particular aren't updated. My plan is to
move most storage-agnostic tests onto some purely in-memory storage
solution that doesn't do compression.
Change-Id: I04087ec79faeea208b19848939898ad7172b6672
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java index e04a587ac2..e6f8933389 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java @@ -440,7 +440,12 @@ public abstract class RefUpdate { * an unexpected IO error occurred while writing changes. */ public Result update() throws IOException { - return update(new RevWalk(getRepository())); + RevWalk rw = new RevWalk(getRepository()); + try { + return update(rw); + } finally { + rw.release(); + } } /** @@ -485,7 +490,12 @@ public abstract class RefUpdate { * @throws IOException */ public Result delete() throws IOException { - return delete(new RevWalk(getRepository())); + RevWalk rw = new RevWalk(getRepository()); + try { + return delete(rw); + } finally { + rw.release(); + } } /** |