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

KAFKA-12841: NPE from the provided metadata in client callback in case of ApiException #10951

Closed
wants to merge 2 commits into from
Closed

KAFKA-12841: NPE from the provided metadata in client callback in case of ApiException #10951

wants to merge 2 commits into from

Conversation

kirktrue
Copy link
Collaborator

@kirktrue kirktrue commented Jun 30, 2021

Jira: https://issues.apache.org/jira/browse/KAFKA-12841

Using the InterceptorCallback wrapper in the case of ApiException so
that we will adhere correctly to the Callback contract for onCompletion
specifying a valid (dummy) TopicPartition.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

I'm also supposed to add:

The contribution is my original work and that I license the work to the project under the project's open source license.

@kirktrue kirktrue marked this pull request as draft June 30, 2021 23:05
@kirktrue kirktrue marked this pull request as ready for review July 1, 2021 18:43
@kirktrue
Copy link
Collaborator Author

kirktrue commented Jul 1, 2021

@ayoukhananov - you're absolutely correct that there are conditions wherein tp wasn't initialized. This should fix that case too.

Kirk True added 2 commits July 6, 2021 10:21
…e of ApiException

Using the InterceptorCallback wrapper in the case of ApiException so
that we will adhere correctly to the Callback contract for onCompletion
specifying a valid (dummy) TopicPartition.
@kirktrue
Copy link
Collaborator Author

kirktrue commented Jul 6, 2021

@hachikuji - would you be willing to assign a reviewer for this PR?

The failing tests look like they're related to KRaft tests, so I don't think they're related.

@kirktrue
Copy link
Collaborator Author

kirktrue commented Jul 8, 2021

@cmccabe - could you take a look at this and/or assign a reviewer for this? Thanks!

@cmccabe
Copy link
Contributor

cmccabe commented Jul 26, 2021

If I understand correctly, the PR makes up a fake partition so that TopicPartition can be non-null in the callback. I don't think that this is the right thing to do. Why not change the JavaDoc for the callback to indicate that TopicPartition can be null if the method fails before it gets assigned?

@kirktrue
Copy link
Collaborator Author

Thanks @cmccabe for looking at this!

If I understand correctly, the PR makes up a fake partition so that TopicPartition can be non-null in the callback. I don't think that this is the right thing to do.

Yeah, I'm not crazy about it either. There was some "prior art" in the codebase where the same thing was done (ProducerInterceptors.onSendError) and the existence of RecordMetadata.UNKNOWN_PARTITION suggested that it might be permissible for these kinds of cases.

Why not change the JavaDoc for the callback to indicate that TopicPartition can be null if the method fails before it gets assigned?

My interpretation was that was akin to changing the interface of the Callback API and could cause some NullPointerException cases in users' code.

I'm happy to make the change to the JavaDoc, as suggested.

Thanks!

@ijuma
Copy link
Contributor

ijuma commented Feb 1, 2022

@kirktrue Given how it works for the producer interceptor, it seems reasonable to do something similar for the consumer. @cmccabe do you agree?

@kirktrue
Copy link
Collaborator Author

kirktrue commented Feb 2, 2022

Closing this PR in favor of #11689.

@kirktrue kirktrue closed this Feb 2, 2022
@philipnee
Copy link
Contributor

@kirktrue Given how it works for the producer interceptor, it seems reasonable to do something similar for the consumer. @cmccabe do you agree?

let's move the conversation to #11689

@kirktrue kirktrue deleted the KAFKA-12841-resolve-callback-npe branch October 25, 2023 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants