Skip to content

[fix][broker] Fix Filter NPE - #20711

Closed
Technoboy- wants to merge 2 commits into
apache:branch-2.11from
Technoboy-:fix-filter-npe
Closed

[fix][broker] Fix Filter NPE#20711
Technoboy- wants to merge 2 commits into
apache:branch-2.11from
Technoboy-:fix-filter-npe

Conversation

@Technoboy-

Copy link
Copy Markdown
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in 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