-
Notifications
You must be signed in to change notification settings - Fork 70
Closed
Labels
needs investigationAn issue that has more questions to answer or otherwise needs work to fully understand the issueAn issue that has more questions to answer or otherwise needs work to fully understand the issue
Description
Describe the problem
As per: examples we should be able to catch NetworkException when getting JWK using cached JwkProviderBuilder. But in here that error is caught and replaced with SigningKeyNotFoundException (as ExecutionException includes NetworkException):
@Override
public Jwk get(final String keyId) throws JwkException {
try {
String cacheKey = keyId == null ? NULL_KID_KEY : keyId;
return cache.get(cacheKey, new Callable<Jwk>() {
@Override
public Jwk call() throws Exception {
return provider.get(keyId);
}
});
} catch (ExecutionException e) {
throw new SigningKeyNotFoundException("Failed to get key with kid " + keyId, e);
}
}
This basically recreates the issue: #79.
What was the expected behavior?
NetworkException being thrown directly from: JwkProviderBuilder(URL(...)).cached(...).build().get(...) method when unable to connect to the url.
Reproduction
- Create cached provider for some urlPath of an offline server:
val provider = JwkProviderBuilder(URL(urlPath)).cached(10, 1, TimeUnit.MINUTES).build() - Try to access the JWK for some keyId:
provider.get(keyId) - Get the SigningKeyNotFoundException:
Failed to get key with kid **** - Only able to trace exception.cause:
java.util.concurrent.ExecutionException: com.auth0.jwk.NetworkException: Cannot obtain jwks from url ****
Environment
- Version of this library used: 0.21.2
- Version of Java used: 11 (Kotlin 1.3.72)
- Other modules/plugins/libraries that might be involved:
- Any other relevant information you think would be useful:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
needs investigationAn issue that has more questions to answer or otherwise needs work to fully understand the issueAn issue that has more questions to answer or otherwise needs work to fully understand the issue