You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Grzegorz Grzybek (Jira)" <ji...@apache.org> on 2020/07/03 15:42:00 UTC
[jira] [Created] (FELIX-6294) Missing trailing slash with
Bundle.getResource() for directory entry
Grzegorz Grzybek created FELIX-6294:
---------------------------------------
Summary: Missing trailing slash with Bundle.getResource() for directory entry
Key: FELIX-6294
URL: https://issues.apache.org/jira/browse/FELIX-6294
Project: Felix
Issue Type: Bug
Components: Framework
Reporter: Grzegorz Grzybek
I'm working on Pax Web 8 and I try to unify _welcome file_ handling across Jetty/Tomcat/Undertow.
When accessing _directory entries_ from a bundle ({{org.osgi.framework.Bundle#getResource()}} I found different behavior between Felix and Equinox.
Trying to pass {{/META-INF/}} and {{/META-INF}} resource names to {{getResource()}} method, I'm getting different results for Felix:
* bundle://19.0:1/META-INF/
* bundle://19.0:1/META-INF
and Equinox:
* bundleresource://19.fwk1529115495/META-INF/
* bundleresource://19.fwk1529115495/META-INF/
Underneath, both implementations call {{java.util.zip.ZipFile#getEntry(java.lang.String)}}, but only Equniox has special {{org.eclipse.osgi.storage.bundlefile.BundleFile#fixTrailingSlash()}} method that adjusts the returned URL according to passed name and actual ZIP entry ({{java.util.zip.ZipEntry#getName()}}.
This makes detection of _a directory_ obtained from a bundle much harder with Felix. Also {{org.eclipse.jetty.util.resource.URLResource#isDirectory()}} is simply:
{code:java}
public boolean isDirectory()
{
return exists() && _urlString.endsWith("/");
}
{code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)