commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r900015 - /commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/Range.java
Date Sat, 16 Jan 2010 19:50:34 GMT
Author: bayard
Date: Sat Jan 16 19:50:33 2010
New Revision: 900015

URL: http://svn.apache.org/viewvc?rev=900015&view=rev
Log:
Modifying toString method to cache in a thread-safe way per LANG-481

Modified:
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/Range.java

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/Range.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/Range.java?rev=900015&r1=900014&r2=900015&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/Range.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/Range.java Sat Jan 16
19:50:33 2010
@@ -350,16 +350,18 @@
      */
     @Override
     public String toString() {
-        if (toString == null) {
+        String result = toString;
+        if (result == null) {
             StringBuilder buf = new StringBuilder(32);
             buf.append("Range[");
             buf.append(this.minimum);
             buf.append(',');
             buf.append(this.maximum);
             buf.append(']');
-            toString = buf.toString();
+            result = buf.toString();
+            toString = result;
         }
-        return toString;
+        return result;
     }
 
     // Taken from Commons Collections - documentation removed as not a public class



Mime
View raw message