laserninja commented on PR #10668:
URL: https://github.com/apache/gravitino/pull/10668#issuecomment-4184280266

   Thanks for the suggestion! I looked into throwing exceptions from the filter 
and catching them with a JAX-RS `ExceptionMapper`, but that doesn't work 
because `AuthenticationFilter` is a servlet `Filter` — it runs *before* the 
request reaches JAX-RS/Jersey. Exceptions thrown at the filter level propagate 
to Jetty's servlet container, not to `IcebergExceptionMapper`.
   
   Instead, I refactored to handle it directly in the filter:
   
   - Added a `protected sendAuthErrorResponse()` hook to `AuthenticationFilter` 
(default: `resp.sendError()`, preserving current Gravitino behavior).
   - Created `IcebergAuthenticationFilter` that overrides it to write 
Iceberg-spec JSON directly.
   - Overloaded `JettyServer.addSystemFilters(pathSpec, authFilter)` so the 
Iceberg server passes its own filter.
   - Removed the Jetty `ErrorHandler` approach entirely.
   
   This handles errors at the source and lets the Gravitino server easily add 
its own error format later via a similar subclass.


-- 
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