Race-condition in EntityCapabilitiesManager when deleting user

Description

When a user gets deleted, the `userDeleting` event handler in `EntityCapabilitiesManager` is designed to remove all of the user's capabilities from the `entityCapabilitiesUserMap`. It does so by

  1. looking up the matching keys (see if the full JID keys match the user's bare JID), followed by

  2. a removal of the matching entries.

  3. Finally, a check is preformed to see if the 'ver' hash that was associated with them remains in use (by unrelated entries). If not, that can be removed too.

There is a race condition where between 1 and 2, another event might modified the map. For example, deleting a user can go hand-in-hand with sending an unavailable presence for that same user, causing another thread from removing an entry from the map. This can lead to situations where the second step results in a `null` value being passed to the third step, which will then throw a NullPointerException (as it does not allow for null arguments to be used.

Environment

None
Fixed

Assignee

Guus der Kinderen

Reporter

Guus der Kinderen

Labels

None

Expected Effort

None

Ignite Forum URL

None

Components

Fix versions

Priority

Minor