commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r826960 - /commons/proper/lang/trunk/src/java/org/apache/commons/lang/ObjectUtils.java
Date Tue, 20 Oct 2009 05:46:43 GMT
Author: bayard
Date: Tue Oct 20 05:46:43 2009
New Revision: 826960

URL: http://svn.apache.org/viewvc?rev=826960&view=rev
Log:
Moved identityToString(StringBuffer, Object) to identityToString(Appendable, Object) per LANG-542

Modified:
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/ObjectUtils.java

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/ObjectUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/ObjectUtils.java?rev=826960&r1=826959&r2=826960&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/ObjectUtils.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/ObjectUtils.java Tue Oct 20
05:46:43 2009
@@ -158,7 +158,7 @@
         if (object == null) {
             return null;
         }
-        StringBuffer buffer = new StringBuffer();
+        StringBuilder buffer = new StringBuilder();
         identityToString(buffer, object);
         return buffer.toString();
     }
@@ -178,13 +178,17 @@
      * @param object  the object to create a toString for
      * @since 2.4
      */
-    public static void identityToString(StringBuffer buffer, Object object) {
+    public static void identityToString(Appendable buffer, Object object) {
         if (object == null) {
             throw new NullPointerException("Cannot get the toString of a null identity");
         }
-        buffer.append(object.getClass().getName())
-              .append('@')
-              .append(Integer.toHexString(System.identityHashCode(object)));
+        try {
+            buffer.append(object.getClass().getName())
+                  .append('@')
+                  .append(Integer.toHexString(System.identityHashCode(object)));
+        } catch(java.io.IOException ioe) {
+            // can't happen - Appendable API forces it upon us
+        }
     }
 
     // ToString



Mime
View raw message