Skip to content

Commit

Permalink
fix: span names (#543)
Browse files Browse the repository at this point in the history
  • Loading branch information
alekseyvdovenko authored Oct 28, 2024
1 parent 2cff468 commit 3b35864
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,13 @@ public static DecodedJWT decodeJwtToken(String encodedToken) {
}

private Future<JwkResult> getJwk(String kid) {
return cache.computeIfAbsent(kid, key -> vertx.executeBlocking(() -> {
/* The result of vertx.executeBlocking is a future that contains Vert.x context which is valid during a request
* execution. So, if we put that future in a cache, it will contain a context from the initial request, that
* may be invalid for further requests. For this reason, when we retrieve the future from the cache, we must
* extract the value and put it into another future (Promise) which holds a valid context of a current request.
* */
Promise<JwkResult> promise = Promise.promise();
cache.computeIfAbsent(kid, key -> vertx.executeBlocking(() -> {
JwkResult jwkResult;
long currentTime = System.currentTimeMillis();
try {
Expand All @@ -192,7 +198,8 @@ private Future<JwkResult> getJwk(String kid) {
jwkResult = new JwkResult(null, e, currentTime + negativeCacheExpirationMs);
}
return jwkResult;
}, false));
}, false)).onSuccess(promise::complete).onFailure(promise::fail);
return promise.future();
}

private Future<DecodedJWT> verifyJwt(DecodedJWT jwt) {
Expand Down

0 comments on commit 3b35864

Please sign in to comment.