public synchronized V loadAndGet ( ) throws ExecutionException { try { value = Optional . ofNullable ( valueFetcher . call ( ) ) ; } catch ( final Exception e ) { throw new ExecutionException ( e ) ; } finally { writeTime = Optional . of ( currentTime . now ( ) ) ; this . notifyAll ( ) ; } if ( ! value . isPresent ( ) ) { throw new ExecutionException ( new NullPointerException ( "valueFetcher returned null" ) ) ; } else { return value . get ( ) ; } }
Must only be called once by the thread that created this WrappedValue .