jackrabbit-oak-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jukka Zitting (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (OAK-553) Add NameMapper#getValidOakName that never returns null
Date Wed, 16 Jan 2013 13:46:22 GMT

    [ https://issues.apache.org/jira/browse/OAK-553?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13555029#comment-13555029
] 

Jukka Zitting commented on OAK-553:
-----------------------------------

bq. there is quite a lot of code that doesn't check for null

To get us some numbers, here's a breakdown of all cases where getOakName() is called outside
of unit tests, along with suggested actions:

* 11 cases of getJcrName(getOakName()) -> replace with a new method as discussed above
* 6 cases with valid null checks (different exceptions thrown in all cases) -> no action
needed
* 3 borderline cases where null value is fine but unexpected (see NodeTypeImpl.matches, RestrictionProviderImpl.createRestriction)
-> add a comment to clarify the logic
* 2 cases of an apparently missing null check (see NodeTypeImpl.isNodeType, PrivilegeManagerImpl.getPrivilege)
-> fix
* 1 case of valid null return value -> no action needed

In addition there is the NodeUtil.getOakName method that confuses the matter somewhat by redefining
the getOakName contract. I'd rename it to follow the getOakNameOrThrow pattern from SessionDelegate.
                
> Add NameMapper#getValidOakName that never returns null
> ------------------------------------------------------
>
>                 Key: OAK-553
>                 URL: https://issues.apache.org/jira/browse/OAK-553
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: core
>            Reporter: angela
>
> we keep adding methods that convert a jcrName into an oak-name
> and throw an exception if the value returned by NameMapper#getOakName is
> null. instead of duplicating code i would like to add a second flavor
> of the method that throws if the the jcrName cannot be resolved to an oak
> name.
> i even suspect that most usages of the getOakName call that don't throw
> in case of null-value are susceptible to NPE. but we can still review those
> and possible replace them with the save method call.
> proposed patch for the interface:
> {code}
> /**
>      * Returns the Oak name for the specified JCR name. In contrast to
>      * {@link #getOakName(String)} this method will throw a {@code NamespaceException}
>      * if the JCR name is invalid and cannot be resolved.
>      *
>      * @param jcrName The JCR name to be converted.
>      * @return A valid Oak name.
>      * @throws NamespaceException If the JCR name cannot be resolved.
>      */
>     @Nonnull
>     String getValidOakName(@Nonnull String jcrName) throws NamespaceException;
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message