You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by gg...@apache.org on 2022/08/25 12:36:03 UTC

[httpcomponents-core] 01/02: Deprecate org.apache.hc.core5.util.LangUtils.equals(Object[], Object[]) in favor or java.util.Arrays.equals(Object[], Object[]).

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git

commit f813fb9023824379a38a5fa9ae7b7e03431ea41e
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Aug 25 08:23:19 2022 -0400

    Deprecate org.apache.hc.core5.util.LangUtils.equals(Object[], Object[])
    in favor or java.util.Arrays.equals(Object[], Object[]).
---
 RELEASE_NOTES.txt                                        |  6 ++++++
 .../main/java/org/apache/hc/core5/util/LangUtils.java    | 16 ++++------------
 2 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index f524b55d1..4aaf4ef6e 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -1,3 +1,9 @@
+Release 5.2 BETA3
+------------------
+
+* Deprecate org.apache.hc.core5.util.LangUtils.equals(Object[], Object[]) in favor or java.util.Arrays.equals(Object[], Object[]).
+
+
 Release 5.2 BETA2
 ------------------
 
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/util/LangUtils.java b/httpcore5/src/main/java/org/apache/hc/core5/util/LangUtils.java
index 6857bd2a3..eca1b7f16 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/util/LangUtils.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/util/LangUtils.java
@@ -27,6 +27,7 @@
 
 package org.apache.hc.core5.util;
 
+import java.util.Arrays;
 import java.util.Objects;
 
 /**
@@ -81,20 +82,11 @@ public final class LangUtils {
      * @param a1 first array to compare, may be {@code null}
      * @param a2 second array to compare, may be {@code null}
      * @return {@code true} if the arrays are equal or both null
+     * @deprecated Use {@link Arrays#equals(Object)}.
      */
+    @Deprecated
     public static boolean equals(final Object[] a1, final Object[] a2) {
-        if (a1 == null) {
-            return a2 == null;
-        }
-        if (a2 != null && a1.length == a2.length) {
-            for (int i = 0; i < a1.length; i++) {
-                if (!equals(a1[i], a2[i])) {
-                    return false;
-                }
-            }
-            return true;
-        }
-        return false;
+        return Arrays.equals(a1, a2);
     }
 
 }