[BZ-1156297] fix classloader leak caused by ThreadLocal used in UpgradableReentrantReadWriteLock

(cherry picked from commit 58d8025cd4dd7cf495ff603357844fb23201af37)