diff options
author | David Pursehouse <david.pursehouse@gmail.com> | 2018-03-13 17:55:05 +0900 |
---|---|---|
committer | David Pursehouse <david.pursehouse@gmail.com> | 2018-03-14 10:44:23 +0900 |
commit | 98667d385149a64ca0be04419e3329472a33892d (patch) | |
tree | 04cf7fb5d02d692083a6a6ca585e1b237515567b /org.eclipse.jgit.http.server | |
parent | fe6c97bc4cc01a80f29e1af880bf106745989670 (diff) | |
download | jgit-98667d385149a64ca0be04419e3329472a33892d.tar.gz jgit-98667d385149a64ca0be04419e3329472a33892d.zip |
RepositoryFilter: Refactor doFilter to open Repository in try-with-resource
Change-Id: Ic4a056eebe567ff933519d6a805edb7e97c71b22
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
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(); } } } |