Skip to content

Commit

Permalink
Merge pull request #30242 from aloubyansky/classloader-npe2
Browse files Browse the repository at this point in the history
Throw an IllegalStateException with basic info about the provider that failed to provide a resource
  • Loading branch information
gsmet authored Jan 9, 2023
2 parents 5fe0d02 + a9827a8 commit c4da818
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,12 @@ public InputStream getResourceAsStream(String unsanitisedName) {
if (name.endsWith(".class")) {
ClassPathElement[] providers = state.loadableResources.get(name);
if (providers != null) {
return new ByteArrayInputStream(providers[0].getResource(name).getData());
final ClassPathResource resource = providers[0].getResource(name);
if (resource == null) {
throw new IllegalStateException(providers[0] + " from " + getName() + " (closed=" + this.isClosed()
+ ") was expected to provide " + name + " but failed");
}
return new ByteArrayInputStream(resource.getData());
}
} else {
for (ClassPathElement i : elements) {
Expand Down

0 comments on commit c4da818

Please sign in to comment.