spullara / spullara/mustache.java
NullPointerException when context ClassLoader retrieves the Bootstrap Class Loader
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 2k
- Forks
- 281
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in ClassPathResolver.getReader, where the current thread's context class loader is used to retrieve a URL resource. Reproduce the bootstrap-class-loader case and make the result a clear exception rather than a NullPointerException; verify that normal context class loaders still retrieve resources correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100