/** * Forces a refresh of the value. This method will not attempt to lock on calls to refresh the * value. * * @throws AmazonClientException If error occurs during refresh. * @throws IllegalStateException If value if invalid after refreshing. */ public T forceGetValue() { refreshValue(); return getRefreshedValue(); }
/** * Used when there is no valid value to return. Callers are blocked until a new value is created * or an exception is thrown. */ 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(); }
/** * Forces a refresh of the value. This method will not attempt to lock on calls to refresh the * value. * * @throws AmazonClientException If error occurs during refresh. * @throws IllegalStateException If value if invalid after refreshing. */ public T forceGetValue() { refreshValue(); return getRefreshedValue(); }
/** * Used when there is no valid value to return. Callers are blocked until a new value is created * or an exception is thrown. */ 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(); }