From add0e8f1d7373926187b90cca13e1db1ee0050a9 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Fri, 16 Aug 2024 11:25:41 +0200 Subject: [PATCH] Honor parentFirst in QuarkusClassLoader#getElementsWithResource() For whatever reason, we weren't honoring parentFirst in this method which looks like an oversight and un undesirable behavior. --- .../bootstrap/classloading/QuarkusClassLoader.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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 8d98f93f152bc..e769abddc1806 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 @@ -602,15 +602,21 @@ public List getElementsWithResource(String name) { public List getElementsWithResource(String name, boolean localOnly) { ensureOpen(name); + boolean parentFirst = parentFirst(name, getClassPathResourceIndex()); + List ret = new ArrayList<>(); - if (parent instanceof QuarkusClassLoader && !localOnly) { + + if (parentFirst && !localOnly && parent instanceof QuarkusClassLoader) { ret.addAll(((QuarkusClassLoader) parent).getElementsWithResource(name)); } + List classPathElements = getClassPathResourceIndex().getClassPathElements(name); - if (classPathElements.isEmpty()) { - return ret; - } ret.addAll(classPathElements); + + if (!parentFirst && !localOnly && parent instanceof QuarkusClassLoader) { + ret.addAll(((QuarkusClassLoader) parent).getElementsWithResource(name)); + } + return ret; }