diff options
author | Jonathan Nieder <jrn@google.com> | 2019-04-14 11:00:46 -0400 |
---|---|---|
committer | Jonathan Nieder <jrn@google.com> | 2019-04-14 11:00:46 -0400 |
commit | 460500e99a448f30c3d94e6d6b3e468a97b2cb30 (patch) | |
tree | 30c8ad7fa8a890578c07026d494cacb4a16406a7 /org.eclipse.jgit/src/org/eclipse/jgit/submodule | |
parent | 39b0b51b1253f569888db3578b01708a14360b69 (diff) | |
download | jgit-460500e99a448f30c3d94e6d6b3e468a97b2cb30.tar.gz jgit-460500e99a448f30c3d94e6d6b3e468a97b2cb30.zip |
Revert "Use try-with-resources in SubmoduleWalk"
This reverts commit 39b0b51b1253f569888db3578b01708a14360b69. Before
that change, SubmoduleWalk.forPath transferred ownership to the caller
on success. Afterward, it returns a closed SubmoduleWalk to the caller,
which does not appear to be intentional.
Change-Id: I9381daac5153706e24fd9117700089848b58c54e
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/submodule')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/submodule/SubmoduleWalk.java | 26 |
1 files changed, 14 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 8f9fcc1bf6..ce8995ad8f 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/submodule/SubmoduleWalk.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/submodule/SubmoduleWalk.java @@ -149,20 +149,21 @@ public class SubmoduleWalk implements AutoCloseable { */ public static SubmoduleWalk forPath(Repository repository, AnyObjectId treeId, String path) throws IOException { - try (SubmoduleWalk generator = new SubmoduleWalk(repository)) { + SubmoduleWalk generator = new SubmoduleWalk(repository); + try { generator.setTree(treeId); PathFilter filter = PathFilter.create(path); generator.setFilter(filter); generator.setRootTree(treeId); - while (generator.next()) { - if (filter.isDone(generator.walk)) { + while (generator.next()) + if (filter.isDone(generator.walk)) return generator; - } - } - return null; } catch (IOException e) { + generator.close(); throw e; } + generator.close(); + return null; } /** @@ -181,20 +182,21 @@ public class SubmoduleWalk implements AutoCloseable { */ public static SubmoduleWalk forPath(Repository repository, AbstractTreeIterator iterator, String path) throws IOException { - try (SubmoduleWalk generator = new SubmoduleWalk(repository)) { + SubmoduleWalk generator = new SubmoduleWalk(repository); + try { generator.setTree(iterator); PathFilter filter = PathFilter.create(path); generator.setFilter(filter); generator.setRootTree(iterator); - while (generator.next()) { - if (filter.isDone(generator.walk)) { + while (generator.next()) + if (filter.isDone(generator.walk)) return generator; - } - } - return null; } catch (IOException e) { + generator.close(); throw e; } + generator.close(); + return null; } /** |