mirror of
https://github.com/apache/commons-lang.git
synced 2025-02-08 11:05:09 +00:00
LANG-1144: Multiple calls of org.apache.commons.lang3.concurrent.LazyInitializer.initialize() are possible
use all uppercase name for constant
This commit is contained in:
parent
383bc8eefa
commit
eafeca4326
@ -79,11 +79,11 @@
|
|||||||
*/
|
*/
|
||||||
public abstract class LazyInitializer<T> implements ConcurrentInitializer<T> {
|
public abstract class LazyInitializer<T> implements ConcurrentInitializer<T> {
|
||||||
|
|
||||||
private static final Object noInit = new Object();
|
private static final Object NO_INIT = new Object();
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
/** Stores the managed object. */
|
/** Stores the managed object. */
|
||||||
private volatile T object = (T) noInit;
|
private volatile T object = (T) NO_INIT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the object wrapped by this instance. On first access the object
|
* Returns the object wrapped by this instance. On first access the object
|
||||||
@ -99,10 +99,10 @@ public T get() throws ConcurrentException {
|
|||||||
// volatile field
|
// volatile field
|
||||||
T result = object;
|
T result = object;
|
||||||
|
|
||||||
if (result == noInit) {
|
if (result == NO_INIT) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
result = object;
|
result = object;
|
||||||
if (result == noInit) {
|
if (result == NO_INIT) {
|
||||||
object = result = initialize();
|
object = result = initialize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user