diff options
author | David Pursehouse <david.pursehouse@gmail.com> | 2018-03-07 08:27:06 +0900 |
---|---|---|
committer | David Pursehouse <david.pursehouse@gmail.com> | 2018-03-07 08:27:06 +0900 |
commit | 2c5b721161e40cdcfa76548739117ea198ed8942 (patch) | |
tree | 0ce3073b3bc09cc209532a3ea34d560e776c1e4d /org.eclipse.jgit.http.server | |
parent | de96131d36e0b8ee4a595cb60e7accf26cf14106 (diff) | |
download | jgit-2c5b721161e40cdcfa76548739117ea198ed8942.tar.gz jgit-2c5b721161e40cdcfa76548739117ea198ed8942.zip |
InfoRefsServlet: Open OutputStreamWriter in try-with-resource
Change-Id: Iaf93d5c020ee67e9effbe93334f1ad419ffaee1f
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/InfoRefsServlet.java | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/InfoRefsServlet.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/InfoRefsServlet.java index ccb76adca0..4f70cf7004 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/InfoRefsServlet.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/InfoRefsServlet.java @@ -74,29 +74,30 @@ class InfoRefsServlet extends HttpServlet { rsp.setCharacterEncoding(Constants.CHARACTER_ENCODING); final Repository db = getRepository(req); - final OutputStreamWriter out = new OutputStreamWriter( + try (OutputStreamWriter out = new OutputStreamWriter( new SmartOutputStream(req, rsp, true), - Constants.CHARSET); - final RefAdvertiser adv = new RefAdvertiser() { - @Override - protected void writeOne(final CharSequence line) throws IOException { - // Whoever decided that info/refs should use a different - // delimiter than the native git:// protocol shouldn't - // be allowed to design this sort of stuff. :-( - out.append(line.toString().replace(' ', '\t')); - } + Constants.CHARSET)) { + final RefAdvertiser adv = new RefAdvertiser() { + @Override + protected void writeOne(final CharSequence line) + throws IOException { + // Whoever decided that info/refs should use a different + // delimiter than the native git:// protocol shouldn't + // be allowed to design this sort of stuff. :-( + out.append(line.toString().replace(' ', '\t')); + } - @Override - protected void end() { - // No end marker required for info/refs format. - } - }; - adv.init(db); - adv.setDerefTags(true); + @Override + protected void end() { + // No end marker required for info/refs format. + } + }; + adv.init(db); + adv.setDerefTags(true); - Map<String, Ref> refs = db.getRefDatabase().getRefs(ALL); - refs.remove(Constants.HEAD); - adv.send(refs); - out.close(); + Map<String, Ref> refs = db.getRefDatabase().getRefs(ALL); + refs.remove(Constants.HEAD); + adv.send(refs); + } } } |