[LANG-1144]

Multiple calls of
org.apache.commons.lang3.concurrent.LazyInitializer.initialize() are
possible.
This commit is contained in:
Gary Gregory 2016-10-23 10:33:29 -07:00
parent 65ed41ff7a
commit e4c72a5522
2 changed files with 8 additions and 4 deletions

View File

@ -45,7 +45,8 @@ The <action> type attribute can be add,update,fix,remove.
</properties>
<body>
<release version="3.6" date="tba" description="tba">
<release version="3.6" date="2016-MM-DD" description="TBD">
<action issue="LANG-1144" type="fix" dev="ggregory" due-to="Waldemar Maier, Gary Gregory">Multiple calls of org.apache.commons.lang3.concurrent.LazyInitializer.initialize() are possible.</action>
<action issue="LANG-1276" type="fix" dev="pschumacher" due-to="Andy Klimczak">StrBuilder#replaceAll ArrayIndexOutOfBoundsException</action>
<action issue="LANG-1278" type="fix" dev="pschumacher" due-to="Duke Yin">BooleanUtils javadoc issues</action>
<action issue="LANG-1277" type="update" dev="pschumacher" due-to="yufcuy">StringUtils#getLevenshteinDistance reduce memory consumption</action>

View File

@ -79,7 +79,10 @@ package org.apache.commons.lang3.concurrent;
*/
public abstract class LazyInitializer<T> implements ConcurrentInitializer<T> {
/** Stores the managed object. */
private volatile T object;
private static final Object NoInit = new Object();
private volatile T object = (T) NoInit;
/**
* Returns the object wrapped by this instance. On first access the object
@ -95,10 +98,10 @@ public abstract class LazyInitializer<T> implements ConcurrentInitializer<T> {
// volatile field
T result = object;
if (result == null) {
if (result == NoInit) {
synchronized (this) {
result = object;
if (result == null) {
if (result == NoInit) {
object = result = initialize();
}
}