Copilot commented on code in PR #20019:
URL: https://github.com/apache/kafka/pull/20019#discussion_r2161676037
##########
streams/src/test/java/org/apache/kafka/streams/tests/SmokeTestDriver.java:
##########
@@ -591,6 +599,18 @@ private static boolean verify(final PrintStream
resultStream,
}
}
+ private static Boolean lessEquals(final Number expected, final Number
actual) {
Review Comment:
Change the return type of `lessEquals` from `Boolean` to primitive `boolean`
to avoid unnecessary boxing/unboxing.
```suggestion
private static boolean lessEquals(final Number expected, final Number
actual) {
```
##########
streams/src/test/java/org/apache/kafka/streams/tests/SmokeTestDriver.java:
##########
@@ -591,6 +599,18 @@ private static boolean verify(final PrintStream
resultStream,
}
}
+ private static Boolean lessEquals(final Number expected, final Number
actual) {
+ if (actual instanceof Integer && expected instanceof Integer) {
+ return actual.intValue() >= expected.intValue();
+ } else if (actual instanceof Long && expected instanceof Long) {
+ return actual.longValue() >= expected.longValue();
+ } else if (actual instanceof Double && expected instanceof Double) {
+ return actual.doubleValue() >= expected.doubleValue();
+ } else {
+ throw new RuntimeException("Unexpected type: " +
actual.getClass());
+ }
Review Comment:
The current implementation of `lessEquals` only handles cases where both
`expected` and `actual` are of the same numeric type; mixed-type comparisons
(e.g., `Integer` vs `Long`) will fall through and throw. Consider normalizing
to a common type (e.g., `doubleValue()`) or supporting more combinations.
```suggestion
if (expected == null || actual == null) {
throw new IllegalArgumentException("Expected and actual values
must not be null");
}
return actual.doubleValue() >= expected.doubleValue();
```
##########
streams/src/test/java/org/apache/kafka/streams/tests/SmokeTestDriver.java:
##########
@@ -591,6 +599,18 @@ private static boolean verify(final PrintStream
resultStream,
}
}
+ private static Boolean lessEquals(final Number expected, final Number
actual) {
+ if (actual instanceof Integer && expected instanceof Integer) {
+ return actual.intValue() >= expected.intValue();
+ } else if (actual instanceof Long && expected instanceof Long) {
+ return actual.longValue() >= expected.longValue();
+ } else if (actual instanceof Double && expected instanceof Double) {
+ return actual.doubleValue() >= expected.doubleValue();
+ } else {
+ throw new RuntimeException("Unexpected type: " +
actual.getClass());
Review Comment:
Use a more specific exception type such as `IllegalArgumentException` for
unexpected input rather than a generic `RuntimeException`.
```suggestion
throw new IllegalArgumentException("Unexpected type: " +
actual.getClass());
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]