From 10a2eb540f560844cab43c2279060f53446e780f Mon Sep 17 00:00:00 2001 From: arybakov Date: Tue, 28 Nov 2023 14:09:42 -0700 Subject: [PATCH] Fixed code smell --- .../educ/api/gradbusiness/service/GradBusinessService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradbusiness/service/GradBusinessService.java b/api/src/main/java/ca/bc/gov/educ/api/gradbusiness/service/GradBusinessService.java index 3e71b16..57d58f2 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/gradbusiness/service/GradBusinessService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/gradbusiness/service/GradBusinessService.java @@ -367,9 +367,9 @@ private void saveBinaryResponseToFile(byte[] resultBinary, String reportFile) th String pathToFile = TMP + File.separator + reportFile; logger.debug("Save generated PDF {} on the file system", reportFile); File fileToSave = new File(pathToFile); - if(fileToSave.exists()) { - boolean isDeleted = fileToSave.delete(); - logger.debug("{} to delete existing PDF {}", isDeleted, reportFile); + boolean isDeleted = Files.deleteIfExists(fileToSave.toPath()); + if(isDeleted) { + logger.debug("Delete existing PDF {}", reportFile); } Files.write(fileToSave.toPath(), resultBinary); logger.debug("PDF {} saved successfully", pathToFile);