Skip to content

Commit 96a7195

Browse files
Use try-with for resource in test HttpServer (#1521) (#1686)
1 parent 60ee5c0 commit 96a7195

File tree

1 file changed

+1
-13
lines changed
  • maven-resolver-test-http/src/main/java/org/eclipse/aether/internal/test/util/http

1 file changed

+1
-13
lines changed

maven-resolver-test-http/src/main/java/org/eclipse/aether/internal/test/util/http/HttpServer.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -424,26 +424,14 @@ public void handle(String target, Request req, HttpServletRequest request, HttpS
424424
if (HttpMethod.HEAD.is(req.getMethod())) {
425425
return;
426426
}
427-
FileInputStream is = null;
428-
try {
429-
is = new FileInputStream(file);
427+
try (FileInputStream is = new FileInputStream(file)) {
430428
if (offset > 0L) {
431429
long skipped = is.skip(offset);
432430
while (skipped < offset && is.read() >= 0) {
433431
skipped++;
434432
}
435433
}
436434
IO.copy(is, response.getOutputStream());
437-
is.close();
438-
is = null;
439-
} finally {
440-
try {
441-
if (is != null) {
442-
is.close();
443-
}
444-
} catch (final IOException e) {
445-
// Suppressed due to an exception already thrown in the try block.
446-
}
447435
}
448436
} else if (HttpMethod.PUT.is(req.getMethod())) {
449437
if (!webDav) {

0 commit comments

Comments
 (0)