Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Create a WebClient with ServletOAuth2AuthorizedClientExchangeFilterFunction
public WebClient webClient(WebClient.Builder webClientBuilder, OAuth2AuthorizedClientManager authorizedClientManager) {
ServletOAuth2AuthorizedClientExchangeFilterFunction oauth2Client = new ServletOAuth2AuthorizedClientExchangeFilterFunction(authorizedClientManager);
oauth2Client.setDefaultClientRegistrationId("default-oauth");
return webClientBuilder.apply(oauth2Client.oauth2Configuration()).build();
}
Later if you execute a request the reauthorizeClient is called but stepped out now earlier due
if (servletRequest == null || servletResponse == null) {
return Mono.empty();
}
we use a method annotated mit @Async.
@Async
public CompletableFuture<EchoResult> getBearer() {
var uriComponents = UriComponentsBuilder.newInstance()
.scheme("https")
.host("echo.free.beeceptor.com")
.build();
EchoResult body;
try {
body = webClient.get()
.uri(uriComponents.toUri())
.retrieve()
.bodyToMono(EchoResult.class)
.block();
} catch (RuntimeException ex) {
throw new IllegalArgumentException(ex);
}
return CompletableFuture.completedFuture(body);
}
If we use without @Asyncthe authorization works
Expected behavior
Authorization works without servletRequest and servletResponse because addToAttributes handle the nullify values.
Links
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Create a WebClient with
ServletOAuth2AuthorizedClientExchangeFilterFunctionLater if you execute a request the
reauthorizeClientis called but stepped out now earlier duewe use a method annotated mit
@Async.@Async public CompletableFuture<EchoResult> getBearer() { var uriComponents = UriComponentsBuilder.newInstance() .scheme("https") .host("echo.free.beeceptor.com") .build(); EchoResult body; try { body = webClient.get() .uri(uriComponents.toUri()) .retrieve() .bodyToMono(EchoResult.class) .block(); } catch (RuntimeException ex) { throw new IllegalArgumentException(ex); } return CompletableFuture.completedFuture(body); }If we use without
@Asyncthe authorization worksExpected behavior
Authorization works without
servletRequestandservletResponsebecauseaddToAttributeshandle the nullify values.Links