Updated ThreadSafeLazyLoadedivoryTower

Added null check in private constructor to prevent instantiating by Reflection call
This commit is contained in:
shaiktaj authored and GitHub committed 2017-05-25 11:04:30 -05:00
1 parent ae1d9cf7a8
commit 24f258848c
1 file changed
+6 -1
@@ -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