diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2018-06-11 10:54:50 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2018-06-11 10:54:59 +0200 |
commit | e512d919ecbb0fcbf45d3ac954863e7d190917d0 (patch) | |
tree | db3a56bf608b1b9c1e446640c0d2891f58fbf2b0 | |
parent | 9fdc595cdddac5913a2f3d512cc7787bebc3b687 (diff) | |
parent | 5fe8e31d4351a9d26db81e799defd8225e883f3e (diff) | |
download | jgit-e512d919ecbb0fcbf45d3ac954863e7d190917d0.tar.gz jgit-e512d919ecbb0fcbf45d3ac954863e7d190917d0.zip |
Merge branch 'stable-4.9' into stable-4.10
* stable-4.9:
Ensure DirectoryStream is closed promptly
Change-Id: I62674a1db9266c04fb353ab697e2c0a24a7369b7
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java index c1fbe65de8..6df09fbb32 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java @@ -967,19 +967,19 @@ public class GC { private void deleteTempPacksIdx() { Path packDir = repo.getObjectDatabase().getPackDirectory().toPath(); Instant threshold = Instant.now().minus(1, ChronoUnit.DAYS); - try { - Files.newDirectoryStream(packDir, "gc_*_tmp") //$NON-NLS-1$ - .forEach(t -> { - try { - Instant lastModified = Files.getLastModifiedTime(t) - .toInstant(); - if (lastModified.isBefore(threshold)) { - Files.deleteIfExists(t); - } - } catch (IOException e) { - LOG.error(e.getMessage(), e); - } - }); + try (DirectoryStream<Path> stream = + Files.newDirectoryStream(packDir, "gc_*_tmp")) { //$NON-NLS-1$ + stream.forEach(t -> { + try { + Instant lastModified = Files.getLastModifiedTime(t) + .toInstant(); + if (lastModified.isBefore(threshold)) { + Files.deleteIfExists(t); + } + } catch (IOException e) { + LOG.error(e.getMessage(), e); + } + }); } catch (IOException e) { LOG.error(e.getMessage(), e); } |