From 901b8d2065fb6d948e13e75480561c8905a12a14 Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Fri, 26 Jan 2024 14:04:08 +0100 Subject: [PATCH] fixed an infinite recursion caused by the getResources method of SourceLocationClassLoader. This method would only be called by the plugin mechanism of Selenium when activated from the rascal tutor command executor wrapper for taking snapshots during documentation generation --- .../SourceLocationClassLoader.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/org/rascalmpl/uri/classloaders/SourceLocationClassLoader.java b/src/org/rascalmpl/uri/classloaders/SourceLocationClassLoader.java index 5459bba761e..307ba73b23b 100644 --- a/src/org/rascalmpl/uri/classloaders/SourceLocationClassLoader.java +++ b/src/org/rascalmpl/uri/classloaders/SourceLocationClassLoader.java @@ -160,10 +160,23 @@ public URL getResource(String name) { public Enumeration getResources(String name) throws IOException { List result = new ArrayList<>(path.size()); + for (ClassLoader l : path) { - Enumeration e = l.getResources(name); - while (e.hasMoreElements()) { - result.add(e.nextElement()); + SearchItem item = new SearchItem(l, name); + + if (stack.contains(item)) { + continue; + } + try { + stack.push(item); + + Enumeration e = l.getResources(name); + while (e.hasMoreElements()) { + result.add(e.nextElement()); + } + } + finally { + stack.pop(); } }