Improve ClassLoaderUtils.loadClassWithTCCL() 61/70661/1
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 9 Apr 2018 13:38:33 +0000 (15:38 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 9 Apr 2018 13:46:51 +0000 (15:46 +0200)
commit40997323a598045510a525aecd51dd84a5c1c64b
treeff572eff25580d1238694d4c017884fc43b8f8db
parentd6b396379c2630b5aaff6b9f6b0596b922223c62
Improve ClassLoaderUtils.loadClassWithTCCL()

There are scenarios when we do not have a Thread Context Class Loader,
such as when executing from Netty's GlobalEventExecutor. When we attempt
to load a class in that scenario, the method will throw a NPE, which
exposes users which can deal with the class not being able to load
to a RuntimeException -- preventing recovery.

Detect the case when TCCL is null and report a failure to load the class,
noting the reason for the failure.

Change-Id: Ia6837ba451d290a2070bc24e9e7088c60275cae0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 4a3cc19a42b3740ec518569ca274153b66f2bc82)
common/util/src/main/java/org/opendaylight/yangtools/util/ClassLoaderUtils.java