Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[Broker] Fix async response filter #11052

Merged
merged 4 commits into from
Jun 27, 2021

Conversation

gaoran10
Copy link
Contributor

Motivation

Currently, the response filter couldn't process async responses correctlly, the response interceptor may be called before the async response returning.

Modifications

Add listener when using async request.

Verifying this change

Add a new test to verify the response interceptor is called after async response returning.

Does this pull request potentially affect one of the following parts:

If yes was chosen, please highlight the changes

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API: (no)
  • The schema: (no)
  • The default values of configurations: (no)
  • The wire protocol: (no)
  • The rest endpoints: (no)
  • The admin cli options: (no)
  • Anything that affects deployment: (no)

@sijie sijie added this to the 2.9.0 milestone Jun 25, 2021
@codelipenghui codelipenghui merged commit 3c8d210 into apache:master Jun 27, 2021

@Slf4j
public class CounterBrokerInterceptor implements BrokerInterceptor {

int beforeSendCount = 0;
int count = 0;
private List<ResponseEvent> responseList = new ArrayList<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong,
This list does not support concurrent access.
We should use CopyOnWriteArrayList

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, @gaoran10 Could you please push a PR for fixing this one?

Copy link
Contributor Author

@gaoran10 gaoran10 Jun 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll fix it. But this class is used for testing, maybe there is only one admin client for testing in normal cases.

@gaoran10 gaoran10 deleted the fix-async-response-filter branch June 28, 2021 02:15
codelipenghui pushed a commit that referenced this pull request Jul 7, 2021
### Motivation

Currently, the response filter couldn't process async responses correctlly, the response interceptor may be called before the async response returning.

### Modifications

Add listener when using async request.

### Verifying this change

Add a new test to verify the response interceptor is called after async response returning.

(cherry picked from commit 3c8d210)
@codelipenghui codelipenghui added the cherry-picked/branch-2.8 Archived: 2.8 is end of life label Jul 7, 2021
bharanic-dev pushed a commit to bharanic-dev/pulsar that referenced this pull request Mar 18, 2022
### Motivation

Currently, the response filter couldn't process async responses correctlly, the response interceptor may be called before the async response returning.

### Modifications

Add listener when using async request.

### Verifying this change

Add a new test to verify the response interceptor is called after async response returning.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants