FileSender: Open OutputStream in try-with-resource
Change-Id: I2278950998dffc2b5730a91a5bb3bcc38f4d446b Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
This commit is contained in:
parent
d1356bf238
commit
07341b2947
|
@ -137,8 +137,7 @@ void serve(final HttpServletRequest req, final HttpServletResponse rsp,
|
|||
rsp.setHeader(HDR_CONTENT_LENGTH, Long.toString(end - pos));
|
||||
|
||||
if (sendBody) {
|
||||
final OutputStream out = rsp.getOutputStream();
|
||||
try {
|
||||
try (OutputStream out = rsp.getOutputStream()) {
|
||||
final byte[] buf = new byte[4096];
|
||||
source.seek(pos);
|
||||
while (pos < end) {
|
||||
|
@ -151,8 +150,6 @@ void serve(final HttpServletRequest req, final HttpServletResponse rsp,
|
|||
pos += n;
|
||||
}
|
||||
out.flush();
|
||||
} finally {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue