[ 
https://issues.apache.org/jira/browse/FELIX-1124?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12725650#action_12725650
 ] 

Richard S. Hall commented on FELIX-1124:
----------------------------------------

Thomas, I created the following bundle activator:

public class Activator implements BundleActivator
{
    public void start(final BundleContext context) throws Exception
    {
        getClass().getClassLoader().getResourceAsStream("does/not/exist.txt");
    }

    public void stop(BundleContext context)
    {
    }
}

When I run this in Felix I get:

-> ps
START LEVEL 1
   ID   State         Level  Name
[   0] [Active     ] [    0] System Bundle (1.9.0.SNAPSHOT)
[   1] [Active     ] [    1] Apache Felix Shell Service (1.3.0.SNAPSHOT)
[   2] [Active     ] [    1] Apache Felix Shell TUI (1.3.0.SNAPSHOT)
[   3] [Active     ] [    1] Apache Felix Bundle Repository (1.5.0.SNAPSHOT)
[   5] [Installed  ] [    1] test.logger
-> start 5
DEBUG: WIRE: 5.0 -> org.osgi.framework -> 0
DEBUG: does/not/exist.txt 
(org.apache.felix.moduleloader.ResourceNotFoundException: does/not/exist.txt)
->

I do not get a stack trace, which is what I would expect from the code for 
Logger. Are you passing in a Logger instance to Felix when you construct it or 
are you just using Felix' launcher? If the former, I would have to assume that 
the passed in launcher is printing the stack trace.

Let me know if I am missing something.

> ResourceNotFoundException too verbose
> -------------------------------------
>
>                 Key: FELIX-1124
>                 URL: https://issues.apache.org/jira/browse/FELIX-1124
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-1.6.1, felix-1.8.0, felix-1.8.1
>            Reporter: Thomas Diesler
>
> ModuleImpl logs stack traces for every resource that cannot be found. Often 
> resources are optional or may be located at different locations. 
>     public URL getResourceByDelegation(String name)
>     {
>         try
>         {
>             return (URL) findClassOrResourceByDelegation(name, false);
>         }
>         catch (ClassNotFoundException ex)
>         {
>             // This should never be thrown because we are loading resources.
>         }
>         catch (ResourceNotFoundException ex)
>         {
>             m_logger.log(
>                 Logger.LOG_DEBUG,
>                 ex.getMessage(),
>                 ex);
>         }
>         return null;
>     }
> Please consider a log message without stack trace and leave it to the client 
> to be more verbose when appropriate. 
> To log no message at all and simply return null would also be consistent with 
> http://java.sun.com/javase/6/docs/api/java/lang/ClassLoader.html#getResource(java.lang.String)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to