Skip to content

Commit

Permalink
Create the CSRF token on the bounded elactic scheduler
Browse files Browse the repository at this point in the history
The CSRF token is generated by UUID.randomUUID() which is I/O blocking operation.
This commit changes the subscriber thread to the bounded elactic scheduler.

Closes gh-9018
  • Loading branch information
tt4g authored and jzheaux committed Sep 16, 2020
1 parent 4f849de commit e444713
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.springframework.web.server.ServerWebExchange;

import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;

/**
* A {@link ServerCsrfTokenRepository} that persists the CSRF token in a cookie named "XSRF-TOKEN" and
Expand Down Expand Up @@ -62,7 +63,7 @@ public static CookieServerCsrfTokenRepository withHttpOnlyFalse() {

@Override
public Mono<CsrfToken> generateToken(ServerWebExchange exchange) {
return Mono.fromCallable(this::createCsrfToken);
return Mono.fromCallable(this::createCsrfToken).subscribeOn(Schedulers.boundedElastic());
}

@Override
Expand Down

0 comments on commit e444713

Please sign in to comment.