From 069a1256c6ebdc1142e525a44733bc32fd834061 Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Tue, 04 Aug 2026 11:37:29 +0000
Subject: [PATCH] Fix CodeQL note-severity alerts: ignored error status of file and stream calls (#814)

---
 opendj-server-legacy/src/main/java/org/opends/server/config/ConfigurationHandler.java |   31 ++++++-------------------------
 1 files changed, 6 insertions(+), 25 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/config/ConfigurationHandler.java b/opendj-server-legacy/src/main/java/org/opends/server/config/ConfigurationHandler.java
index 892643d..011b250 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/config/ConfigurationHandler.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/config/ConfigurationHandler.java
@@ -817,25 +817,14 @@
     }
 
     // If a ".startok" file already exists, then move it to an ".old" file.
+    // renameFile() deletes an existing ".old" file and reports a failure to do so.
     File oldFile = new File(oldFilePath);
-    try
-    {
-      if (oldFile.exists())
-      {
-        oldFile.delete();
-      }
-    }
-    catch (Exception e)
-    {
-      logger.traceException(e);
-    }
-
     File startOKFile = new File(startOKFilePath);
     try
     {
       if (startOKFile.exists())
       {
-        startOKFile.renameTo(oldFile);
+        renameFile(startOKFile, oldFile);
       }
     }
     catch (Exception e)
@@ -846,7 +835,7 @@
     // Rename the temp file to the ".startok" file.
     try
     {
-      tempFile.renameTo(startOKFile);
+      renameFile(tempFile, startOKFile);
     }
     catch (Exception e)
     {
@@ -1609,20 +1598,12 @@
 
     // Move the current config file out of the way and replace it with the updated version.
     File oldSource = new File(sourceFile.getAbsolutePath() + ".prechanges");
-    if (oldSource.exists())
-    {
-      oldSource.delete();
-    }
-    sourceFile.renameTo(oldSource);
-    new File(tempFilePath).renameTo(sourceFile);
+    renameFile(sourceFile, oldSource);
+    renameFile(new File(tempFilePath), sourceFile);
 
     // Move the changes file out of the way so it doesn't get applied again.
     File newChanges = new File(changesFile.getAbsolutePath() + ".applied");
-    if (newChanges.exists())
-    {
-      newChanges.delete();
-    }
-    changesFile.renameTo(newChanges);
+    renameFile(changesFile, newChanges);
   }
 
   private void applyConfigChangesIfNeeded(File configFileToUse) throws InitializationException

--
Gitblit v1.10.0