From 48034eb9a1ebf0c3ee639ad0a6eb7dbd7aebd32d Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Wed, 29 Jul 2026 14:17:05 +0000
Subject: [PATCH] Fix wrong-equals-signature and inconsistent-equals-and-hashcode CodeQL alerts in AttributeDescription (#783)

---
 opendj-core/src/main/java/org/forgerock/opendj/ldap/AttributeDescription.java |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/AttributeDescription.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/AttributeDescription.java
index 3fcfc2c..d61ea31 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/AttributeDescription.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/AttributeDescription.java
@@ -13,6 +13,7 @@
  *
  * Copyright 2009-2010 Sun Microsystems, Inc.
  * Portions copyright 2011-2016 ForgeRock AS.
+ * Portions Copyright 2026 3A Systems, LLC.
  */
 package org.forgerock.opendj.ldap;
 
@@ -62,7 +63,12 @@
 
         public abstract boolean hasOption(String normalizedOption);
 
-        public abstract boolean equals(Impl other);
+        /**
+         * Options are compared by value, so this method must be kept consistent
+         * with {@link #hashCode()}.
+         */
+        @Override
+        public abstract boolean equals(Object other);
 
         public abstract String firstNormalizedOption();
 
@@ -130,7 +136,7 @@
         }
 
         @Override
-        public boolean equals(final Impl other) {
+        public boolean equals(final Object other) {
             if (other instanceof MultiOptionImpl) {
                 final MultiOptionImpl tmp = (MultiOptionImpl) other;
                 return Arrays.equals(normalizedOptions, tmp.normalizedOptions);
@@ -229,8 +235,13 @@
         }
 
         @Override
-        public boolean equals(final Impl other) {
-            return other.size() == 1 && other.hasOption(normalizedOption);
+        public boolean equals(final Object other) {
+            if (other instanceof Impl) {
+                final Impl tmp = (Impl) other;
+                return tmp.size() == 1 && tmp.hasOption(normalizedOption);
+            } else {
+                return false;
+            }
         }
 
         @Override
@@ -289,7 +300,7 @@
         }
 
         @Override
-        public boolean equals(final Impl other) {
+        public boolean equals(final Object other) {
             return this == other;
         }
 

--
Gitblit v1.10.0