Uploaded image for project: 'Jackrabbit Oak'
  1. Jackrabbit Oak
  2. OAK-8212

ImporterImpl.importProperties prone to NPE

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.14.0, 1.10.4, 1.8.16
    • Component/s: jcr
    • Labels:
      None

      Description

      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:

      EffectiveNodeType ent = effectiveNodeTypeProvider.getEffectiveNodeType(tree);
      PropertyDefinition def = ent.getPropertyDefinition(pi.getName(), pi.getType(), pi.isUnknownMultiple());
      if (def.isProtected()) {
          ...
      }
      

      proposed fix (adding a check for null):

      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()) {
          ...
      }
      

      i spotted the issue while writing an import test for OAK-8190 with property type mismatch.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                angela Angela Schreiber
                Reporter:
                angela Angela Schreiber
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: