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-17563: Move RequestConvertToJson to server module #17223

Merged

Conversation

xijiu
Copy link
Contributor

@xijiu xijiu commented Sep 18, 2024

As title.

Committer Checklist (excluded from commit message)

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

Copy link
Contributor

@chia7712 chia7712 left a comment

Choose a reason for hiding this comment

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

@xijiu thanks for this patch.

Could you please move some tests from RequestConvertToJsonTest to server module? testClientInfoNode, testAllRequestTypesHandled, testAllApiVersionsResponseHandled and testAllResponseTypesHandled

@github-actions github-actions bot added core Kafka Broker performance labels Sep 20, 2024
@xijiu
Copy link
Contributor Author

xijiu commented Sep 20, 2024

@xijiu thanks for this patch.

Could you please move some tests from RequestConvertToJsonTest to server module? testClientInfoNode, testAllRequestTypesHandled, testAllApiVersionsResponseHandled and testAllResponseTypesHandled

@chia7712 Sure, I have migrated these four methods, PTAL

@mimaison
Copy link
Member

I wonder if we should wait for server to switch to Java 17 before merging this. With Java 17, we will be able to use pattern matching and significantly simplify the logic. The huge list of if (x instance y) is really ugly with Java 11.

@chia7712
Copy link
Contributor

I wonder if we should wait for server to switch to Java 17 before merging this. With Java 17, we will be able to use pattern matching and significantly simplify the logic. The huge list of if (x instance y) is really ugly with Java 11.

That is a good idea. Not only match pattern but also record type can simplify Kafka code base significantly. Also, I agree to that instanceof is ugly. Maybe we can use ApiKeys instead? for exampel:

        switch(request.apiKey()) {
            case PRODUCE:
                return ProduceRequestDataJsonConverter.write(((ProduceRequest) request).data(), request.version(), false);
        }

That is more graceful and probably have better performance.

@mimaison
Copy link
Member

Maybe we can use ApiKeys instead?

Yes that's also an option. I'd really prefer this or pattern matching over the current code.

@xijiu
Copy link
Contributor Author

xijiu commented Sep 23, 2024

Maybe we can use ApiKeys instead?

Yes that's also an option. I'd really prefer this or pattern matching over the current code.

@mimaison @chia7712 Thanks very much for code review, and indeed, the switch(request.apiKey()) mode is more elegant and efficient

I have changed it, PTAL

@chia7712 chia7712 merged commit 18340c9 into apache:trunk Sep 26, 2024
9 of 10 checks passed
airlock-confluentinc bot pushed a commit to confluentinc/kafka that referenced this pull request Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants