-
Notifications
You must be signed in to change notification settings - Fork 14.6k
MINOR: suppress build warning #20424
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
@@ -1978,7 +1978,7 @@ public ProductionExceptionHandlerResponse handle(final ErrorHandlerContext conte | |||
assertNull(sourceRawData[1]); | |||
} | |||
|
|||
|
|||
@SuppressWarnings("unchecked") |
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.
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.
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.
Oh, I get your point.
It seems L1988 has already suppressed the warning.
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.
Hmmm... I did see a gradle build warning -- I am pretty sure. But now I cannot reproduce it. 🤷
Will revert this. Found some other necessary cleanup though...
8757a09
to
7f6f7ba
Compare
Still seeing, but IntelliJ does not highlight anything, and I cannot spot the issue.
|
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.
Still seeing, but IntelliJ does not highlight anything, and I cannot spot the issue.
> Task :server:compileTestJava
/home/chia7712/project/kafka/server/src/test/java/org/apache/kafka/server/quota/ClientQuotasRequestTest.java:499: warning: [unchecked] unchecked method invocation: method ofEntries in interface Map is applied to given types
Map<Object, Object> expectedMatchesMap = Map.ofEntries(expectedMatches.toArray(new Map.Entry[0]));
^
required: Entry<? extends K,? extends V>[]
found: Entry[]
where K,V are type-variables:
K extends Object declared in method <K,V>ofEntries(Entry<? extends K,? extends V>...)
V extends Object declared in method <K,V>ofEntries(Entry<? extends K,? extends V>...)
/home/chia7712/project/kafka/server/src/test/java/org/apache/kafka/server/quota/ClientQuotasRequestTest.java:499: warning: [unchecked] unchecked conversion
Map<Object, Object> expectedMatchesMap = Map.ofEntries(expectedMatches.toArray(new Map.Entry[0]));
^
required: Map<Object,Object>
found: Map
2 warnings
Following my other comment, we can reproduce the warning above.
build.gradle
Outdated
@@ -740,6 +740,7 @@ subprojects { | |||
// For more details, refer to https://github.com/gradle/gradle/issues/13762. | |||
// As a result, we need to explicitly configure the Scala compiler with this setting. | |||
options.compilerArgs += ["--release", String.valueOf(releaseVersion)] | |||
options.compilerArgs += ["-Xlint:unchecked"] |
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.
Perhaps -Xlint:unchecked
should be added at line 127 so that all warnings are visible.
if (name in ["compileTestJava", "compileTestScala"]) {
options.compilerArgs << "-parameters"
options.compilerArgs << "-Xlint:unchecked"
}
I still don't get this output... Not sure why 🤷 |
assertEquals(props.getProperty("my.empty.property"), "", "Value of a key with missing value should be an empty string"); | ||
assertEquals(props.getProperty("my.empty.property1"), "", "Value of a key with missing value with no delimiter should be an empty string"); | ||
assertEquals("", props.getProperty("my.empty.property"), "Value of a key with missing value should be an empty string"); | ||
assertEquals("", props.getProperty("my.empty.property1"), "Value of a key with missing value with no delimiter should be an empty string"); |
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.
Fixing incorrect order for expected vs actual value.
That’s strange. I tested JDK 17, 21, and 24 according to this comment, and all of them printed the unchecked warnings. The following outputs were generated on my local setup. Since
|
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.
@mjsax thanks for this patch. not all warnings are fixed but it looks good enough. I just have one small comment left
build.gradle
Outdated
@@ -3362,6 +3362,7 @@ project(':jmh-benchmarks') { | |||
tasks.withType(JavaCompile) { | |||
// Suppress warning caused by code generated by jmh: `warning: [cast] redundant cast to long` | |||
options.compilerArgs << "-Xlint:-cast" | |||
options.compilerArgs << "-Xlint:unchecked" |
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.
This should be included by -Xlint:all
, right?
https://github.com/apache/kafka/blob/trunk/build.gradle#L129
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.
Happy to remove it -- it seems something is off with my local setup -- I don't see the full warn output as you do, and adding this flag did make a difference for me... so 🤷
Suppress build warning.
Reviewers: TengYao Chi [email protected], Ken Huang
[email protected], Chia-Ping Tsai [email protected]