mustache.java icon indicating copy to clipboard operation
mustache.java copied to clipboard

NullPointerException when context ClassLoader retrieves the Bootstrap Class Loader

Open Macinto5h opened this issue 2 years ago • 0 comments

Within the ClassPathResolver a ClassLoader is used to retrieve a URL resource in the getReader method. This class loader is retrieved from the current thread's defined context class loader. However, if the current thread's context class loader is only Java's bootstrap class loader, the value returned is null.

This causes a null pointer exception to occur when the code attempts to use the bootstrap class loader. Would it be possible to have an exception thrown that the context class loader needs a parent class loader to properly retrieve resources?

Maybe there could be a future solution to the issue to allow that class loader to be optionally defined as an argument that can be passed into that method.

Macinto5h avatar Mar 12 '22 17:03 Macinto5h