default boolean refreshIfRequired(final RefreshMode refreshMode,
                                      final Consumer<Refreshable> onRefreshAction) {
        final boolean didRefresh;
        if (isRefreshRequired(refreshMode)) {
            synchronized (this) {
                if (isRefreshRequired(refreshMode)) {
                    if (RefreshMode.JUST_IN_TIME == refreshMode) {
                        // If things are working properly then the RefreshManager should have refreshed it
                        // in EAGER mode before we need to do it in JUST_IN_TIME mode.
                        LOGGER.debug(() -> LogUtil.message(
                                "Just in time refresh required for type: {}, expireTime: {}, refreshBuffer: {}",
                                this.getClass().getSimpleName(),
                                LogUtil.instant(getExpireTimeEpochMs()),
                                Duration.ofMillis(getRefreshBufferMs())));
                    }
                    didRefresh = refresh(onRefreshAction);
                    LOGGER.trace("Refreshing, didRefresh: {}", didRefresh);
                } else {
                    LOGGER.trace("Refresh not required");
                    didRefresh = false;
                }
            }
        } else {
            LOGGER.trace("Refresh not required");
            didRefresh = false;
        }
        return didRefresh;
    }
Refresh this {@link Refreshable} if {@link Refreshable#isRefreshRequired(RefreshMode)} is true.
Calls onRefreshAction if the refresh happened.

@param onRefreshAction An optional callback to run if a refresh happens.
@return True if the refresh happened
stroom-util/src/main/java/stroom/util/authentication/Refreshable.java