You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@aries.apache.org by "Hao Zhong (JIRA)" <ji...@apache.org> on 2017/03/17 00:47:41 UTC

[jira] [Commented] (ARIES-1701) A Possible NPE

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

Hao Zhong commented on ARIES-1701:
----------------------------------

ARIES-788 fixed the code as follow:
ServiceReference ref = reference;
                reference = null;
                service = null;
                proxy = null;
                Bundle bundle = ref.getBundle();
                if (bundle != null) {
                    BundleContext ctx = bundle.getBundleContext();
                    if (ctx != null) {
                        ctx.ungetService(reference);
                    }
                }

> A Possible NPE
> --------------
>
>                 Key: ARIES-1701
>                 URL: https://issues.apache.org/jira/browse/ARIES-1701
>             Project: Aries
>          Issue Type: Bug
>          Components: Blueprint
>    Affects Versions: blueprint-core-1.7.0
>            Reporter: Hao Zhong
>
> I found that the CmUtils.getProperties method has a buggy code as follow:
> try {
>             ConfigurationAdmin ca = bc.getService(caRef);
>             Configuration config = getConfiguration(ca, persistentId);
>             if (config != null) {
>                 Dictionary<String, Object> props = new CaseInsensitiveDictionary(config.getProperties());
>                 BundleContext caBc = caRef.getBundle().getBundleContext();
>                 callPlugins(caBc, props, service, persistentId, null);
>                 return props;
>             } else {
>                 return null;
>             }
>         } finally {
>             bc.ungetService(caRef);
>         }
> Here, before calling ungetService, the call chain BundleContext caBc = caRef.getBundle().getBundleContext() can throw NPE.
> Indeed, a similar bug is fixed in ARIES-788. Please check this bug at https://issues.apache.org/jira/browse/ARIES-788?jql=project%20%3D%20ARIES



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)