mirror of https://github.com/apache/kafka.git
KAFKA-16564 Apply `Xlint` to java code in core module (#16965)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
This commit is contained in:
parent
33147d1089
commit
09d76f917c
29
build.gradle
29
build.gradle
|
@ -113,11 +113,22 @@ ext {
|
|||
|
||||
commitId = determineCommitId()
|
||||
|
||||
addParametersForTests = { name, options ->
|
||||
configureJavaCompiler = { 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")
|
||||
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)]
|
||||
}
|
||||
}
|
||||
|
||||
runtimeTestLibs = [
|
||||
|
@ -308,16 +319,7 @@ subprojects {
|
|||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = 'UTF-8'
|
||||
options.compilerArgs << "-Xlint:all"
|
||||
// temporary exclusions until all the warnings are fixed
|
||||
if (!project.path.startsWith(":connect") && !project.path.startsWith(":storage"))
|
||||
options.compilerArgs << "-Xlint:-rawtypes"
|
||||
options.compilerArgs << "-Xlint:-serial"
|
||||
options.compilerArgs << "-Xlint:-try"
|
||||
options.compilerArgs << "-Werror"
|
||||
options.release = minJavaVersion
|
||||
addParametersForTests(name, options)
|
||||
configureJavaCompiler(name, options)
|
||||
}
|
||||
|
||||
if (shouldPublish) {
|
||||
|
@ -769,9 +771,8 @@ subprojects {
|
|||
scalaCompileOptions.additionalParameters += ["-Xfatal-warnings"]
|
||||
|
||||
scalaCompileOptions.additionalParameters += ["-release", String.valueOf(minJavaVersion)]
|
||||
options.compilerArgs += ["--release", String.valueOf(minJavaVersion)]
|
||||
|
||||
addParametersForTests(name, options)
|
||||
configureJavaCompiler(name, options)
|
||||
|
||||
configure(scalaCompileOptions.forkOptions) {
|
||||
memoryMaximumSize = defaultMaxHeapSize
|
||||
|
|
|
@ -456,6 +456,7 @@ public class SynchronizationTest {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private static ThreadFactory threadFactoryWithNamedThreads(String threadPrefix) {
|
||||
AtomicInteger threadNumber = new AtomicInteger(1);
|
||||
return r -> {
|
||||
|
|
|
@ -221,6 +221,7 @@ public class RemoteLogManager implements Closeable {
|
|||
* @param brokerTopicStats BrokerTopicStats instance to update the respective metrics.
|
||||
* @param metrics Metrics instance
|
||||
*/
|
||||
@SuppressWarnings({"this-escape"})
|
||||
public RemoteLogManager(RemoteLogManagerConfig rlmConfig,
|
||||
int brokerId,
|
||||
String logDir,
|
||||
|
@ -331,6 +332,7 @@ public class RemoteLogManager implements Closeable {
|
|||
rlmConfig.remoteLogManagerFetchQuotaWindowSizeSeconds());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T> T createDelegate(ClassLoader classLoader, String className) {
|
||||
try {
|
||||
return (T) classLoader.loadClass(className)
|
||||
|
|
|
@ -1312,6 +1312,7 @@ public class ConfigCommandTest {
|
|||
return describeResult;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public synchronized AlterConfigsResult alterConfigs(Map<ConfigResource, Config> configs, AlterConfigsOptions options) {
|
||||
assertEquals(1, configs.size());
|
||||
|
|
Loading…
Reference in New Issue