Modifying toString method to cache in a thread-safe way per LANG-481
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@900015 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
01067903aa
commit
6913747d7d
|
@ -350,16 +350,18 @@ public final class Range<T> implements Serializable {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
if (toString == null) {
|
String result = toString;
|
||||||
|
if (result == null) {
|
||||||
StringBuilder buf = new StringBuilder(32);
|
StringBuilder buf = new StringBuilder(32);
|
||||||
buf.append("Range[");
|
buf.append("Range[");
|
||||||
buf.append(this.minimum);
|
buf.append(this.minimum);
|
||||||
buf.append(',');
|
buf.append(',');
|
||||||
buf.append(this.maximum);
|
buf.append(this.maximum);
|
||||||
buf.append(']');
|
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
|
// Taken from Commons Collections - documentation removed as not a public class
|
||||||
|
|
Loading…
Reference in New Issue