diff --git a/src/main/java/org/apache/commons/lang3/ObjectUtils.java b/src/main/java/org/apache/commons/lang3/ObjectUtils.java index ea59208d7dc..0bfa347efcf 100644 --- a/src/main/java/org/apache/commons/lang3/ObjectUtils.java +++ b/src/main/java/org/apache/commons/lang3/ObjectUtils.java @@ -1264,8 +1264,7 @@ public static T requireNonEmpty(final T obj, final String message) { } /** - * Gets the {@code toString} of an {@link Object} returning - * an empty string ("") if {@code null} input. + * Gets the {@code toString()} of an {@link Object} or the empty string ({@code ""}) if the input is {@code null}. * *
      * ObjectUtils.toString(null)         = ""
@@ -1278,14 +1277,10 @@ public static  T requireNonEmpty(final T obj, final String message) {
      * @see Objects#toString(Object, String)
      * @see StringUtils#defaultString(String)
      * @see String#valueOf(Object)
-     * @param obj  the Object to {@code toString}, may be null
-     * @return the passed in Object's toString, or {@code ""} if {@code null} input
+     * @param obj  the Object to {@code toString()}, may be {@code null}.
+     * @return the input's {@code toString()}, or {@code ""} if the input is {@code null}.
      * @since 2.0
-     * @deprecated this method has been replaced by {@code java.util.Objects.toString(Object)} in Java 7 and will be
-     * removed in future releases. Note however that said method will return "null" for null references, while this
-     * method returns an empty String. To preserve behavior use {@code java.util.Objects.toString(myObject, "")}
      */
-    @Deprecated
     public static String toString(final Object obj) {
         return Objects.toString(obj, StringUtils.EMPTY);
     }
diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java
index b9f6729acd4..0c5cbc76c4a 100644
--- a/src/main/java/org/apache/commons/lang3/StringUtils.java
+++ b/src/main/java/org/apache/commons/lang3/StringUtils.java
@@ -4268,7 +4268,7 @@ public static String join(final Iterator iterator, final char separator) {
         if (!iterator.hasNext()) {
             return EMPTY;
         }
-        return Streams.of(iterator).collect(LangCollectors.joining(toString(String.valueOf(separator)), EMPTY, EMPTY, StringUtils::toString));
+        return Streams.of(iterator).collect(LangCollectors.joining(ObjectUtils.toString(String.valueOf(separator)), EMPTY, EMPTY, ObjectUtils::toString));
     }
 
     /**
@@ -4292,7 +4292,7 @@ public static String join(final Iterator iterator, final String separator) {
         if (!iterator.hasNext()) {
             return EMPTY;
         }
-        return Streams.of(iterator).collect(LangCollectors.joining(toString(separator), EMPTY, EMPTY, StringUtils::toString));
+        return Streams.of(iterator).collect(LangCollectors.joining(ObjectUtils.toString(separator), EMPTY, EMPTY, ObjectUtils::toString));
     }
 
     /**
@@ -4529,7 +4529,7 @@ public static String join(final Object[] array, final char delimiter, final int
      * @return the joined String, {@code null} if null array input
      */
     public static String join(final Object[] array, final String delimiter) {
-        return array != null ? join(array, toString(delimiter), 0, array.length) : null;
+        return array != null ? join(array, ObjectUtils.toString(delimiter), 0, array.length) : null;
     }
 
     /**
@@ -4569,7 +4569,7 @@ public static String join(final Object[] array, final String delimiter) {
      */
     public static String join(final Object[] array, final String delimiter, final int startIndex, final int endIndex) {
         return array != null ? Streams.of(array).skip(startIndex).limit(Math.max(0, endIndex - startIndex))
-            .collect(LangCollectors.joining(delimiter, EMPTY, EMPTY, StringUtils::toString)) : null;
+            .collect(LangCollectors.joining(delimiter, EMPTY, EMPTY, ObjectUtils::toString)) : null;
     }
 
     /**
@@ -6302,7 +6302,7 @@ public static String replaceChars(final String str, final String searchChars, St
         if (isEmpty(str) || isEmpty(searchChars)) {
             return str;
         }
-        replaceChars = toString(replaceChars);
+        replaceChars = ObjectUtils.toString(replaceChars);
         boolean modified = false;
         final int replaceCharsLength = replaceChars.length();
         final int strLength = str.length();
@@ -8760,17 +8760,6 @@ public static String toString(final byte[] bytes, final String charsetName) {
         return new String(bytes, Charsets.toCharset(charsetName));
     }
 
-    /**
-     * Returns the result of calling {@code toString} on argument if the argument is not {@code null} and returns the empty String otherwise.
-     *
-     * @param o           an object
-     * @return the result of calling {@code toString} on the argument if it is not {@code null} and the empty String otherwise.
-     * @see Objects#toString(Object)
-     */
-    private static String toString(final Object obj) {
-        return Objects.toString(obj, EMPTY);
-    }
-
     /**
      * Removes control characters (char <= 32) from both
      * ends of this String, handling {@code null} by returning