From 03536cc2d04f66e2167e4e9d068aa515c4286ff0 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Tue, 6 Mar 2018 17:15:04 +0900 Subject: [PATCH] FileLfsServlet: Open PrintWriter in try-with-resource Change-Id: I6fa225e541c6d5c3dbf3d852a502f4e9c4f7d77e Signed-off-by: David Pursehouse --- .../org/eclipse/jgit/lfs/server/fs/FileLfsServlet.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/FileLfsServlet.java b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/FileLfsServlet.java index 018102f79..36dc7606b 100644 --- a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/FileLfsServlet.java +++ b/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(); } }