fix: Remove unnecessary and possibly not threadsafe flag (#1811)
This commit is contained in:
parent
e2ebb59fe7
commit
3126ad3106
@ -36,16 +36,12 @@ public final class ThreadSafeDoubleCheckLocking {
|
||||
|
||||
private static volatile ThreadSafeDoubleCheckLocking instance;
|
||||
|
||||
private static boolean flag = true;
|
||||
|
||||
/**
|
||||
* private constructor to prevent client from instantiating.
|
||||
*/
|
||||
private ThreadSafeDoubleCheckLocking() {
|
||||
// to prevent instantiating by Reflection call
|
||||
if (flag) {
|
||||
flag = false;
|
||||
} else {
|
||||
if (instance != null) {
|
||||
throw new IllegalStateException("Already initialized.");
|
||||
}
|
||||
}
|
||||
|
@ -34,9 +34,7 @@ public final class ThreadSafeLazyLoadedIvoryTower {
|
||||
|
||||
private ThreadSafeLazyLoadedIvoryTower() {
|
||||
// Protect against instantiation via reflection
|
||||
if (instance == null) {
|
||||
instance = this;
|
||||
} else {
|
||||
if (instance != null) {
|
||||
throw new IllegalStateException("Already initialized.");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user