Skip to content

Commit e444713

Browse files
tt4gjzheaux
authored andcommitted
Create the CSRF token on the bounded elactic scheduler
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
1 parent 4f849de commit e444713

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

web/src/main/java/org/springframework/security/web/server/csrf/CookieServerCsrfTokenRepository.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.springframework.web.server.ServerWebExchange;
2727

2828
import reactor.core.publisher.Mono;
29+
import reactor.core.scheduler.Schedulers;
2930

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

6364
@Override
6465
public Mono<CsrfToken> generateToken(ServerWebExchange exchange) {
65-
return Mono.fromCallable(this::createCsrfToken);
66+
return Mono.fromCallable(this::createCsrfToken).subscribeOn(Schedulers.boundedElastic());
6667
}
6768

6869
@Override

0 commit comments

Comments
 (0)