diff options
Diffstat (limited to 'org.eclipse.jgit.http.server')
-rw-r--r-- | org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/RepositoryFilter.java | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/RepositoryFilter.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/RepositoryFilter.java index c89a5d762c..b9e82c27f6 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/RepositoryFilter.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/RepositoryFilter.java @@ -140,9 +140,9 @@ public class RepositoryFilter implements Filter { return; } - final Repository db; - try { - db = resolver.open(req, name); + try (Repository db = resolver.open(req, name)) { + request.setAttribute(ATTRIBUTE_REPOSITORY, db); + chain.doFilter(request, response); } catch (RepositoryNotFoundException e) { sendError(req, res, SC_NOT_FOUND); return; @@ -155,13 +155,8 @@ public class RepositoryFilter implements Filter { } catch (ServiceMayNotContinueException e) { sendError(req, res, e.getStatusCode(), e.getMessage()); return; - } - try { - request.setAttribute(ATTRIBUTE_REPOSITORY, db); - chain.doFilter(request, response); } finally { request.removeAttribute(ATTRIBUTE_REPOSITORY); - db.close(); } } } |