jiangpengcheng opened a new issue, #23670:
URL: https://github.com/apache/pulsar/issues/23670

   ### Search before asking
   
   - [X] I searched in the [issues](https://github.com/apache/pulsar/issues) 
and found nothing similar.
   
   
   ### Read release policy
   
   - [X] I understand that unsupported versions don't get bug fixes. I will 
attempt to reproduce the issue on a supported version of Pulsar client and 
Pulsar broker.
   
   
   ### Version
   
   master(f27905560207eb2ade32f8086b4585dffb918b80)
   
   ### Minimal reproduce step
   
   1. implement a simple `BrokerInterceptor` like below, and build a nar 
package for it:
   
     ```
     public class TestFilter implements BrokerInterceptor {
         private static final Logger log = 
LoggerFactory.getLogger(TestFilter.class);
         @Override
         public void onPulsarCommand(BaseCommand command, ServerCnx cnx) {
         }
     
         @Override
         public void onConnectionClosed(ServerCnx cnx) {
         }
     
         @Override
         public void onWebserviceRequest(ServletRequest request) {
         }
     
         @Override
         public void onWebserviceResponse(ServletRequest request, 
ServletResponse response) {
         }
     
         @Override
         public void initialize(PulsarService pulsarService) {
         }
     
         @Override
         public void onFilter(ServletRequest request, ServletResponse response, 
FilterChain chain)
                 throws ServletException, IOException {
             log.info("====test");
             chain.doFilter(request, response);
         }
     
         @Override
         public void close() {
     
         }
     }
     ```
   
   2. edit the `standalone.conf`, and update the `brokerInterceptors=` field to 
the `test-filter`
   3. start the pulsar service in standalone mode
   4. call `pulsar-admin tenants list` to fire a http request
   
   ### What did you expect to see?
   
   the pulsar process should printed below logs:
   
   ```
   ====test
   ```
   
   ### What did you see instead?
   
   the `====test` logs doesn't get printed
   
   ### Anything else?
   
   The issue lies in the implementation:
   
   Although [PR #10489](https://github.com/apache/pulsar/pull/10489) introduced 
an `onFilter` method in the `BrokerInterceptor` interface, the `PulsarService` 
is hardcoded to use `BrokerInterceptors` as the entry interceptor. Custom 
interceptors configured via the `brokerInterceptors=` parameter are loaded into 
`BrokerInterceptors` and executed sequentially. However, `BrokerInterceptors` 
does not override the `onFilter` method, causing it to fall back to the default 
implementation:
   
   ```java
   default void onFilter(ServletRequest request, ServletResponse response, 
FilterChain chain)
           throws IOException, ServletException {
       // Just continue the chain by default.
       chain.doFilter(request, response);
   }
   ```
   
   As a result, even if a custom `BrokerInterceptor` implements the `onFilter` 
method, it is never invoked.
   
   This issue exists in branch-3.0, 3.3, 4.0 too
   
   ### Are you willing to submit a PR?
   
   - [X] I'm willing to submit a PR!


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