Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[fix][broker] Fix Filter NPE #20711

Closed
wants to merge 2 commits into from

Conversation

Technoboy-
Copy link
Contributor

Motivation

After merging #20422 , the broker may encounter NPE when config :

brokerInterceptors = xxx-interceptor
disableBrokerInterceptors = true
image
2023-07-03T10:26:00,507+0000 [main] INFO  org.apache.pulsar.broker.intercept.BrokerInterceptors - Skip loading the broker interceptors when disableBrokerInterceptors is true

See

public ProcessHandlerFilter(PulsarService pulsar) {
this.interceptor = pulsar.getBrokerInterceptor();
this.interceptorEnabled = !pulsar.getConfig().getBrokerInterceptors().isEmpty();
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
if (interceptorEnabled
&& !StringUtils.containsIgnoreCase(request.getContentType(), MediaType.MULTIPART_FORM_DATA)
&& !StringUtils.containsIgnoreCase(request.getContentType(), MediaType.APPLICATION_OCTET_STREAM)) {
interceptor.onFilter(request, response, chain);
} else {
chain.doFilter(request, response);
}
}

public static BrokerInterceptor load(ServiceConfiguration conf) throws IOException {
if (conf.isDisableBrokerInterceptors()) {
log.info("Skip loading the broker interceptors when disableBrokerInterceptors is true");
return null;
}

The master branch has fixed this by #19376

For the judgment of interceptors, we need to be consistent with the master, that is, to use the disableBrokerInterceptors judgment first

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

@Technoboy- Technoboy- self-assigned this Jul 4, 2023
@Technoboy- Technoboy- added this to the 3.1.0 milestone Jul 4, 2023
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Jul 4, 2023
@Technoboy- Technoboy- closed this Jul 4, 2023
@Technoboy- Technoboy- reopened this Jul 4, 2023
@Technoboy- Technoboy- closed this Jul 4, 2023
@Technoboy- Technoboy- deleted the fix-filter-npe branch November 11, 2023 07:26
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
doc-not-needed Your PR changes do not impact docs ready-to-test release/2.11.2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants