BUG-893: improve ClassLoaderUtils safety

There is a slight possiblity for
ClassLoaderUtils.withClassLoaderAndLock() to not release the lock. Fix
this by refactoring it properly and letting users pick which flavor of
the method they want to use.

Change-Id: I07edd05323d26bfdf6800fbcd28ad9c150599a74
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 1c146bc46b1d071efbcbb2b5960db7d8f7db68bf)
Signed-off-by: Robert Varga <rovarga@cisco.com>
Merge "BUG-893: improve ClassLoaderUtils safety" into stable/hydrogen