-
Notifications
You must be signed in to change notification settings - Fork 14.9k
KAFKA-16564: Apply Xlint to java code in core module
#16965
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
Conversation
d3d4aa0 to
dc7924f
Compare
91b39ca to
d7c6761
Compare
build.gradle
Outdated
| if (name == "compileTestJava" || name == "compileTestScala") | ||
| if (name == "compileTestJava" || name == "compileTestScala") { | ||
| options.compilerArgs << "-parameters" | ||
| } else if (name == "compileJava") { |
There was a problem hiding this comment.
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 could you please rebase code and fix conflicts? |
# Conflicts: # core/src/test/java/kafka/admin/ConfigCommandTest.java
|
I have been fix it, Thanks for your reminder. |
|
@m1a2st could you please rebase code and fix conflicts? |
# Conflicts: # core/src/main/java/kafka/server/handlers/DescribeTopicPartitionsRequestHandler.java
build.gradle
Outdated
| options.compilerArgs << "-Xlint:-serial" | ||
| options.compilerArgs << "-Xlint:-try" | ||
| options.compilerArgs << "-Werror" | ||
| options.compilerArgs << "-Xlint:-options" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
chia7712
left a comment
There was a problem hiding this 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") { |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
|
@m1a2st please fix build error |
0701e8c to
99dd032
Compare
chia7712
left a comment
There was a problem hiding this 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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicate config?
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)] |
There was a problem hiding this comment.
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?
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
Jira: https://issues.apache.org/jira/browse/KAFKA-16564
We should apply the same
xlintto java code in core module before we complete the code migration.Committer Checklist (excluded from commit message)