public class SingletonDoubleCheckedLock {
    private volatile static SingletonDoubleCheckedLock uniqueInstance;
    private SingletonDoubleCheckedLock() {
    }
    public static SingletonDoubleCheckedLock getInstance() {
            if (uniqueInstance == null) {
                    synchronized (SingletonDoubleCheckedLock.class) {
                            if (uniqueInstance == null) {
                                    uniqueInstance = new SingletonDoubleCheckedLock();
                            }
                    }
            }
            return uniqueInstance;
    }
}
If any error occurs when running the getInstance() method (e.g. when executing new SingletonDoubleCheckedLock() but there isn't enough memory) and I still want the  getInstance() method return the right result. How to achieve this? 
 
    