Skip to content

Commit

Permalink
Merge pull request #61 from sswguo/duration_setting
Browse files Browse the repository at this point in the history
Add timeout for fetching token
  • Loading branch information
sswguo authored Dec 18, 2024
2 parents 4634455 + b73f7cd commit 6e65e6a
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import jakarta.ws.rs.core.HttpHeaders;
import jakarta.ws.rs.ext.Provider;

import java.time.Duration;

@Provider
@Priority(Priorities.AUTHENTICATION)
public class CustomClientRequestFilter implements ClientRequestFilter
Expand All @@ -51,7 +53,7 @@ public void filter( ClientRequestContext requestContext )
if ( tokens == null || tokens.isAccessTokenExpired() )
{
logger.debug("Security enabled, get oidc Tokens");
tokens = client.getTokens().await().indefinitely();
tokens = client.getTokens().await().atMost( Duration.ofSeconds( 30 ) );
}
requestContext.getHeaders().add(HttpHeaders.AUTHORIZATION, "Bearer " + tokens.getAccessToken());
}
Expand Down

0 comments on commit 6e65e6a

Please sign in to comment.