Quickfix: the cache file & dir management
@@ -318,17 +318,15 @@ public class VulnerabilityCacheProcessorPlugin extends Plugin {
var firstLetter = revision.groupId.substring(0, 1);
var outputPath = baseDir + File.separator + firstLetter +
File.separator + revision.groupId +
- File.separator + revision.artifactId;
+ File.separator + revision.artifactId +
+ File.separator + revision.version.toString() + ".json";
- File directory = new File(outputPath);
- if (!directory.exists()) {
- var result = directory.mkdir();
- }
-
- outputPath += File.separator + revision.version.toString() + ".json";
+ File outputFile = new File(outputPath);
+ outputFile.getParentFile().mkdirs();
- FileWriter outputFile = new FileWriter(outputPath);
- outputFile.write(output.toString());
+ FileWriter writer = new FileWriter(outputFile);
+ writer.write(output.toString());
+ writer.close();
} catch (IOException e) {
logger.error("Unable to persist the cache output in the file", e);
setPluginError(e);
