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-5772 Improve Util classes #3370

Merged
merged 2 commits into from
Dec 22, 2017
Merged

Conversation

matzew
Copy link
Member

@matzew matzew commented Jun 19, 2017

Done for https://issues.apache.org/jira/browse/KAFKA-5772

Utils with static methods should not be instantiated, hence marking the classes final and adding a private constructor.

this is consistent w/ some of the Util classes, such as ByteUtils, see:

public final class ByteUtils {
private ByteUtils() {}

@asfgit
Copy link

asfgit commented Jun 19, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk7-scala2.11/5472/
Test PASSed (JDK 7 and Scala 2.11).

@asfgit
Copy link

asfgit commented Jun 19, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk8-scala2.12/5457/
Test PASSed (JDK 8 and Scala 2.12).

@matzew
Copy link
Member Author

matzew commented Aug 23, 2017

@rhauch do you mind taking a look? Or do I need to also have a JIRA for this improvement?

Copy link
Contributor

@rhauch rhauch left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@rhauch rhauch left a comment

Choose a reason for hiding this comment

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

We still need a JIRA issue, and the title of this PR should start with that issue number per the contributors guide. Other than that, the code changes look great.

@matzew matzew changed the title making util classes final and adding private ctor KAFKA-5772 - Improve Util classes Aug 23, 2017
@matzew
Copy link
Member Author

matzew commented Aug 23, 2017

@rhauch Thanks Randall 👍

I've created a JIRA and update the tilte of the PR 😃

@rhauch
Copy link
Contributor

rhauch commented Aug 23, 2017

@matzew, the Apache JIRA should automatically update with a reference to this PR, but I don't see that happening. Perhaps remove the " -" just after the issue number in the PR title?

Copy link
Contributor

@rhauch rhauch left a comment

Choose a reason for hiding this comment

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

LGTM!

@rhauch
Copy link
Contributor

rhauch commented Aug 23, 2017

Actually, on second thought I'm not sure whether these utility methods are considered part of the public API, and if so whether a KIP would be required. The Apache Kafka project are very strict about ensuring backward compatibility, and technically removing the constructor for these classes breaks backward compatibility.

Need advice from one of the committers, such as @hachikuji or @ijuma.

@ijuma
Copy link
Contributor

ijuma commented Aug 23, 2017

These are class are internal.

@matzew
Copy link
Member Author

matzew commented Aug 24, 2017

@ijuma @rhauch thanks for clarification

@matzew matzew changed the title KAFKA-5772 - Improve Util classes KAFKA-5772 Improve Util classes Aug 24, 2017
@matzew
Copy link
Member Author

matzew commented Sep 14, 2017

@rhauch is there still interest in merging this? Or should I just close it ?

@rhauch
Copy link
Contributor

rhauch commented Sep 14, 2017

@ijuma any reason not to approve and merge this?

@rhauch
Copy link
Contributor

rhauch commented Sep 14, 2017

retest this please.

@@ -26,6 +26,9 @@
import org.apache.kafka.common.resource.ResourceType;

class RequestUtils {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason why this one is not final?

Copy link
Member Author

Choose a reason for hiding this comment

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

@ijuma there was no particular reason, added final keyword here to

@ijuma
Copy link
Contributor

ijuma commented Sep 14, 2017

retest this please

@ijuma
Copy link
Contributor

ijuma commented Sep 14, 2017

One issue with final classes is that they're harder to mock (i.e. PowerMock is needed). For internal classes, the benefit of making classes final is not as pronounced as for public classes (since we can make any changes anyway). Still, happy to merge the PR if the tests pass.

@matzew
Copy link
Member Author

matzew commented Sep 14, 2017

@ijuma @rhauch thanks for the feedback.

I've now also rebased my branch, based on upstream's trunk!

Copy link
Contributor

@rhauch rhauch left a comment

Choose a reason for hiding this comment

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

I'm going to approve this on a technical basis: the PR is simple and minimal. I'll leave to @ijuma to decide whether it's a desirable change.

@matzew
Copy link
Member Author

matzew commented Sep 22, 2017 via email

@matzew
Copy link
Member Author

matzew commented Dec 22, 2017

@ijuma should I close it or will it be merged ? :-)

@hachikuji
Copy link

Thanks for the patch. LGTM.

@hachikuji hachikuji merged commit 0538f15 into apache:trunk Dec 22, 2017
@matzew
Copy link
Member Author

matzew commented Dec 22, 2017

Thanks 😸

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.

5 participants