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