Skip to content

Commit a9fe640

Browse files
author
Ryan O'Meara
committed
GH-22 Ensure a failure to clean up temporary files does not fail call
1 parent 29ae524 commit a9fe640

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

method-analyzer-core/src/main/java/com/synopsys/method/analyzer/core/report/ReportGenerator.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444

4545
import javax.annotation.Nullable;
4646

47+
import org.slf4j.Logger;
48+
import org.slf4j.LoggerFactory;
49+
4750
import com.google.common.collect.Lists;
4851
import com.google.common.collect.Multimap;
4952
import com.google.gson.Gson;
@@ -72,6 +75,9 @@ public class ReportGenerator {
7275

7376
private static final Gson GSON = new Gson();
7477

78+
/** Logger reference to output information to the application log files */
79+
private final Logger logger = LoggerFactory.getLogger(getClass());
80+
7581
private final MetaDataReportJson metaDataReport;
7682

7783
/**
@@ -182,10 +188,14 @@ private Path writeReport(Path destinationFile, List<MethodIdJson> uniqueMethodKe
182188
writeZipFile(destinationFile, outputFileMapping);
183189

184190
// GH-22: Explicitly clean up temporary files once use of them is complete
185-
try (Stream<Path> walk = Files.walk(workingDirectory)) {
186-
walk.sorted(Comparator.reverseOrder())
187-
.map(Path::toFile)
188-
.forEach(File::delete);
191+
try {
192+
try (Stream<Path> walk = Files.walk(workingDirectory)) {
193+
walk.sorted(Comparator.reverseOrder())
194+
.map(Path::toFile)
195+
.forEach(File::delete);
196+
}
197+
} catch (IOException e) {
198+
logger.warn("Error cleaning up temporary report files", e);
189199
}
190200

191201
return destinationFile;

0 commit comments

Comments
 (0)