GLM-5.3 Flash · 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
2 of 2
Comments published
4
Comments matching a bug
2
Comments not matching
2
Cost of this PR
$0.102

Published comments (4)

mediumbugmodel/infinispan/src/main/java/org/keycloak/models/cache/infinispan/GroupAdapter.java:271-276

Sibling getSubGroupsStream overloads still lack the null guard — The same concurrent-deletion race still throws an NPE through the unguarded `modelSupplier.get()` calls in the three `getSubGroupsStream` overloads, so the fix is only partial. Apply the same null check, or a shared null-safe accessor, at all four call sites.

mediumbugtests/base/src/test/java/org/keycloak/tests/admin/group/GroupTest.java:139-155

Reader thread may finish no reads before deletes complete, passing vacuously — On a slow or loaded machine all 100 deletes can finish before the reader thread's first call, so the loop exits having read nothing and the assertion passes vacuously — the race is never exercised. Gate the delete loop on a latch that the reader signals once running.

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

getSubGroupsCount() returns null, violating GroupModel never-null contract — Callers relying on the `GroupModel` contract ("Never returns null" in server-spi) that unbox the result to a primitive `long` will now hit a fresh NullPointerException. Return a fallback such as `0L`, or document the contract change on the interface.

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

Reader thread not joined before asserting caughtExceptions is empty — A request still in flight when `deletedAll.set(true)` runs can append to `caughtExceptions` after the assertion has already passed, hiding the very NPE this test guards against. Keep a reference to the reader thread, join it after the delete loop, then assert.

Gold bugs found (2)

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.
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.

Gold bugs missed (0)

None.