LANG-1144: Multiple calls of org.apache.commons.lang3.concurrent.LazyInitializer.initialize() are possible
minimal clean-up
This commit is contained in:
parent
96c8ea2fb3
commit
dc53e49b4a
|
@ -78,11 +78,12 @@
|
|||
* @param <T> the type of the object managed by this initializer class
|
||||
*/
|
||||
public abstract class LazyInitializer<T> implements ConcurrentInitializer<T> {
|
||||
|
||||
private static final Object noInit = new Object();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
/** Stores the managed object. */
|
||||
|
||||
private static final Object NoInit = new Object();
|
||||
|
||||
private volatile T object = (T) NoInit;
|
||||
private volatile T object = (T) noInit;
|
||||
|
||||
/**
|
||||
* Returns the object wrapped by this instance. On first access the object
|
||||
|
@ -98,10 +99,10 @@ public T get() throws ConcurrentException {
|
|||
// volatile field
|
||||
T result = object;
|
||||
|
||||
if (result == NoInit) {
|
||||
if (result == noInit) {
|
||||
synchronized (this) {
|
||||
result = object;
|
||||
if (result == NoInit) {
|
||||
if (result == noInit) {
|
||||
object = result = initialize();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue