aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Borowitz2012-06-14 18:06:09 (EDT)
committerDave Borowitz2012-06-15 14:43:22 (EDT)
commit458f64c6ea94da114cd99243302dfaacc7194d7c (patch)
tree229ac831c65bf03869b65f8223e210e678b7782f
parent2656ac1b5acb9b73c6b47e2cf8830a0a0b2cc214 (diff)
downloadjgit-458f64c6ea94da114cd99243302dfaacc7194d7c.zip
jgit-458f64c6ea94da114cd99243302dfaacc7194d7c.tar.gz
jgit-458f64c6ea94da114cd99243302dfaacc7194d7c.tar.bz2
Add a release() method to SubmoduleWalkrefs/changes/66/6366/2
We need a way to release the underlying TreeWalk. Also, use this method to release walks from the static factory methods on error or when submodules are not found. Change-Id: I6bedc2db78bcd577aef2cfe6715bb981a26dcfd7
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/submodule/SubmoduleWalk.java41
1 files changed, 29 insertions, 12 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/submodule/SubmoduleWalk.java b/org.eclipse.jgit/src/org/eclipse/jgit/submodule/SubmoduleWalk.java
index d18f1e1..f037a7c 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/submodule/SubmoduleWalk.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/submodule/SubmoduleWalk.java
@@ -102,12 +102,18 @@ public class SubmoduleWalk {
public static SubmoduleWalk forPath(Repository repository,
AnyObjectId treeId, String path) throws IOException {
SubmoduleWalk generator = new SubmoduleWalk(repository);
- generator.setTree(treeId);
- PathFilter filter = PathFilter.create(path);
- generator.setFilter(filter);
- while (generator.next())
- if (filter.isDone(generator.walk))
- return generator;
+ try {
+ generator.setTree(treeId);
+ PathFilter filter = PathFilter.create(path);
+ generator.setFilter(filter);
+ while (generator.next())
+ if (filter.isDone(generator.walk))
+ return generator;
+ } catch (IOException e) {
+ generator.release();
+ throw e;
+ }
+ generator.release();
return null;
}
@@ -124,12 +130,18 @@ public class SubmoduleWalk {
public static SubmoduleWalk forPath(Repository repository,
AbstractTreeIterator iterator, String path) throws IOException {
SubmoduleWalk generator = new SubmoduleWalk(repository);
- generator.setTree(iterator);
- PathFilter filter = PathFilter.create(path);
- generator.setFilter(filter);
- while (generator.next())
- if (filter.isDone(generator.walk))
- return generator;
+ try {
+ generator.setTree(iterator);
+ PathFilter filter = PathFilter.create(path);
+ generator.setFilter(filter);
+ while (generator.next())
+ if (filter.isDone(generator.walk))
+ return generator;
+ } catch (IOException e) {
+ generator.release();
+ throw e;
+ }
+ generator.release();
return null;
}
@@ -511,4 +523,9 @@ public class SubmoduleWalk {
String url = getModulesUrl();
return url != null ? getSubmoduleRemoteUrl(repository, url) : null;
}
+
+ /** Release any resources used by this walker's reader. */
+ public void release() {
+ walk.release();
+ }
}