private void blockingRefresh ( ) { try { if ( blockingRefreshLock . tryLock ( BLOCKING_REFRESH_MAX_WAIT_IN_SECONDS , TimeUnit . SECONDS ) ) { try { // Return if successful refresh occurred while waiting for the lock if ( ! shouldDoBlockingRefresh ( ) ) { return ; } else { // Otherwise do a synchronous refresh if the last lock holder was unable to // refresh the value refreshValue ( ) ; return ; } } finally { blockingRefreshLock . unlock ( ) ; } } } catch ( InterruptedException ex ) { handleInterruptedException ( "Interrupted waiting to refresh the value." , ex ) ; } // Couldn't acquire the lock. Just try a synchronous refresh refreshValue ( ) ; }
Used when there is no valid value to return . Callers are blocked until a new value is created or an exception is thrown .