DeepSeek V4.1 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 Haiku 5.5.

Gold bugs found
0 of 0
Comments published
4
Comments matching a bug
0
Comments not matching
4
Cost of this PR
$0.162

Published comments (4)

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

getSubGroupsCount may return null when cached group is unresolved — Returning null breaks the contract, and `GroupUtils` passes the value straight into `representation.setSubGroupCount(...)`, so the count can be silently absent or NPE on unboxing. Return a non-null default such as 0, or handle null in that consumer.

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

Reader thread not joined before asserting caught exceptions — An exception from the request in flight during the concurrent-delete window may not yet be in `caughtExceptions`, so the test can pass while the NPE still reproduces. Join the reader thread before the `assertThat(caughtExceptions, Matchers.empty())` check.

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

Reader thread is not joined before the exception assertion — The assertion reads `caughtExceptions` while the reader thread can still append, so a racing exception may be recorded after it passes, or the loop may exit without a read against the deleted state. Join the reader thread before `assertThat(caughtExceptions, Matchers.empty())` so every raced read counts.

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

Reader thread can loop forever when group deletion throws — If any `remove()` throws, `deletedAll.set(true)` is never reached and the non-daemon reader thread spins in a delay-free loop, hanging the forked JVM. Set the flag in a `finally` around the delete loop and join the thread with a bounded timeout before asserting.

Gold bugs found (0)

None.

Gold bugs missed (0)

None.