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. 8
      org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/FileLfsServlet.java

8
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)
throws IOException {
rsp.setStatus(status);
PrintWriter writer = rsp.getWriter();
LfsGson.toJson(message, writer);
writer.flush();
writer.close();
try (PrintWriter writer = rsp.getWriter()) {
LfsGson.toJson(message, writer);
writer.flush();
}
rsp.flushBuffer();
}
}

Loading…
Cancel
Save