You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@aries.apache.org by "Christoph Gritschenberger (JIRA)" <ji...@apache.org> on 2012/07/16 18:50:35 UTC

[jira] [Created] (ARIES-875) ReferenceRecipe may "unget" a service without ever "getting" it

Christoph Gritschenberger created ARIES-875:
-----------------------------------------------

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


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

        

[jira] [Updated] (ARIES-875) ReferenceRecipe may "unget" a service without ever "getting" it

Posted by "Christoph Gritschenberger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ARIES-875?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Christoph Gritschenberger updated ARIES-875:
--------------------------------------------

    Attachment: get-service.patch

Patch that would fix the issue.
                
> 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, 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

        

[jira] [Commented] (ARIES-875) ReferenceRecipe may "unget" a service without ever "getting" it

Posted by "Guillaume Nodet (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/ARIES-875?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13421230#comment-13421230 ] 

Guillaume Nodet commented on ARIES-875:
---------------------------------------

I think the goal was to have a lazy getService call in order to avoid creating services until actually needed (for example blueprint exposes a ServiceFactory and will delay the actual initialization of the service until asked for).  So I guess it would be better to track if getService has been called and only call ungetService when appropriate.
                
> 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, 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

        

[jira] [Updated] (ARIES-875) ReferenceRecipe may "unget" a service without ever "getting" it

Posted by "Christoph Gritschenberger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ARIES-875?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Christoph Gritschenberger updated ARIES-875:
--------------------------------------------

    Attachment: my.playground.bundle-0.1.0-SNAPSHOT.jar
                playground-bundle.zip

Source and compiled jar for the demo-bundle.
Just deploy it in a Karaf-3.0.0-SNAPSHOT.
(It works correctly in karaf-2.2.5)
                
> 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: my.playground.bundle-0.1.0-SNAPSHOT.jar, 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

        

[jira] [Assigned] (ARIES-875) ReferenceRecipe may "unget" a service without ever "getting" it

Posted by "Guillaume Nodet (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ARIES-875?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Guillaume Nodet reassigned ARIES-875:
-------------------------------------

    Assignee: Guillaume Nodet
    
> 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
>            Assignee: Guillaume Nodet
>         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

        

[jira] [Comment Edited] (ARIES-875) ReferenceRecipe may "unget" a service without ever "getting" it

Posted by "Christoph Gritschenberger (JIRA)" <ji...@apache.org>.
    [ 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

        

[jira] [Resolved] (ARIES-875) ReferenceRecipe may "unget" a service without ever "getting" it

Posted by "Guillaume Nodet (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ARIES-875?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Guillaume Nodet resolved ARIES-875.
-----------------------------------

       Resolution: Fixed
    Fix Version/s: blueprint-core-1.0.1

http://svn.apache.org/viewvc?rev=1365271&view=rev
                
> 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
>            Assignee: Guillaume Nodet
>             Fix For: blueprint-core-1.0.1
>
>         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

        

[jira] [Updated] (ARIES-875) ReferenceRecipe may "unget" a service without ever "getting" it

Posted by "Christoph Gritschenberger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ARIES-875?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Christoph Gritschenberger updated ARIES-875:
--------------------------------------------

    Attachment: only-unget-when-get-service.patch

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