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

rickhall edited comment on FELIX-953 at 2/23/09 11:25 AM:
-----------------------------------------------------------------

Guillaume, I looked at the code more closely. Could you describe the situation 
in which you are seeing a null being returned? The only time 
ModuleImpl.getClassByDelegation() should return null is if it has detected a 
cycle, but this is not intended to be returned to the caller, it just marks the 
end of the cycle. Perhaps we have a logic bug. This is part of a more recent 
refactoring, so it is likely the issue appeared as a result. I think the intent 
is that the method should always result in an exception if the class cannot be 
found.

      was (Author: rickhall):
    Guillaume, I looked at the code more closely. Could you describe the 
situation in which you are seeing a null being returned? The only time 
ModuleImpl.getClassByDelegation() should return null is if it has detected a 
cycle, but this is not intended to be returned to the caller, it just marks the 
end of the cycle. Perhaps we have a logic bug. I think the intent is that the 
method should always result in an exception if the class cannot be found.
  
> Bundle#loadClass sometimes return null instead of throwing a CNFE
> -----------------------------------------------------------------
>
>                 Key: FELIX-953
>                 URL: https://issues.apache.org/jira/browse/FELIX-953
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>            Reporter: Guillaume Nodet
>            Assignee: Richard S. Hall
>            Priority: Blocker
>         Attachments: FELIX-953.patch
>
>
> Here is a patch:
> {code}
> Index: src/main/java/org/apache/felix/framework/Felix.java
> ===================================================================
> --- src/main/java/org/apache/felix/framework/Felix.java (revision 746347)
> +++ src/main/java/org/apache/felix/framework/Felix.java (working copy)
> @@ -1338,7 +1338,12 @@
>                  throw new ClassNotFoundException(name, ex);
>              }
>          }
> -        return bundle.getCurrentModule().getClassByDelegation(name);
> +        Class clazz = bundle.getCurrentModule().getClassByDelegation(name);
> +        if (clazz == null)
> +        {
> +            throw new ClassNotFoundException(name);
> +        }
> +        return clazz;
>      }
>  
>      /**
> {code}
> I'm wondering if there any reason why ModuleImpl#getClassByDelegation(String) 
> returns null instead of throwing a NPE.
> Browsing through the code, it seems there are several places where a null 
> value is checked, then a CNFE thrown.
> This would also avoid possible NPE in felix code as in 
> Felix#createBundleActivator.
> I think it would be nice to iron the definition of 
> IModule#getClassByDelegation to either remove the thrown CNFE or never 
> returns null, as currently both can happen.
> The IWire interface has exactly the same problem.
> I will try to come up with a patch which will never return a null value for 
> both interfaces.

-- 
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