Skip to content

Commit

Permalink
fix for issue NullPointerException in ClassList.loadClassList when co…
Browse files Browse the repository at this point in the history
…ntext class loader is unavailable in current thread (ninia#401)
  • Loading branch information
Htarlov committed May 24, 2022
1 parent ea9493b commit 43e5311
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/java/jep/ClassList.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,17 @@ private void loadClassList() throws JepException {
* different ClassLoader than classes (e.g. tomcat), while the Jep.class
* ClassLoader is useful if running inside an OSGi container as a Bundle
* (e.g. eclipse).
* If there is no context ClassLoader then system ClassLoader will be tried.
*/
boolean hasContextClassloader = Thread.currentThread() != null
&& Thread.currentThread().getContextClassLoader() != null;
ClassLoader parentClassLoader = hasContextClassloader
? Thread.currentThread().getContextClassLoader()
: ClassLoader.getSystemClassLoader();
ClassLoader[] classloadersToTry = new ClassLoader[] {
Thread.currentThread().getContextClassLoader(),
Jep.class.getClassLoader() };
parentClassLoader,
Jep.class.getClassLoader()
};
String rsc = "jep/classlist_";
if (version.startsWith("1.8")) {
rsc += "8";
Expand Down

0 comments on commit 43e5311

Please sign in to comment.