Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » [DS] Failure to activate a component does not reset already bound dependencies
[DS] Failure to activate a component does not reset already bound dependencies [message #84721] Wed, 21 March 2007 21:58
Samant Maharaj is currently offline Samant MaharajFriend
Messages: 1
Registered: July 2009
Junior Member
--nextPart2178513.6zcO6a7nyl
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8Bit

If a component managed by declarative services throws an exception during a
bind call or activate(), all the dependencies that have already been bound
remain bound.

This has the unfortunate result that any subsequent attempts to activate the
component will fail due to the previously bound dependencies not being
bound on the new instance created on the next activation attempt.

I have attached a patch to BuildDispose.java that I think resolves the
issue, however I'm not at all confident that this is an appropriate
solution to the problem.

In any case can someone let me know if this is a bug or expected behaviour.

Regards,
Samant

--nextPart2178513.6zcO6a7nyl
Content-Type: text/x-diff; name="BuildDispose.java.patch"
Content-Transfer-Encoding: 8Bit
Content-Disposition: attachment; filename="BuildDispose.java.patch"

Index: src/org/eclipse/equinox/ds/instance/BuildDispose.java
============================================================ =======
RCS file: /cvsroot/eclipse/org.eclipse.equinox.ds/src/org/eclipse/equi nox/ds/instance/BuildDispose.java,v
retrieving revision 1.2
diff -u -r1.2 BuildDispose.java
--- src/org/eclipse/equinox/ds/instance/BuildDispose.java 12 Jul 2006 19:01:44 -0000 1.2
+++ src/org/eclipse/equinox/ds/instance/BuildDispose.java 8 Mar 2007 22:41:49 -0000
@@ -125,6 +125,9 @@

} catch (ComponentException e) {
Log.log(1, "[SCR] Error attempting to build component ", e);
+ if(componentInstance != null) {
+ unbind(componentInstance);
+ }
throw e;

} finally {
@@ -178,11 +181,16 @@
}

// get all instances for this component
- Iterator it = componentConfiguration.getInstances().iterator();
+ final List instances = new ArrayList(componentConfiguration.getInstances());
+ Iterator it = instances.iterator();
while (it.hasNext()) {
- disposeComponentInstance((ComponentInstanceImpl) it.next());
+ final ComponentInstanceImpl instance = (ComponentInstanceImpl) it.next();
+ try {
+ disposeComponentInstance(instance);
+ } finally {
+ componentConfiguration.removeInstance(instance);
+ }
}
- componentConfiguration.removeAllInstances();

// clean up this component configuration object
it = componentConfiguration.getReferences().iterator();
@@ -561,7 +569,8 @@
* @param componentInstance
*/
private void unbindReference(Reference reference, ComponentInstanceImpl componentInstance) {
- Iterator itr = reference.getServiceReferences().iterator();
+ final Set serviceReferences = new HashSet(reference.getServiceReferences());
+ Iterator itr = serviceReferences.iterator();
while (itr.hasNext()) {
ServiceReference serviceReference = (ServiceReference) itr.next();
unbindServiceFromReference(reference, componentInstance, serviceReference);


--nextPart2178513.6zcO6a7nyl--
Previous Topic:Issues deploying using the Servletbridge
Next Topic:error deploying first standalone osgi app
Goto Forum:
  


Current Time: Fri Apr 26 06:37:39 GMT 2024

Powered by FUDForum. Page generated in 0.03099 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top