Skip to content

MINOR: Clean up core metrics, migration, network, raft, security, serializer, tools, utils, and zookeeper modules#15279

Merged
jlprat merged 1 commit intoapache:trunkfrom
jlprat:MINOR-cleanup-core-part3
Feb 19, 2024
Merged

MINOR: Clean up core metrics, migration, network, raft, security, serializer, tools, utils, and zookeeper modules#15279
jlprat merged 1 commit intoapache:trunkfrom
jlprat:MINOR-cleanup-core-part3

Conversation

@jlprat
Copy link
Copy Markdown
Contributor

@jlprat jlprat commented Jan 29, 2024

Second follow up from #15252

This PR cleans up: metrics, migration, network, raft, security, serializer, tools, utils, and zookeeper package classes

  • Mark methods and fields private where possible
  • Annotate public methods and fields
  • Remove unused classes and methods
  • Make sure Arrays are not printed with .toString
  • Optimize minor warnings

Committer Checklist (excluded from commit message)

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

Copy link
Copy Markdown
Member

@mimaison mimaison 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.

import org.apache.kafka.common.utils.Utils
import org.apache.kafka.server.util.{CommandDefaultOptions, CommandLineUtils}

import java.util
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've got a PR to move this to the tools module: #15274 so I'm not sure it's worth updating it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can review your PR first, and then rebase this one, so this class is gone :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Works for me 👍

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

#15274 is merged now

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Rebased against trunk. Feel free to review whenever you have time @mimaison. Thanks!

@volatile var callbackRequestCompleteTimeNanos: Option[Long] = None

val session = Session(context.principal, context.clientAddress)
val session: Session = Session(context.principal, context.clientAddress)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see sometimes we add the type for val and var definition and sometimes we don't am just curious what is the pattern we are opting in for here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I might have missed some spots where this should be applied but the Scala idiomatic approach to this is:

  • public API should be explicitly typed: this applies to vals, vars and defs for example. Like the case you comment on.
  • private definitions or variables don't need to be typed. Thanks to Scala type inference many defs, vars and vals can omit their explicit type making it easy to refactor things. Please note the "don't need to", you can still explicitly type those.

Let me know if this answers your question.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The changes made in this PR reflect the current (as per 2.12 and 2.13) idiomatic way to write Scala. For example:
Boolean parameters should be named, idempotent methods that are parameterless can be omit the parenthesis, side-effecting parameterless methods should include the parenthesis, and so on

This PR cleans up: metrics, migration, network, raft, security, serializer, tools, utils, and zookeeper package classes

Mark methods and fields private where possible
Annotate public methods and fields
Remove unused classes and methods
Make sure Arrays are not printed with .toString
Optimize minor warnings
@jlprat jlprat force-pushed the MINOR-cleanup-core-part3 branch from e89a791 to 4c489eb Compare February 19, 2024 09:09
Copy link
Copy Markdown
Member

@mimaison mimaison left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@jlprat
Copy link
Copy Markdown
Contributor Author

jlprat commented Feb 19, 2024

Checked that all tests pass locally and are flaky tests.

@jlprat jlprat merged commit b71999b into apache:trunk Feb 19, 2024
@jlprat jlprat deleted the MINOR-cleanup-core-part3 branch February 19, 2024 15:54
clolov pushed a commit to clolov/kafka that referenced this pull request Apr 5, 2024
This PR cleans up: metrics, migration, network, raft, security, serializer, tools, utils, and zookeeper package classes

Mark methods and fields private where possible
Annotate public methods and fields
Remove unused classes and methods
Make sure Arrays are not printed with .toString
Optimize minor warnings

Reviewers: Mickael Maison <mickael.maison@gmail.com>
Phuc-Hong-Tran pushed a commit to Phuc-Hong-Tran/kafka that referenced this pull request Jun 6, 2024
This PR cleans up: metrics, migration, network, raft, security, serializer, tools, utils, and zookeeper package classes

Mark methods and fields private where possible
Annotate public methods and fields
Remove unused classes and methods
Make sure Arrays are not printed with .toString
Optimize minor warnings

Reviewers: Mickael Maison <mickael.maison@gmail.com>
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.

3 participants