[REFACTORING] Wrap blocking calls in JWTAuthenticationStrategy
It was forcing to schedule the whole chain on an elastic scheduler...
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/jwt/JWTAuthenticationStrategy.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/jwt/JWTAuthenticationStrategy.java
index 4314c31..55352af 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/jwt/JWTAuthenticationStrategy.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/jwt/JWTAuthenticationStrategy.java
@@ -36,6 +36,7 @@
import com.google.common.collect.ImmutableMap;
import reactor.core.publisher.Mono;
+import reactor.core.scheduler.Schedulers;
import reactor.netty.http.server.HttpServerRequest;
public class JWTAuthenticationStrategy implements AuthenticationStrategy {
@@ -61,7 +62,7 @@
return Mono.fromCallable(() -> authHeaders(httpRequest))
.filter(header -> header.startsWith(AUTHORIZATION_HEADER_PREFIX))
.map(header -> header.substring(AUTHORIZATION_HEADER_PREFIX.length()))
- .map(userJWTToken -> {
+ .flatMap(userJWTToken -> Mono.fromCallable(() -> {
if (!tokenManager.verify(userJWTToken)) {
throw new UnauthorizedException("Failed Jwt verification");
}
@@ -74,7 +75,7 @@
}
return username;
- })
+ }).subscribeOn(Schedulers.elastic()))
.map(mailboxManager::createSystemSession);
}