Skip to content

Conversation

@m1a2st
Copy link
Collaborator

@m1a2st m1a2st commented Aug 22, 2024

Jira: https://issues.apache.org/jira/browse/KAFKA-16564

We should apply the same xlint to java code in core module before we complete the code migration.

Committer Checklist (excluded from commit message)

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

@m1a2st m1a2st force-pushed the gh-KAFKA-16564 branch 2 times, most recently from d3d4aa0 to dc7924f Compare September 10, 2024 19:30
build.gradle Outdated
if (name == "compileTestJava" || name == "compileTestScala")
if (name == "compileTestJava" || name == "compileTestScala") {
options.compilerArgs << "-parameters"
} else if (name == "compileJava") {
Copy link
Member

Choose a reason for hiding this comment

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

please change compileJava to compileScala to add the args to "scala compiler"

@m1a2st m1a2st marked this pull request as ready for review September 17, 2024 05:37
@chia7712
Copy link
Member

chia7712 commented Oct 7, 2024

@m1a2st could you please rebase code and fix conflicts?

# Conflicts:
#	core/src/test/java/kafka/admin/ConfigCommandTest.java
@github-actions github-actions bot added core Kafka Broker small Small PRs labels Oct 7, 2024
@m1a2st
Copy link
Collaborator Author

m1a2st commented Oct 7, 2024

I have been fix it, Thanks for your reminder.

@chia7712
Copy link
Member

@m1a2st could you please rebase code and fix conflicts?

# Conflicts:
#	core/src/main/java/kafka/server/handlers/DescribeTopicPartitionsRequestHandler.java
@github-actions github-actions bot added the build Gradle build or GitHub Actions label Oct 15, 2024
build.gradle Outdated
options.compilerArgs << "-Xlint:-serial"
options.compilerArgs << "-Xlint:-try"
options.compilerArgs << "-Werror"
options.compilerArgs << "-Xlint:-options"
Copy link
Member

Choose a reason for hiding this comment

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

why we need this option?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The -Xlint:-options is "Warns about the issues relating to use of command line options" . doc
I think we don't need this option, I will remove it.

Copy link
Member

@chia7712 chia7712 left a comment

Choose a reason for hiding this comment

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

@m1a2st thanks for your patch

build.gradle Outdated
if (name == "compileTestJava" || name == "compileTestScala")
if (name == "compileTestJava" || name == "compileTestScala") {
options.compilerArgs << "-parameters"
} else if (name == "compileScala") {
Copy link
Member

Choose a reason for hiding this comment

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

Could you please config both scala and java? for example:

    if (name == "compileTestJava" || name == "compileTestScala") {
      options.compilerArgs << "-parameters"
    } else if (name == "compileJava" || name == "compileScala") {
      options.compilerArgs << "-Xlint:all"
      if (!project.path.startsWith(":connect") && !project.path.startsWith(":storage"))
        options.compilerArgs << "-Xlint:-rawtypes"
      options.compilerArgs << "-encoding" << "UTF-8"
      options.compilerArgs << "-Xlint:-rawtypes"
      options.compilerArgs << "-Xlint:-serial"
      options.compilerArgs << "-Xlint:-try"
      options.compilerArgs << "-Werror"
      options.compilerArgs += ["--release", String.valueOf(minJavaVersion)]
    }

addParametersForTests = { name, options ->
// -parameters generates arguments with parameter names in TestInfo#getDisplayName.
// ref: https://github.com/junit-team/junit5/blob/4c0dddad1b96d4a20e92a2cd583954643ac56ac0/junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedTest.java#L161-L164
if (name == "compileTestJava" || name == "compileTestScala")
Copy link
Member

Choose a reason for hiding this comment

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

Additionally, addParametersForTests -> configureJavaCompiler

SecurityManager s = System.getSecurityManager();
Thread t = new Thread((s != null) ? s.getThreadGroup() :
Thread.currentThread().getThreadGroup(), r,
Thread t = new Thread(Thread.currentThread().getThreadGroup(), r,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Java 17 is deprecated the SecurityManager, see doc

Copy link
Member

Choose a reason for hiding this comment

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

Could you please use suppression to fix it? we can go back to dig in it later

@chia7712
Copy link
Member

@m1a2st please fix build error

Copy link
Member

@chia7712 chia7712 left a comment

Choose a reason for hiding this comment

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

@m1a2st thanks for this patch

if (!project.path.startsWith(":connect") && !project.path.startsWith(":storage"))
options.compilerArgs << "-Xlint:-rawtypes"
options.compilerArgs << "-encoding" << "UTF-8"
options.compilerArgs << "-Xlint:-rawtypes"
Copy link
Member

Choose a reason for hiding this comment

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

duplicate config?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

configureJavaCompiler also use in the tasks.withType(JavaCompile) and subprojects, it is dulpicate in the tasks.withType(JavaCompile)code block so I remove it which in tasks.withType(JavaCompile)

wrappedCert.hasUnsupportedCriticalExtension());
// We have just generated a valid test certificate, it should still be valid now
assertEquals(cert.getBasicConstraints(), wrappedCert.getBasicConstraints());
assertEquals(cert.getIssuerDN(), wrappedCert.getIssuerDN());
Copy link
Member

Choose a reason for hiding this comment

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

why we need those changes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it seens this deprecated method won't cause build error, I will revert it

build.gradle Outdated
scalaCompileOptions.additionalParameters += ["-Xfatal-warnings"]

scalaCompileOptions.additionalParameters += ["-release", String.valueOf(minJavaVersion)]
options.compilerArgs += ["--release", String.valueOf(minJavaVersion)]
Copy link
Member

Choose a reason for hiding this comment

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

Could you please remove this duplicate config?

@chia7712 chia7712 merged commit 09d76f9 into apache:trunk Oct 25, 2024
abhishekgiri23 pushed a commit to abhishekgiri23/kafka that referenced this pull request Nov 2, 2024
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
chiacyu pushed a commit to chiacyu/kafka that referenced this pull request Nov 30, 2024
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
tedyu pushed a commit to tedyu/kafka that referenced this pull request Jan 6, 2025
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Gradle build or GitHub Actions ci-approved clients connect core Kafka Broker small Small PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants