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/tools/upgrade/LicenseFile.java | 19 +++++++++++++++----
1 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/LicenseFile.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/LicenseFile.java
index 1cd2940..eab5eab 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/LicenseFile.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/LicenseFile.java
@@ -13,6 +13,7 @@
*
* Copyright 2006-2010 Sun Microsystems, Inc.
* Portions Copyright 2013-2016 ForgeRock AS.
+ * Portions Copyright 2026 3A Systems, LLC.
*/
package org.opends.server.tools.upgrade;
@@ -21,6 +22,8 @@
import java.io.FileReader;
import java.io.IOException;
+import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.util.StaticUtils;
/**
@@ -31,6 +34,8 @@
*/
class LicenseFile
{
+ private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
+
private static final String INSTALL_ROOT_SYSTEM_PROPERTY = "INSTALL_ROOT";
/**
@@ -80,9 +85,9 @@
final String instanceDirname = UpgradeUtils.getInstancePathFromInstallPath(getInstallRootPathFromSystem("."));
final String instanceLegalDirName = instanceDirname + File.separator + LEGAL_FOLDER_NAME;
final File instanceLegalDir = new File(instanceLegalDirName);
- if (!instanceLegalDir.exists())
+ if (!instanceLegalDir.isDirectory() && !instanceLegalDir.mkdirs())
{
- instanceLegalDir.mkdir();
+ logger.warn(LocalizableMessage.raw("Unable to create the legal directory %s", instanceLegalDirName));
}
return instanceLegalDirName;
}
@@ -197,12 +202,18 @@
{
if (getApproval())
{
+ final File approvalFile = new File(getInstanceLegalDirectory(), ACCEPTED_LICENSE_FILE_NAME);
try
{
- new File(getInstanceLegalDirectory(), ACCEPTED_LICENSE_FILE_NAME).createNewFile();
+ if (!approvalFile.createNewFile() && !approvalFile.isFile())
+ {
+ logger.warn(LocalizableMessage.raw("Unable to create the license approval file %s", approvalFile));
+ }
}
catch (IOException e)
- { // do nothing
+ {
+ logger.warn(LocalizableMessage.raw(
+ "Unable to create the license approval file %s: %s", approvalFile, e.getLocalizedMessage()));
}
}
}
--
Gitblit v1.10.0