sling-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Arneh Jain (JIRA)" <>
Subject [jira] [Created] (SLING-7687) Some Adapters don't work during service deactivation
Date Tue, 29 May 2018 06:19:00 GMT
Arneh Jain created SLING-7687:

             Summary: Some Adapters don't work during service deactivation
                 Key: SLING-7687
             Project: Sling
          Issue Type: Bug
          Components: Apache Sling Testing Rules
    Affects Versions: Testing Sling Mock 2.2.18
            Reporter: Arneh Jain
         Attachments: patch.txt

If we have an AdapterFactory and a Service registered by the following code:

// code placeholder
SlingContext context = new SlingContext();
context.registerInjectActivateService(new TestAdapterFactory());
context.registerInjectActivateService(new TestService());{code}
it turns out that adapting a Resource to another Class (defined by the TestAdapterFactory)
returns null when done in the deactivate method of the TestService, i.e.

resource.adaptTo(TestClass.class) // returns null in the deactivate method.
resource.adaptTo(TestClass.class) // works correctly in any other method.{code}


It looks like the registered adapters are cleaned up before registered services are deactivated
in the tearDown method of SlingContextImpl. 

// SlingContextImpl
void tearDown() {
    super.tearDown(); // calls the deactivate of the registered services.


Cleaning up the registered adapters after deactivating the services seems to solve the issue. 
// SlingContextImpl
void tearDown() {
but I'm not sure about any other potential impacts of this change (attached patch). 



This message was sent by Atlassian JIRA

View raw message