[
https://issues.apache.org/jira/browse/SLING-2222?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13105995#comment-13105995
]
Aleksander Bandelj commented on SLING-2222:
-------------------------------------------
I agree, those NPE checks are not smelling good.I think
AbstractSlingRepository#setup should be the first thing called in
AbstractSlingRepository#activate, not indirectly through #setupRepository in
its superclass.
> SlingServerRepository startup and potential NPE
> -----------------------------------------------
>
> Key: SLING-2222
> URL: https://issues.apache.org/jira/browse/SLING-2222
> Project: Sling
> Issue Type: Bug
> Components: JCR
> Environment: Eclipse Equinox
> Reporter: Aleksander Bandelj
> Assignee: Justin Edelson
> Priority: Minor
> Fix For: JCR Base 2.1.2
>
>
> I'm starting Sling bundles from Equinox and there is now a NPE when starting
> repository (doesn't seem to happen in launchpad, probably because component
> and bundle activation order is different there).
> AbstractNamespaceMappingRepository#namespaceMapperTracker is used before
> initialized with #setup.
> SlingServerRepository(AbstractNamespaceMappingRepository).defineNamespacePrefixes(Session)
> line: 65
> SlingServerRepository(AbstractNamespaceMappingRepository).getNamespaceAwareSession(Session)
> line: 92
> SlingServerRepository(AbstractSlingRepository).login(Credentials, String)
> line: 216
> SlingServerRepository(AbstractSlingRepository).loginAdministrative(String)
> line: 171
> SlingServerRepository(AbstractSlingRepository).pingAndCheck() line: 499
> SlingServerRepository(AbstractSlingRepository).startRepository() line: 755
> SlingServerRepository(AbstractSlingRepository).activate(ComponentContext)
> line: 581
> the above will hit SlingServerRepository before #setup is called. #setup will
> be called second time around:
> SlingServerRepository(AbstractNamespaceMappingRepository).setup(BundleContext)
> line: 46
> SlingServerRepository(AbstractSlingRepository).setupRepository(Repository)
> line: 426
> SlingServerRepository(AbstractSlingRepository).startRepository() line: 758
> SlingServerRepository(AbstractSlingRepository).activate(ComponentContext)
> line: 581
> I've added NPE check for namespaceMapperTracker in defineNamespacePrefixes
> which works around this issue. NPE check for other namespaceHandler is
> already present.
> I would be good to simplify repository pinging code path and avoid the NPE
> checks though.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira