Updated ThreadSafeLazyLoadedivoryTower
Added null check in private constructor to prevent instantiating by Reflection call
This commit is contained in:
parent
ae1d9cf7a8
commit
24f258848c
@ -33,7 +33,12 @@ public final class ThreadSafeLazyLoadedIvoryTower {
|
|||||||
|
|
||||||
private static ThreadSafeLazyLoadedIvoryTower instance;
|
private static ThreadSafeLazyLoadedIvoryTower instance;
|
||||||
|
|
||||||
private ThreadSafeLazyLoadedIvoryTower() {}
|
private ThreadSafeLazyLoadedIvoryTower() {
|
||||||
|
// to prevent instantiating by Reflection call
|
||||||
|
if (instance != null) {
|
||||||
|
throw new IllegalStateException("Already initialized.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The instance gets created only when it is called for first time. Lazy-loading
|
* The instance gets created only when it is called for first time. Lazy-loading
|
||||||
|
Loading…
x
Reference in New Issue
Block a user