Copilot commented on code in PR #21267:
URL: https://github.com/apache/kafka/pull/21267#discussion_r2669627555
##########
core/src/test/scala/integration/kafka/api/PlaintextAdminIntegrationTest.scala:
##########
@@ -4476,7 +4476,7 @@ class PlaintextAdminIntegrationTest extends
BaseAdminIntegrationTest {
TestUtils.waitUntilTrue(() => {
val firstGroup = client.listGroups().all().get().stream()
.filter(g => g.groupId() == streamsGroupId).findFirst().orElse(null)
- firstGroup.groupState().orElse(null) == GroupState.NOT_READY &&
firstGroup.groupId() == streamsGroupId
+ firstGroup != null && firstGroup.groupState().orElse(null) ==
GroupState.NOT_READY && firstGroup.groupId() == streamsGroupId
Review Comment:
The similar test method testDescribeStreamsGroups (line 4432) has the same
potential NullPointerException issue where it checks firstGroup.groupState()
without first verifying firstGroup is not null. For consistency and to prevent
the same flaky test behavior, it should also be updated to check firstGroup !=
null before accessing its methods.
```suggestion
if (firstGroup == null) {
false
} else {
firstGroup.groupState().orElse(null) == GroupState.NOT_READY &&
firstGroup.groupId() == streamsGroupId
}
```
##########
core/src/test/scala/integration/kafka/api/PlaintextAdminIntegrationTest.scala:
##########
@@ -4476,7 +4476,7 @@ class PlaintextAdminIntegrationTest extends
BaseAdminIntegrationTest {
TestUtils.waitUntilTrue(() => {
val firstGroup = client.listGroups().all().get().stream()
.filter(g => g.groupId() == streamsGroupId).findFirst().orElse(null)
- firstGroup.groupState().orElse(null) == GroupState.NOT_READY &&
firstGroup.groupId() == streamsGroupId
+ firstGroup != null && firstGroup.groupState().orElse(null) ==
GroupState.NOT_READY && firstGroup.groupId() == streamsGroupId
Review Comment:
The condition check is redundant. Once you verify firstGroup != null,
checking firstGroup.groupId() == streamsGroupId is unnecessary because the
filter already ensures that g.groupId() == streamsGroupId. Only groups matching
this condition can be found by findFirst(). Consider simplifying the condition
to just check firstGroup != null && firstGroup.groupState().orElse(null) ==
GroupState.NOT_READY.
```suggestion
firstGroup != null && firstGroup.groupState().orElse(null) ==
GroupState.NOT_READY
```
--
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]