Merge pull request #3189 from igniterealtime/backport-3122-to-5.0
[Backport 5.0] OF-3164: Avoid user lookup for JIDs without node to reduce exception overhead
OF-3164: Avoid user lookup for JIDs without node to reduce exception overhead
Prevent execution of user lookup logic when the provided JID has no node. JIDs without a node part cannot represent a local user, yet currently flow through UserManager.isRegisteredUser(), which relies on exception-based control flow when the user does not exist.
Thread dumps show significant CPU time spent constructing UserNotFoundException instances (Throwable.fillInStackTrace) on this hot path.
This change short-circuits the lookup for node-less JIDs, avoiding the exception-heavy path and reducing unnecessary CPU usage under load.
Note: This is a partial workaround. A full fix should refactor user existence checks to avoid exceptions for normal control flow.
Additionally, more unit tests were added.
(cherry picked from commit 3c55066eb3b9b57f9709f1f21fc533817045a06b)