porting improvements from xwiki-contrib-resilience.