Updated ThreadSafeLazyLoadedivoryTower

Added null check in private constructor to prevent instantiating by Reflection call
This commit is contained in:
shaiktaj 2017-05-25 11:04:30 -05:00 committed by GitHub
parent ae1d9cf7a8
commit 24f258848c

View File

@ -33,7 +33,12 @@ public final class ThreadSafeLazyLoadedIvoryTower {
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