This is an automated email from the ASF dual-hosted git repository. benw pushed a commit to branch javax in repository https://gitbox.apache.org/repos/asf/tapestry-5.git
commit aa925eccc978704ec4e51388ee2f69594a8bef46 Author: Ben Weidig <[email protected]> AuthorDate: Sun Apr 5 11:38:40 2026 +0200 tapestry-ioc: AbstractResource double-slash on jar resource fixed --- .../org/apache/tapestry5/ioc/internal/util/AbstractResource.java | 7 +++++-- .../src/test/groovy/ioc/specs/ClasspathResourceSpec.groovy | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AbstractResource.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AbstractResource.java index 5b6a5ff19..15def883c 100644 --- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AbstractResource.java +++ b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AbstractResource.java @@ -294,11 +294,14 @@ public abstract class AbstractResource extends LockSupport implements Resource int indexOfExclamationMark = urlAsString.indexOf('!'); String resourceInJar = urlAsString.substring(indexOfExclamationMark + 2); + if (!resourceInJar.endsWith("/")) + { + resourceInJar += "/"; + } - URL directoryResource = Thread.currentThread().getContextClassLoader().getResource(resourceInJar + "/"); + URL directoryResource = Thread.currentThread().getContextClassLoader().getResource(resourceInJar); boolean isDirectory = directoryResource != null && "jar".equals(directoryResource.getProtocol()); - if (isDirectory) { throw new IOException("Cannot open a stream for a resource that references a directory inside a JAR file (" + url + ")."); diff --git a/tapestry-ioc/src/test/groovy/ioc/specs/ClasspathResourceSpec.groovy b/tapestry-ioc/src/test/groovy/ioc/specs/ClasspathResourceSpec.groovy index f465ffae5..d4db85cd5 100644 --- a/tapestry-ioc/src/test/groovy/ioc/specs/ClasspathResourceSpec.groovy +++ b/tapestry-ioc/src/test/groovy/ioc/specs/ClasspathResourceSpec.groovy @@ -289,7 +289,8 @@ class ClasspathResourceSpec extends Specification { def resourcePath = 'META-INF/maven/org.slf4j/slf4j-api/pom.xml' // TAP5-2825: This failes on Java 21, as Groovy can no longer access the - // protected methods `findResources`, so we use `getResources` instead + // protected methods `findResources`, so we use `getResources` instead, + // as it returns the same underlying Enumeration<URL>. def resourceURLs = currentCl.getResources(resourcePath).toList() def slf4jApiURL = resourceURLs.find{it.toString().contains('.jar!')} ClassLoader cl = new URLClassLoader(slf4jApiURL as URL[], (ClassLoader) null)
