On 2/8/12 15:19 , Irving Cordova wrote:
Hi,

I am currently using a 3rd party component in a small project of mine. This
component tries to dynamically load resources from a given URL, it does
this by trying several extensions for a base name, and returns success when
it finds a resource that matches the base name and extension. For this
dynamic loading it depends on URL.openStream(). If openStream returns
FileNotFoundException it continues looking, but if openStream returns
IOException it assumes something is wrong with the resource, stops looking
and throws an exception. This works fine in a non OSGi environment, and
also inside equinox, however it does not work inside Felix. Felix throws a
IOException with the message: "Resource does not exist" instead of a
FileNotFoundException. Compare the stack traces:

Felix:

java.io.IOException: Resource does not exist:
bundle://93.0:1/resource/myresource.stg
at
org.apache.felix.framework.URLHandlersBundleURLConnection.<init>(URLHandlersBundleURLConnection.java:131)
at
org.apache.felix.framework.URLHandlersBundleStreamHandler.openConnection(URLHandlersBundleStreamHandler.java:64)
at java.net.URL.openConnection(URL.java:945)
at java.net.URL.openStream(URL.java:1010)

Equinox:

java.io.FileNotFoundException: /resource/myresource.stg
at
org.eclipse.osgi.framework.internal.protocol.bundleresource.Handler.findBundleEntry(Handler.java:51)
at
org.eclipse.osgi.framework.internal.core.BundleResourceHandler.openConnection(BundleResourceHandler.java:175)
at java.net.URL.openConnection(URL.java:945)
at java.net.URL.openStream(URL.java:1010)

Shouldn't the appropriate exception be FileNotFoundException ?

It doesn't necessarily seem like this is more appropriate. We are not talking about a file in the file system, we are talking about a resource in a JAR file. I see nothing in the API JavaDoc that indicates that openConnection() should through a FileNotFoundException, nor specifically should it through such an exception to indicate a less severe error type than IOException.

So, I guess the question is, do should we modify the framework to always throw FileNotFoundException when it cannot find the resource to participate in this non-standard protocol?

It's not clear to me that it makes sense to me, but you could open a feature request in JIRA and assign it to the framework component for consideration.

Thanks.

-> richard


Regards,

Irving Cordova
http://irvingc.com


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to