Browse Source

FileSender: Open OutputStream in try-with-resource

Change-Id: I2278950998dffc2b5730a91a5bb3bcc38f4d446b
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
stable-4.11
David Pursehouse 7 years ago
parent
commit
07341b2947
  1. 5
      org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/FileSender.java

5
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/FileSender.java

@ -137,8 +137,7 @@ final class FileSender {
rsp.setHeader(HDR_CONTENT_LENGTH, Long.toString(end - pos)); rsp.setHeader(HDR_CONTENT_LENGTH, Long.toString(end - pos));
if (sendBody) { if (sendBody) {
final OutputStream out = rsp.getOutputStream(); try (OutputStream out = rsp.getOutputStream()) {
try {
final byte[] buf = new byte[4096]; final byte[] buf = new byte[4096];
source.seek(pos); source.seek(pos);
while (pos < end) { while (pos < end) {
@ -151,8 +150,6 @@ final class FileSender {
pos += n; pos += n;
} }
out.flush(); out.flush();
} finally {
out.close();
} }
} }
} }

Loading…
Cancel
Save