|
41 | 41 | import java.util.ArrayList;
|
42 | 42 | import java.util.Arrays;
|
43 | 43 | import java.util.Collections;
|
44 |
| -import java.util.Comparator; |
45 | 44 | import java.util.Iterator;
|
46 | 45 | import java.util.List;
|
47 | 46 | import java.util.Map;
|
@@ -622,9 +621,8 @@ static void saveBatchToFile(List<String> ids, BufferedWriter writer) throws IOEx
|
622 | 621 | * @param logPath whether to log path in the file or not
|
623 | 622 | */
|
624 | 623 | protected void iterateNodeTree(GarbageCollectorFileState fs, final boolean logPath) throws IOException {
|
625 |
| - final BufferedWriter writer = new BufferedWriter(new FileWriter(fs.getMarkedRefs(), StandardCharsets.UTF_8)); |
626 | 624 | final AtomicInteger count = new AtomicInteger();
|
627 |
| - try { |
| 625 | + try (BufferedWriter writer = new BufferedWriter(new FileWriter(fs.getMarkedRefs(), StandardCharsets.UTF_8))) { |
628 | 626 | marker.collectReferences(
|
629 | 627 | new ReferenceCollector() {
|
630 | 628 | private final boolean debugMode = LOG.isTraceEnabled();
|
@@ -663,21 +661,15 @@ public void addReference(String blobId, final String nodeId) {
|
663 | 661 | }
|
664 | 662 | }
|
665 | 663 | );
|
666 |
| - LOG.info("Number of valid blob references marked under mark phase of " + |
667 |
| - "Blob garbage collection [{}]", count.get()); |
668 |
| - // sort the marked references with the first part of the key |
669 |
| - sort(fs.getMarkedRefs(), |
670 |
| - new Comparator<String>() { |
671 |
| - @Override |
672 |
| - public int compare(String s1, String s2) { |
673 |
| - return s1.split(DELIM)[0].compareTo(s2.split(DELIM)[0]); |
674 |
| - } |
675 |
| - }); |
676 |
| - } finally { |
677 |
| - closeQuietly(writer); |
678 | 664 | }
|
| 665 | + |
| 666 | + LOG.info("Number of valid blob references marked under mark phase of " + |
| 667 | + "Blob garbage collection [{}]", count.get()); |
| 668 | + // sort the marked references with the first part of the key |
| 669 | + sort(fs.getMarkedRefs(), |
| 670 | + (s1, s2) -> s1.split(DELIM)[0].compareTo(s2.split(DELIM)[0])); |
679 | 671 | }
|
680 |
| - |
| 672 | + |
681 | 673 | @Override
|
682 | 674 | public long checkConsistency(boolean markOnly) throws Exception {
|
683 | 675 | consistencyStatsCollector.start();
|
|
0 commit comments