You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Carsten Ziegeler (Jira)" <ji...@apache.org> on 2022/06/02 08:12:00 UTC
[jira] [Commented] (SLING-11367) Potential NPE as ResolveContext.getProviderState() is nullable
[ https://issues.apache.org/jira/browse/SLING-11367?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17545338#comment-17545338 ]
Carsten Ziegeler commented on SLING-11367:
------------------------------------------
This might be a matter of taste and how it will be exactly done. But we should not complicate the code just because of a code analysis message which is kind of a false positive in this case.
I think we can probably do this in the context implementation and simply throw a Runtime Exception (or similar) if the context is not active anymore. Today we get a NullPointerException downstream which is okish but not that nice
> Potential NPE as ResolveContext.getProviderState() is nullable
> ---------------------------------------------------------------
>
> Key: SLING-11367
> URL: https://issues.apache.org/jira/browse/SLING-11367
> Project: Sling
> Issue Type: Sub-task
> Components: JCR
> Affects Versions: JCR Resource 3.2.0
> Reporter: Angela Schreiber
> Priority: Minor
>
> since {{ResolveContext.getProviderState()}} is defined to return a nullable provider state code analysis spots this a potential source for NPE. according to [~cziegeler] this should never return null as long as the provider is active.
> i would suggest to move access to session, resourcefactory and helperdata to a utility with comments on why the NPE should not occur.
--
This message was sent by Atlassian Jira
(v8.20.7#820007)