You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "David Bosschaert (JIRA)" <ji...@apache.org> on 2014/09/25 21:58:33 UTC

[jira] [Commented] (FELIX-4654) NullPointerException in BundleWiringImpl.findClassOrResourceByDelegation()

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

David Bosschaert commented on FELIX-4654:
-----------------------------------------

Thanks Dirk for reporting this issue. Looking at the the source code of 4.2.0 line 1472 the issue seems to be the following:
{code}result = (isClass)
  ? (Object) ((BundleClassLoader) getClassLoader()).findClass(name)
  : (Object) m_revision.getResourceLocal(name);
{code}
getClassLoader() seems to return null, which can cause the NPE (m_revision cannot be null as it's a final field).

Looking at the latest trunk, this issue seems to have been resolved there. The relevant code on trunk is on lines start at 1512:
{code}                    if (isClass)
                    {
                        ClassLoader cl = getClassLoaderInternal();
                        if (cl == null)
                        {
                            throw new ClassNotFoundException(
                                "Unable to load class '"
                                + name
                                + "' because the bundle wiring for "
                                + m_revision.getSymbolicName()
                                + " is no longer valid.");
                        }
                        result = ((BundleClassLoader) cl).findClass(name);
                    }
                    else
                    {
                        result = m_revision.getResourceLocal(name);
                    }
{code}
So if the classloader cannot be found, a CNFE is thrown which should be picked up by the classloader as an ordinary signal that the class isn't available.

Is there any chance that you could check this with the latest Felix?

> NullPointerException in BundleWiringImpl.findClassOrResourceByDelegation()
> --------------------------------------------------------------------------
>
>                 Key: FELIX-4654
>                 URL: https://issues.apache.org/jira/browse/FELIX-4654
>             Project: Felix
>          Issue Type: Bug
>    Affects Versions: framework-4.2.0
>            Reporter: Dirk Rudolph
>
> There is a potential NPE in the implementation of BundleWiringImpl.findClassOrResourceByDelegation(). When the Implementation tries to load a class using the classloader of the wiring null can be returned in case when the wiring has been disposed. I think in this case the null pointer should be handled properly instead of throwing an exception. 
> {code}
> java.lang.NullPointerException
> 	at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1472)
> 	at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)
> 	at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1923)
> 	at java.lang.ClassLoader.loadClass(Unknown Source)
> 	at org.bouncycastle.jcajce.provider.asymmetric.rsa.KeyFactorySpi.generatePublic(Unknown Source)
> 	at org.bouncycastle.jce.provider.BouncyCastleProvider.getPublicKey(Unknown Source)
> 	at org.bouncycastle.jce.provider.X509CertificateObject.getPublicKey(Unknown Source)
> 	at org.bouncycastle.operator.jcajce.JceAsymmetricKeyWrapper.<init>(Unknown Source)
> 	at org.bouncycastle.cms.jcajce.JceKeyTransRecipientInfoGenerator.<init>(Unknown Source)
> {code}
> Unfortunately this is really hard to reproduce. The problem occurs for me when I use Apache Sling in combination with javax.security and bouncycastle (everything installed as bundles) but in my eyes its not (only) related to that.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)