Amazon Ergo 1.0 · Heavy

fix-concurrent-group-access-to-prevent-nullpointerexception-keycloak

Keycloak · Java · XS · <30 lines · 3 files

The generalist plus 9 specialist lens agents in parallel, then the same verify and dedup steps. Judge: Claude Opus 5.5.

Gold bugs found
1 of 2
Comments published
2
Comments matching a bug
1
Comments not matching
1
Cost of this PR
$1.438

Published comments (2)

mediumbugmodel/infinispan/src/main/java/org/keycloak/models/cache/infinispan/GroupAdapter.java:272-275

getSubGroupsCount() returns null for a concurrently removed group — A stale group appears to have children in the admin UI, and SPI callers can unbox the null propagated through `GroupUtils.populateSubGroupCount()` and throw `NullPointerException`. Return `0L` from `getSubGroupsCount()` or filter out the stale group.

mediumbugtests/base/src/test/java/org/keycloak/tests/admin/group/GroupTest.java:138-157

Reader thread is not synchronized with deletion and assertion — A regression can stay green: the reader may perform no reads if it starts after `deletedAll` is set, or update `caughtExceptions` after the assertion. Gate it with a start latch, join it before asserting, and verify that it completed at least one read.

Gold bugs found (1)

mediumThe concurrency regression test never waits for the reader thread before asserting no exceptions, so it can pass even when the concurrent-deletion NPE still occurs.

Gold bugs missed (1)

mediumThe null guard for a concurrently deleted cached group is added only to getSubGroupsCount; the getSubGroupsStream overloads still dereference modelSupplier.get(), so e.g. GroupResource.getSubGroups still throws the NPE the PR set out to fix.