MCPcopy Index your code
hub / github.com/apache/devlake / ForceRefresh

Method ForceRefresh

backend/plugins/github/token/token_provider.go:230–247  ·  view source on GitHub ↗

ForceRefresh refreshes the access token if the current token is still equal to oldToken. The oldToken parameter should be the token value observed by the caller when it determined that a refresh might be needed; if the token has changed since then, another goroutine has already refreshed it and this

(oldToken string)

Source from the content-addressed store, hash-verified

228// that a refresh might be needed; if the token has changed since then, another goroutine has
229// already refreshed it and this method returns without performing a redundant refresh.
230func (tp *TokenProvider) ForceRefresh(oldToken string) errors.Error {
231 tp.mu.Lock()
232 defer tp.mu.Unlock()
233
234 // If the token has changed since the request was made, it means another thread
235 // has already refreshed it.
236 if tp.conn.Token != oldToken {
237 if tp.logger != nil {
238 tp.logger.Info("Skipping reactive token refresh for connection %d — token already changed by another goroutine", tp.conn.ID)
239 }
240 return nil
241 }
242
243 if tp.logger != nil {
244 tp.logger.Info("Reactive token refresh triggered for connection %d (received 401)", tp.conn.ID)
245 }
246 return tp.refreshToken()
247}

Callers 2

TestAppKeyForceRefreshFunction · 0.95
roundTripWithRetryMethod · 0.80

Calls 2

refreshTokenMethod · 0.95
InfoMethod · 0.65

Tested by 1

TestAppKeyForceRefreshFunction · 0.76