Browse Source

FileLfsServlet: Open PrintWriter in try-with-resource

Change-Id: I6fa225e541c6d5c3dbf3d852a502f4e9c4f7d77e
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
stable-4.11
David Pursehouse 7 years ago
parent
commit
03536cc2d0
  1. 4
      org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/FileLfsServlet.java

4
org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/FileLfsServlet.java

@ -178,10 +178,10 @@ public class FileLfsServlet extends HttpServlet {
protected static void sendError(HttpServletResponse rsp, int status, String message) protected static void sendError(HttpServletResponse rsp, int status, String message)
throws IOException { throws IOException {
rsp.setStatus(status); rsp.setStatus(status);
PrintWriter writer = rsp.getWriter(); try (PrintWriter writer = rsp.getWriter()) {
LfsGson.toJson(message, writer); LfsGson.toJson(message, writer);
writer.flush(); writer.flush();
writer.close(); }
rsp.flushBuffer(); rsp.flushBuffer();
} }
} }

Loading…
Cancel
Save