Return-Path: X-Original-To: apmail-felix-dev-archive@www.apache.org Delivered-To: apmail-felix-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 89E849B22 for ; Fri, 15 Jun 2012 22:41:44 +0000 (UTC) Received: (qmail 93235 invoked by uid 500); 15 Jun 2012 22:41:43 -0000 Delivered-To: apmail-felix-dev-archive@felix.apache.org Received: (qmail 93188 invoked by uid 500); 15 Jun 2012 22:41:43 -0000 Mailing-List: contact dev-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list dev@felix.apache.org Received: (qmail 93149 invoked by uid 99); 15 Jun 2012 22:41:42 -0000 Received: from issues-vm.apache.org (HELO issues-vm) (140.211.11.160) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Jun 2012 22:41:42 +0000 Received: from isssues-vm.apache.org (localhost [127.0.0.1]) by issues-vm (Postfix) with ESMTP id C8BB214002E for ; Fri, 15 Jun 2012 22:41:42 +0000 (UTC) Date: Fri, 15 Jun 2012 22:41:42 +0000 (UTC) From: "David Jencks (JIRA)" To: dev@felix.apache.org Message-ID: <1843810008.20453.1339800102824.JavaMail.jiratomcat@issues-vm> In-Reply-To: <1301549629.18002.1334250084061.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Updated] (FELIX-3456) Component ignores required static service addition when in Activating state MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/FELIX-3456?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] David Jencks updated FELIX-3456: -------------------------------- Attachment: FELIX-3456-8.diff We're finding some deadlocks with the current code. Following some suggestions from Michael Fraenkel, I changed to a read-write lock for creating the component instance and a CAS strategy for registering the service. This patch is not complete, it doesn't deal with ServiceFactory or (I think) ComponentFactory and I didn't implement the backwards compatible lock wrapper yet, but I'm putting it out for comments anyway. > Component ignores required static service addition when in Activating state > --------------------------------------------------------------------------- > > Key: FELIX-3456 > URL: https://issues.apache.org/jira/browse/FELIX-3456 > Project: Felix > Issue Type: Bug > Components: Declarative Services (SCR) > Affects Versions: scr-1.6.0 > Environment: Using org.apache.felix.scr svn rev 1298268 on Mac > Reporter: Richard Ellis > Priority: Critical > Fix For: scr-1.6.2 > > Attachments: FELIX-3456-1.1.diff, FELIX-3456-1.diff, FELIX-3456-3.diff, FELIX-3456-4.diff, FELIX-3456-5.diff, FELIX-3456-5a.diff, FELIX-3456-5b.diff, FELIX-3456-7.diff, FELIX-3456-7a.diff, FELIX-3456-8.diff, FELIX-3456-fmeschbe-6.patch, FELIX-3456-fmeschbe.patch > > > I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate. > This happens as follows: > 12:30:59:317 Thread 1 - Registers Service B/257 > 12:30:59:320 Thread 2 - Registers Service A/258 > 12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258 > 12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component > 12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating > 12:30:59:321 Thread 2 - Activating component > 12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257 > 12:30:59:321 Thread 2 - Dependency not satisfied: serviceB > 12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference > 12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate > 12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied > Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present. > There is a comment in DependencyManager#serviceAdded method: > // FELIX-1413: if the dependency is static and the component is > // satisfied (active) added services are not considered until > // the component is reactivated for other reasons. > This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time. > A simple fix would be to check the state of the component as well as if the service is static e.g. > replace if ( m_dependencyMetadata.isStatic() ) > with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE ) > This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread. > There are other fixes that could be done by synchronizing more around service additions. > Is anyone willing to make this fix or does anyone have any thoughts about this issue? > Thanks -- 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