You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Stefan Seifert (JIRA)" <ji...@apache.org> on 2018/08/06 08:19:00 UTC
[jira] [Closed] (SLING-7687) Some Adapters don't work during
service deactivation
[ https://issues.apache.org/jira/browse/SLING-7687?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Stefan Seifert closed SLING-7687.
---------------------------------
> Some Adapters don't work during service deactivation
> ----------------------------------------------------
>
> Key: SLING-7687
> URL: https://issues.apache.org/jira/browse/SLING-7687
> Project: Sling
> Issue Type: Bug
> Components: Testing
> Affects Versions: Testing Sling Mock 2.2.18
> Reporter: Arneh Jain
> Assignee: Stefan Seifert
> Priority: Major
> Labels: mocks
> Fix For: Testing Sling Mock 2.2.20
>
> Attachments: patch.txt
>
>
> If we have an AdapterFactory and a Service registered by the following code:
>
> {code:java}
> // 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.
>
> {code:java}
> resource.adaptTo(TestClass.class) // returns null in the deactivate method.
> resource.adaptTo(TestClass.class) // works correctly in any other method.{code}
>
> Reason:
> It looks like the registered adapters are cleaned up before registered services are deactivated in the tearDown method of SlingContextImpl.
>
> {code:java}
> // SlingContextImpl
> void tearDown() {
> ...
> MockSling.clearAdapterManagerBundleContext();
> ...
> super.tearDown(); // calls the deactivate of the registered services.
> }{code}
>
>
> Cleaning up the registered adapters after deactivating the services seems to solve the issue.
> {code:java}
> // SlingContextImpl
> void tearDown() {
> ...
> super.tearDown();
> MockSling.clearAdapterManagerBundleContext();
> }
> {code}
> but I'm not sure about any other potential impacts of this change (attached patch).
>
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)