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

MINOR: cleanup core modules part 1 #15252

Merged
merged 3 commits into from
Jan 26, 2024

Conversation

jlprat
Copy link
Contributor

@jlprat jlprat commented Jan 24, 2024

I'm going through the core classes and found some warnings that could be cleaned up, this is the first batch of clean ups.
Even if the code needs to be ported to Java, this might help in the process (clearer types, less code, right visibility).

This PR cleans up: admin, api, cluster, common, controller, coordinator and log classes:

  • Mark methods and fields private where possible
  • Annotate public methods and fields
  • Remove unused classes and methods

More detailed description of your change,
if necessary. The PR title and PR message become
the squashed commit message, so use a separate
comment to ping reviewers.

Summary of testing strategy (including rationale)
for the feature or bug fix. Unit and/or integration
tests are expected for any behaviour change and
system tests should be considered for larger changes.

Committer Checklist (excluded from commit message)

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

Mark methods and fields private where possible
Annotate public methods and fields
Remove unused classes and methods
Mark methods and fields private where possible
Annotate public methods and fields
Remove unused classes and methods
@jlprat
Copy link
Contributor Author

jlprat commented Jan 25, 2024

Failures seem all unrelated to the changes

Copy link
Member

@showuon showuon left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. Left some comments.

Comment on lines -119 to 123
case e: Exception => {
case e: Exception =>
e.printStackTrace()
// must exit with non-zero status so system tests will know we failed
Exit.exit(1)
}
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm not completely sure if it'll work as before after removing the curly brackets. Could you confirm it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From: https://docs.scala-lang.org/style/control-structures.html#curlybraces

case - Always omit braces in case clauses.

I also double checked with one of the most used Scala code bases in concurrent world (Pekko, fork of Akka) that this is the case. You can see this in this class for example (one of the key classes of Pekko):
https://github.com/apache/incubator-pekko/blob/e597a702b9a54a0e193e09a50a1d45dfd1f56785/actor/src/main/scala/org/apache/pekko/actor/ActorCell.scala#L659

This is an instance where Java and Scala differ (in Java this diff would cause a different behaviour indeed).

Comment on lines -32 to -33
case class ClientIdAllBrokers(clientId: String) extends ClientIdBroker {
override def toString = "%s-%s".format(clientId, "AllBrokers")
Copy link
Member

Choose a reason for hiding this comment

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

So ClientIdAllBrokers is unused class. Good catch!

Signed-off-by: Josep Prat <[email protected]>
Copy link
Member

@showuon showuon left a comment

Choose a reason for hiding this comment

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

LGTM!

@jlprat
Copy link
Contributor Author

jlprat commented Jan 26, 2024

All tests failures seem to be unrelated to these changes.

@jlprat jlprat merged commit 2a6e420 into apache:trunk Jan 26, 2024
1 check failed
@jlprat jlprat deleted the MINOR-cleanup-core-modules-1 branch January 26, 2024 15:35
yyu1993 pushed a commit to yyu1993/kafka that referenced this pull request Feb 15, 2024
* MINOR: Clean up core api, cluster, common, log, admin, controller and coordinator classes

Mark methods and fields private where possible
Annotate public methods and fields
Remove unused classes and methods

Signed-off-by: Josep Prat <[email protected]>

Reviewers: Luke Chen <[email protected]>
clolov pushed a commit to clolov/kafka that referenced this pull request Apr 5, 2024
* MINOR: Clean up core api, cluster, common, log, admin, controller and coordinator classes

Mark methods and fields private where possible
Annotate public methods and fields
Remove unused classes and methods

Signed-off-by: Josep Prat <[email protected]>

Reviewers: Luke Chen <[email protected]>
Phuc-Hong-Tran pushed a commit to Phuc-Hong-Tran/kafka that referenced this pull request Jun 6, 2024
* MINOR: Clean up core api, cluster, common, log, admin, controller and coordinator classes

Mark methods and fields private where possible
Annotate public methods and fields
Remove unused classes and methods

Signed-off-by: Josep Prat <[email protected]>

Reviewers: Luke Chen <[email protected]>
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.

2 participants