summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2018-06-11 10:54:50 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2018-06-11 10:54:59 +0200
commite512d919ecbb0fcbf45d3ac954863e7d190917d0 (patch)
treedb3a56bf608b1b9c1e446640c0d2891f58fbf2b0
parent9fdc595cdddac5913a2f3d512cc7787bebc3b687 (diff)
parent5fe8e31d4351a9d26db81e799defd8225e883f3e (diff)
downloadjgit-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.java26
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);
}