From a6ae23b3a9749a10f485958340412eaae72d22b6 Mon Sep 17 00:00:00 2001 From: Valera V Harseko Date: Wed, 8 Jul 2026 15:36:59 +0300 Subject: [PATCH] Use Objects.equals instead of hand-rolled String == comparison (CodeQL java/reference-equality-on-strings) ResourceResponseImpl.equals() delegated to a private isEqual(String, String) helper that started with a "s1 == s2" reference check. The reference compare was an intentional fast-path / both-null shortcut and the real value compare was done by s1.equals(s2), so the code was correct, but CodeQL flags the String == String and the helper simply reimplements java.util.Objects.equals. Replace the two isEqual calls with Objects.equals (already imported) and drop the helper. Behaviour is identical - Objects.equals performs the same "a == b || (a != null && a.equals(b))" null-safe comparison. --- .../java/org/forgerock/json/resource/Responses.java | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/commons/rest/json-resource/src/main/java/org/forgerock/json/resource/Responses.java b/commons/rest/json-resource/src/main/java/org/forgerock/json/resource/Responses.java index ac84141bc1..cd3f70118f 100644 --- a/commons/rest/json-resource/src/main/java/org/forgerock/json/resource/Responses.java +++ b/commons/rest/json-resource/src/main/java/org/forgerock/json/resource/Responses.java @@ -12,6 +12,7 @@ * information: "Portions copyright [year] [name of copyright owner]". * * Copyright 2015 ForgeRock AS. + * Portions Copyrighted 2026 3A Systems, LLC */ package org.forgerock.json.resource; @@ -250,22 +251,12 @@ public boolean equals(final Object obj) { return true; } else if (obj instanceof ResourceResponseImpl) { final ResourceResponseImpl that = (ResourceResponseImpl) obj; - return isEqual(id, that.id) && isEqual(revision, that.revision); + return Objects.equals(id, that.id) && Objects.equals(revision, that.revision); } else { return false; } } - private boolean isEqual(final String s1, final String s2) { - if (s1 == s2) { - return true; - } else if (s1 == null || s2 == null) { - return false; - } else { - return s1.equals(s2); - } - } - @Override public int hashCode() { final int hash = id != null ? id.hashCode() : 17;