From a9827a853c9fdd20735e461716add605a5901eaa Mon Sep 17 00:00:00 2001 From: Alexey Loubyansky Date: Sat, 7 Jan 2023 08:51:02 +0100 Subject: [PATCH] Throw an IllegalStateException with basic info about the provider that failed to provide a resource --- .../quarkus/bootstrap/classloading/QuarkusClassLoader.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/QuarkusClassLoader.java b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/QuarkusClassLoader.java index 35dfd19b162cb..440a8d6f5f238 100644 --- a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/QuarkusClassLoader.java +++ b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/QuarkusClassLoader.java @@ -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) {