aries-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christoph Gritschenberger (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (ARIES-875) ReferenceRecipe may "unget" a service without ever "getting" it
Date Tue, 24 Jul 2012 13:48:36 GMT

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

Christoph Gritschenberger edited comment on ARIES-875 at 7/24/12 1:47 PM:
--------------------------------------------------------------------------

attached alternative patch that fixes bind() and unbind() to only call ungetService when getService
was called.
                
      was (Author: christophg):
    Fixes bind() and unbind() to only call ungetService when getService was called.
                  
> ReferenceRecipe may "unget" a service without ever "getting" it
> ---------------------------------------------------------------
>
>                 Key: ARIES-875
>                 URL: https://issues.apache.org/jira/browse/ARIES-875
>             Project: Aries
>          Issue Type: Bug
>          Components: Blueprint
>         Environment: karaf-3.0.0-SNAPSHOT, Aries-1.0.0-SNAPSHOT
>            Reporter: Christoph Gritschenberger
>         Attachments: get-service.patch, my.playground.bundle-0.1.0-SNAPSHOT.jar, only-unget-when-get-service.patch,
playground-bundle.zip
>
>
> I discovered this when trying to use the "ConfigurationAdmin"-service in both blueprint
and a BundleActivator. Normally this should work but I get this Exception 
> {code}
> java.lang.NullPointerException
> 	at org.apache.felix.cm.impl.ConfigurationAdminImpl.getConfiguration(ConfigurationAdminImpl.java:105)
> 	at my.playground.bundle.Activator$ConfigThread.run(Activator.java:29)
> {code}
> This is because this ConfigurationAdminImpl has been "disposed" after blueprint called
"ungetService" in ReferenceRecipe#unbind().
> Normally this should go like this:
> activator gets ConfigAdmin-service
> blueprint gets ConfigAdmin-service
> blueprint ungets ConfigAdmin-service (reference-counter still > 0, so it is not destroyed)
> activator ungets ConfigAdmin-service (reference-counter is now 0, so the dispose-method
in the ConfigAdmin is called).
> But what happens is this:
> activator gets ConfigAdmin-service
> blueprint ungets ConfigAdmin-service (reference-counter is now 0, so the dispose-method
in the ConfigAdmin is called).
> activator throws NPE because the ConfigAdmin-service has been destroyed.
> The Problem is that calling ReferenceRecipe#unbind() always *ungets* the service, but
ReferenceRecipe#bind() does not *get* the service. Thus the *unget*-operation invalidates
the service-reference for some other thread.
> I attached a small demo-bundle to show the behaviour. Deploying it in a karaf-3.0.0-SNAPSHOT
should show the NPE on the console.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message