Details
Description
Shutting down an idle XWiki instance takes over 30 seconds.
Repeat by starting an XWiki instance containing the XWiki Standard Flavor, wait for it to become idle and then stop it again.
I've tracked the problem down to org.xwiki.component.embed.EmbeddableComponentManager.dispose() where it repeatedly calls sortEntry(). This loops many more times than keys.size() because i jumps backwards as well as incrementing. I suggest using a sorting algorithm like Topological sorting Depth-first search instead.