Skip to content

Conversation

see-quick
Copy link
Contributor

@see-quick see-quick commented Sep 3, 2025

This PR moves the ScramPublisher class from the server metadata package
to the dedicated metadata module. During refactoring, I found out that I
also need to move the CredentialProvider interface to a more appropriate
location in the server common package because CredentialProvider is in
the server module, and I can't include that module in the metadata
because I would create a circular dependency, i.e.,

server module ←-------------┐ ↓ (depends on). │
(which would make it circular) metadata module------------┘

So I have moved CredentialProvider to server-common module, and
metadata module has already server-common and thus it's resolved.

@github-actions github-actions bot added triage PRs from the community core Kafka Broker kraft labels Sep 3, 2025
@showuon showuon self-assigned this Sep 4, 2025
@see-quick see-quick changed the title KAFKA-18704: Move ScramPublisher to metadata module KAFKA-18706: Move ScramPublisher to metadata module Sep 4, 2025
Copy link
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. I left a few comments

@@ -44,7 +44,7 @@ import org.apache.kafka.common.security.auth.SecurityProtocol
import org.apache.kafka.common.utils.{KafkaThread, LogContext, Time, Utils}
import org.apache.kafka.common.{Endpoint, KafkaException, MetricName, Reconfigurable}
import org.apache.kafka.network.{ConnectionQuotaEntity, ConnectionThrottledException, SocketServerConfigs, TooManyConnectionsException}
import org.apache.kafka.security.CredentialProvider
import org.apache.kafka.server.common.CredentialProvider
Copy link
Member

Choose a reason for hiding this comment

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

nit: We try to order import alphabetically, can we move this 1 line down?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interestingly, checkstyle allows such a change. Should we also update the spotless or checkstyle configuration to address this problem? :). In this PR, I will update it manually now, but for next time, to avoid it.

Copy link
Member

Choose a reason for hiding this comment

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

I believe we don't enforce checkstyle on Scala code yet as it would fail on many files and fixing it would create a lot of noise.

String deltaName = "MetadataDelta up to " + newImage.highestOffsetAndEpoch().offset();
try {
// Apply changes to SCRAM credentials.
Optional.ofNullable(delta.scramDelta()).ifPresent(scramDelta -> {
Copy link
Member

Choose a reason for hiding this comment

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

If wonder if doing:

ScramDelta scramDelta = delta.scramDelta();
if (scramDelta != null) {

is just more readable. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure.

Comment on lines +56 to +57
scramDelta.changes().forEach((mechanism, userChanges) -> {
userChanges.forEach((userName, change) -> {
Copy link
Member

Choose a reason for hiding this comment

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

In both cases, the body of the block is a single expression, so we can remove the brackets{ }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, this could be added to checkstyle, I assume. Updated.

@github-actions github-actions bot removed the triage PRs from the community label Sep 6, 2025
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