Skip to content

Handle a null context classloader when resolving templates - #316

Open
illusionoftalha wants to merge 1 commit into
spullara:mainfrom
illusionoftalha:fix/null-context-classloader
Open

illusionoftalha wants to merge 1 commit into
spullara:mainfrom
illusionoftalha:fix/null-context-classloader

Conversation

@illusionoftalha

Copy link
Copy Markdown

Fixes #277.

ClasspathResolver.getReader dereferences the thread context classloader even when it is null. A context classloader with no matching resource already falls back to the resolver's defining classloader; use that same loader up front when the context loader itself is absent. This retains the existing resource and directory checks.

Add three JUnit regressions for a null context classloader: finding an existing template, returning null for a missing template, and rejecting a directory. Each test restores the original context classloader in a finally block.

Validation on Windows / JDK 17:

  • Before the source fix, all three new tests throw NullPointerException.
  • mvn -DCI=true -pl compiler -am -Dtest=ClasspathResolverTest -Dsurefire.failIfNoSpecifiedTests=false test: 19 tests passed.
  • The broader compiler run executes 288 tests, with seven failures and eight skips. I repeated it with the original resolver from base commit 023374b: the same seven failures remain, plus the three new classloader errors. The seven unchanged failures are newline-sensitive assertions in DynamicNamesTest, InterpreterTest, Issue278Test, MultipleRecursivePartialsTest and PreTranslateTest.
  • A full mvn -DCI=true package attempt stops at those compiler test failures, so the remaining reactor modules were not validated. The CI flag avoids the project's unrelated benchmark loops.
  • git diff --check passes. No test resources are included in the patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NullPointerException when context ClassLoader retrieves the Bootstrap Class Loader

1 participant