XWIKI-8872: MessageTool can read from the wrong context in scheduler jobs or threads
(cherry picked from commit 9a33f9f396e4b9377e78b803687ad1730f8260cc)