Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2013-03-24 01:00:09 +0000
committerMatthias Sohn2013-03-24 01:00:09 +0000
commit1801d99ea41e4bf47077185dded0c85469aa4f06 (patch)
tree9fc0d607821754e233c6e3c6dd8173c6f85ee69a /org.eclipse.egit.ui
parent7b9d64e73729490c37057fb1697c00cc71d09786 (diff)
downloadegit-1801d99ea41e4bf47077185dded0c85469aa4f06.tar.gz
egit-1801d99ea41e4bf47077185dded0c85469aa4f06.tar.xz
egit-1801d99ea41e4bf47077185dded0c85469aa4f06.zip
Ensure repositories are also closed if an exception is thrown
Improves change I3a596fcabdb5225e9042e1ffae6b054c48d72d54. Change-Id: I8011398e5cb19f8e24ef2bd2d74512a0fbc12c64 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com> cc: Robin Rosenberg <robin.rosenberg@dewire.com>
Diffstat (limited to 'org.eclipse.egit.ui')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesViewContentProvider.java11
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RemoveCommand.java14
2 files changed, 18 insertions, 7 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesViewContentProvider.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesViewContentProvider.java
index d5458c88f5..12e6317be4 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesViewContentProvider.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesViewContentProvider.java
@@ -436,10 +436,15 @@ public class RepositoriesViewContentProvider implements ITreeContentProvider,
while (walk.next()) {
Repository subRepo = walk.getRepository();
if (subRepo != null) {
- final Repository cachedRepo = repositoryCache
+ Repository cachedRepo = null;
+ try {
+ cachedRepo = repositoryCache
.lookupRepository(subRepo.getDirectory());
- subRepo.close();
- children.add(new RepositoryNode(node, cachedRepo));
+ } finally {
+ subRepo.close();
+ }
+ if (cachedRepo != null)
+ children.add(new RepositoryNode(node, cachedRepo));
}
}
} catch (IOException e) {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RemoveCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RemoveCommand.java
index d49ca642c4..491c95a8c4 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RemoveCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RemoveCommand.java
@@ -226,10 +226,16 @@ public class RemoveCommand extends
while (walk.next()) {
Repository subRepo = walk.getRepository();
if (subRepo != null) {
- final RepositoryCache cache = org.eclipse.egit.core.Activator
- .getDefault().getRepositoryCache();
- cache.lookupRepository(subRepo.getDirectory()).close();
- subRepo.close();
+ RepositoryCache cache = null;
+ try {
+ cache = org.eclipse.egit.core.Activator.getDefault()
+ .getRepositoryCache();
+ } finally {
+ if (cache != null)
+ cache.lookupRepository(subRepo.getDirectory())
+ .close();
+ subRepo.close();
+ }
}
}
walk.release();

Back to the top