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

[WIP] KAFKA-19053: Remove FetchResponse#of which is not used in production … #19327

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

apalan60
Copy link
Contributor

No description provided.

Copy link
Contributor

@junrao junrao left a comment

Choose a reason for hiding this comment

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

@apalan60 : Thanks for the PR. Left a comment.

@@ -220,14 +220,6 @@ public static int recordsSize(FetchResponseData.PartitionData partition) {
return partition.records() == null ? 0 : partition.records().sizeInBytes();
}

// TODO: remove as a part of KAFKA-12410
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we remove the TODO for the other of constructor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@junrao

Thanks for your review.
The other of constructor is currently used by KafkaApis in production code. I'm looking into alternative approaches to remove this dependency, so that we can achieve the deletion behavior mentioned in the TODO comment. I'll update the thread if I manage to come up with a viable solution.

If I've misunderstood anything, please let me know.

@ijuma
Copy link
Member

ijuma commented Mar 31, 2025

Are all the tests we deleted for the of method? Or are these tests for other functionality and they just happened to use of to create the fetch response?

@github-actions github-actions bot removed the triage PRs from the community label Apr 1, 2025
.setLastStableOffset(lastStableOffset)
.setLogStartOffset(0)
.setRecords(records));
return FetchResponse.of(Errors.NONE, throttleTime, sessionId, new LinkedHashMap<>(partitions));
Copy link
Member

Choose a reason for hiding this comment

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

The FetchResponse.of is not used in production code, but we still need to use another function to replace it in test code. Probably, you can modify this kind of function like following and add related client.prepareResponse back in the test code.

    private FetchResponse fullFetchResponse(int sessionId, TopicIdPartition tp, MemoryRecords records, Errors error, long hw,
                                            long lastStableOffset, int throttleTime) {
        return new FetchResponse(new FetchResponseData()
            .setThrottleTimeMs(throttleTime)
            .setErrorCode(Errors.NONE.code())
            .setSessionId(sessionId)
            .setResponses(List.of(
                new FetchResponseData.FetchableTopicResponse()
                    .setTopic(tp.topic())
                    .setTopicId(tp.topicId())
                    .setPartitions(List.of(
                        new FetchResponseData.PartitionData()
                            .setPartitionIndex(tp.topicPartition().partition())
                            .setErrorCode(error.code())
                            .setHighWatermark(hw)
                            .setLastStableOffset(lastStableOffset)
                            .setLogStartOffset(0)
                            .setRecords(records))
                    ))));
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@FrankYang0529

Thanks for the review.
I really appreciate your detailed explanation and pointing out my mistake.
I’ll try out your suggested solution and update the PR accordingly.

@apalan60
Copy link
Contributor Author

apalan60 commented Apr 1, 2025

ijuma

@ijuma

Thanks for the review.
I believe I misunderstood the scope of the deletion. I'm currently working on restoring the tests that were mistakenly removed, and trying to construct the FetchResponse without using the of method, so that the original test logic is preserved while removing the dependency on the of method.

Thanks again for pointing that out. I'll update the PR soon with an improved version.

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.

5 participants