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(); } }