From 5dc6e700cbcbc01833a02a193f660a286b934898 Mon Sep 17 00:00:00 2001 From: Keuin Date: Fri, 13 Jan 2023 02:49:57 +0800 Subject: Code cleanup. --- .../incremental/serializer/IncBackupInfoSerializer.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/main/java/com/keuin/kbackupfabric/backup/incremental/serializer/IncBackupInfoSerializer.java') diff --git a/src/main/java/com/keuin/kbackupfabric/backup/incremental/serializer/IncBackupInfoSerializer.java b/src/main/java/com/keuin/kbackupfabric/backup/incremental/serializer/IncBackupInfoSerializer.java index f17217a..c5d1115 100644 --- a/src/main/java/com/keuin/kbackupfabric/backup/incremental/serializer/IncBackupInfoSerializer.java +++ b/src/main/java/com/keuin/kbackupfabric/backup/incremental/serializer/IncBackupInfoSerializer.java @@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Objects; +import java.util.stream.Stream; public class IncBackupInfoSerializer { /** @@ -77,10 +78,12 @@ public class IncBackupInfoSerializer { throw new IllegalArgumentException("Given directory is invalid."); } List pathList = new ArrayList<>(); - Files.walk(directory.toPath(), 1).filter(p -> { - File f = p.toFile(); - return f.isFile() && f.getName().endsWith(".kbi"); - }).forEach(pathList::add); + try (Stream walk = Files.walk(directory.toPath(), 1)) { + walk.filter(p -> { + File f = p.toFile(); + return f.isFile() && f.getName().endsWith(".kbi"); + }).forEach(pathList::add); + } List objectList = new ArrayList<>(); for (Path path : pathList) { SavedIncrementalBackup info = IncBackupInfoSerializer.fromFile(path.toFile()); -- cgit v1.2.3