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:
pascalschumacher 2016-10-25 00:40:48 +02:00
parent 383bc8eefa
commit eafeca4326
1 changed files with 4 additions and 4 deletions

View File

@ -79,11 +79,11 @@ package org.apache.commons.lang3.concurrent;
*/ */
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 abstract class LazyInitializer<T> implements ConcurrentInitializer<T> {
// 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();
} }
} }