ninia / jep

Embed Python in Java
Other
1.3k stars 147 forks source link

NullPointerException in ClassList.loadClassList when context class loader is unavailable in current thread. #401

Closed Htarlov closed 1 year ago

Htarlov commented 2 years ago

Describe the bug If we try to use Jep from a thread that has context class loader null (e.g. thread created from the outside of Java runtime) it fails with java.lang.NullPointerException at line 282 in ClassList in method loadClassList.

To Reproduce Not yet have code to reproduce. A possible way similar to what we try to do:

Expected behavior Instance of the class should be created without exception.

Environment (please complete the following information):

Additional context When Thread.currentThread().getContextClassLoader() returns null then that null is added to the list of class loaders and then code tries to call in = cl.getResourceAsStream(rsc); and fails. A null check is needed before adding a class loader to the list.

ndjensen commented 1 year ago

Fixed in Jep 4.1.0.