You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-issues@jackrabbit.apache.org by "Julian Reschke (JIRA)" <ji...@apache.org> on 2019/08/16 12:20:00 UTC
[jira] [Comment Edited] (OAK-8212) ImporterImpl.importProperties
prone to NPE
[ https://issues.apache.org/jira/browse/OAK-8212?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16893471#comment-16893471 ]
Julian Reschke edited comment on OAK-8212 at 8/16/19 12:19 PM:
---------------------------------------------------------------
trunk: (1.14.0) [r1857242|http://svn.apache.org/r1857242]
1.10: (1.10.4) [r1863781|http://svn.apache.org/r1863781]
1.8: [r1865296|http://svn.apache.org/r1865296]
was (Author: reschke):
trunk: (1.14.0) [r1857242|http://svn.apache.org/r1857242]
1.10: [r1863781|http://svn.apache.org/r1863781]
> ImporterImpl.importProperties prone to NPE
> ------------------------------------------
>
> Key: OAK-8212
> URL: https://issues.apache.org/jira/browse/OAK-8212
> Project: Jackrabbit Oak
> Issue Type: Bug
> Components: jcr
> Reporter: angela
> Assignee: angela
> Priority: Major
> Fix For: 1.14.0, 1.10.4, 1.8.16
>
>
> the {{ImportImpl}} code at line 275 is prone to NPE because {{EffectiveNodeType.getPropertyDefinition(String, int, boolean)}} may return {{null}} (in contrast to the second variant that throws {{ConstraintViolationException}} if no matching definition is found.
> the code looks as follows:
> {code}
> EffectiveNodeType ent = effectiveNodeTypeProvider.getEffectiveNodeType(tree);
> PropertyDefinition def = ent.getPropertyDefinition(pi.getName(), pi.getType(), pi.isUnknownMultiple());
> if (def.isProtected()) {
> ...
> }
> {code}
> proposed fix (adding a check for null):
> {code}
> EffectiveNodeType ent = effectiveNodeTypeProvider.getEffectiveNodeType(tree);
> PropertyDefinition def = ent.getPropertyDefinition(pi.getName(), pi.getType(), pi.isUnknownMultiple());
> if (def == null) {
> throw new ConstraintViolationException("No matching property definition found for " + pi.getName());
> }
> if (def.isProtected()) {
> ...
> }
> {code}
> i spotted the issue while writing an import test for OAK-8190 with property type mismatch.
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)