spullara / spullara/mustache.java

NullPointerException when context ClassLoader retrieves the Bootstrap Class Loader

Open
#277 0 comments 1 reaction 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.