bharos opened a new pull request, #10723:
URL: https://github.com/apache/gravitino/pull/10723

   ### What changes were proposed in this pull request?
   
   1. Cache `JWKSource` in `initialize()` as an instance field instead of 
creating a new one per `validateToken()` call.
   2. Downgrade the catch-block log from `LOG.error` to `LOG.warn` for token 
validation failures.
   3. Remove the now-unused `createJwkSource()` private method.
   
   ### Why are the changes needed?
   
   - **Per-request `JWKSource` creation**: 
`JWKSourceBuilder.create(url).build()` was called on every `validateToken()` 
invocation, potentially triggering an outbound HTTP fetch to the JWKS endpoint 
each time. The Nimbus `JWKSource` already handles key caching and automatic 
rotation internally, so a single instance should be reused.
   - **Incorrect log level**: Expired or invalid client tokens are not server 
errors. Logging them at `ERROR` pollutes error-level monitoring/alerting for 
issues the server cannot fix. `WARN` is the appropriate level.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No. Validation behavior is unchanged. Log level changes from ERROR to WARN 
for client-side token failures.
   
   ### How was this patch tested?
   
   Existing unit tests in `TestJwksTokenValidator` cover the validation paths. 
The change is a straightforward refactoring of when the `JWKSource` is 
constructed (startup vs per-call) with no behavioral change.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to